Skip to content

Commit fa5d829

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

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

ocaml/networkd/lib/network_config.ml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,34 @@ 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_octets t))
93+
; of_rpc=
94+
(function
95+
| Rpc.String s ->
96+
Macaddr.of_octets s
97+
|> Result.map_error (fun (`Msg e) ->
98+
`Msg (Printf.sprintf "typ_of_macaddr: %s" e)
99+
)
100+
| r ->
101+
Error
102+
(`Msg
103+
(Printf.sprintf
104+
"typ_of_macaddr: expectd rpc string but got %s"
105+
(Rpc.to_string r)
106+
)
107+
)
108+
)
109+
}
110+
end
111+
84112
(** {2 Types} *)
85113

86114
type debug_info = string [@@deriving rpcty]
@@ -91,6 +119,8 @@ type port = string [@@deriving rpcty]
91119

92120
type bridge = string [@@deriving rpcty]
93121

122+
type mac_address = Macaddr.t [@@deriving rpcty]
123+
94124
(* rpcty cannot handle polymorphic variant, so change the definition to variant *)
95125
type dhcp_options = Set_gateway | Set_dns [@@deriving rpcty]
96126

@@ -184,11 +214,21 @@ type bridge_config_t = {
184214
}
185215
[@@deriving rpcty]
186216

217+
type ordered_iface = {
218+
name: iface
219+
; position: int
220+
; mac: mac_address
221+
; pci: Xcp_pci.address
222+
; present: bool
223+
}
224+
[@@deriving rpcty]
225+
187226
type config_t = {
188227
interface_config: (iface * interface_config_t) list [@default []]
189228
; bridge_config: (bridge * bridge_config_t) list [@default []]
190229
; gateway_interface: iface option [@default None]
191230
; dns_interface: iface option [@default None]
231+
; interface_order: ordered_iface list option [@default None]
192232
}
193233
[@@deriving rpcty]
194234

@@ -226,6 +266,7 @@ let default_config =
226266
; bridge_config= []
227267
; gateway_interface= None
228268
; dns_interface= None
269+
; interface_order= None
229270
}
230271

231272
(** {2 Configuration manipulation} *)

0 commit comments

Comments
 (0)