Skip to content

Commit ea1de2f

Browse files
committed
CP-44103: Ordering network devices - IDL changes
Signed-off-by: Ming Lu <[email protected]>
1 parent e0d3512 commit ea1de2f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

ocaml/networkd/lib/network_config.ml

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ let read_management_conf () =
187187
; bridge_config
188188
; gateway_interface= Some bridge_name
189189
; dns_interface= Some bridge_name
190+
; interface_order= None
190191
}
191192
with e ->
192193
error "Error while trying to read firstboot data: %s\n%s"

ocaml/xapi-idl/network/dune

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
xapi-idl
1212
xapi-log
1313
ipaddr
14+
macaddr
1415
)
1516
(wrapped false)
1617
(preprocess (pps ppx_deriving_rpc)))

ocaml/xapi-idl/network/network_interface.ml

+38
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,31 @@ module Unix = struct
8181
}
8282
end
8383

84+
module Macaddr = struct
85+
include Macaddr
86+
87+
let typ_of =
88+
Rpc.Types.Abstract
89+
{
90+
aname= "macaddr"
91+
; test_data= [Macaddr.of_string_exn "ca:fe:ba:be:ee:ee"]
92+
; rpc_of= (fun t -> Rpc.String (Macaddr.to_string t))
93+
; of_rpc=
94+
(function
95+
| Rpc.String s ->
96+
Ok (Macaddr.of_string_exn s)
97+
| r ->
98+
Error
99+
(`Msg
100+
(Printf.sprintf
101+
"typ_of_macaddr: expectd rpc string but got %s"
102+
(Rpc.to_string r)
103+
)
104+
)
105+
)
106+
}
107+
end
108+
84109
(** {2 Types} *)
85110

86111
type debug_info = string [@@deriving rpcty]
@@ -91,6 +116,8 @@ type port = string [@@deriving rpcty]
91116

92117
type bridge = string [@@deriving rpcty]
93118

119+
type mac_address = Macaddr.t [@@deriving rpcty]
120+
94121
(* rpcty cannot handle polymorphic variant, so change the definition to variant *)
95122
type dhcp_options = Set_gateway | Set_dns [@@deriving rpcty]
96123

@@ -184,11 +211,21 @@ type bridge_config_t = {
184211
}
185212
[@@deriving rpcty]
186213

214+
type ordered_iface = {
215+
name: iface
216+
; position: int
217+
; mac: mac_address
218+
; pci: Xcp_pci.address
219+
; present: bool
220+
}
221+
[@@deriving rpcty]
222+
187223
type config_t = {
188224
interface_config: (iface * interface_config_t) list [@default []]
189225
; bridge_config: (bridge * bridge_config_t) list [@default []]
190226
; gateway_interface: iface option [@default None]
191227
; dns_interface: iface option [@default None]
228+
; interface_order: ordered_iface list option [@default None]
192229
}
193230
[@@deriving rpcty]
194231

@@ -226,6 +263,7 @@ let default_config =
226263
; bridge_config= []
227264
; gateway_interface= None
228265
; dns_interface= None
266+
; interface_order= None
229267
}
230268

231269
(** {2 Configuration manipulation} *)

0 commit comments

Comments
 (0)