@@ -42,8 +42,28 @@ let read_management_conf () =
4242 let device = List. assoc " LABEL" args in
4343 let vlan = if List. mem_assoc " VLAN" args then Some (List. assoc " VLAN" args) else None in
4444 Inventory. reread_inventory () ;
45- let bridge_name = Inventory. lookup Inventory. _management_interface in
46- debug " Management bridge in inventory file: %s" bridge_name;
45+ let bridge_name =
46+ let inventory_bridge =
47+ try Some (Inventory. lookup Inventory. _management_interface)
48+ with Inventory. Missing_inventory_key _ -> None
49+ in
50+ match inventory_bridge with
51+ | Some "" | None ->
52+ let bridge =
53+ if vlan = None then
54+ bridge_naming_convention device
55+ else
56+ (* At this point, we don't know what the VLAN bridge name will be,
57+ * so use a temporary name. Xapi will replace the bridge once the name
58+ * has been decided on. *)
59+ " xentemp"
60+ in
61+ debug " No management bridge in inventory file... using %s" bridge;
62+ bridge
63+ | Some bridge ->
64+ debug " Management bridge in inventory file: %s" bridge;
65+ bridge
66+ in
4767 let mac = Network_utils.Ip. get_mac device in
4868 let ipv4_conf, ipv4_gateway, dns =
4969 match List. assoc " MODE" args with
@@ -78,24 +98,20 @@ let read_management_conf () =
7898 ports = [device, {default_port with interfaces = [device]}];
7999 persistent_b = true
80100 } in
81- if bridge_name = " " then
82- [] , []
83- else begin
84- match vlan with
85- | None ->
86- [device, phy_interface; bridge_name, bridge_interface],
87- [bridge_name, primary_bridge_conf]
88- | Some vlan ->
89- let parent = bridge_naming_convention device in
90- let secondary_bridge_conf = {default_bridge with
91- vlan = Some (parent, int_of_string vlan);
92- bridge_mac = (Some mac);
93- persistent_b = true
94- } in
95- let parent_bridge_interface = {default_interface with persistent_i = true } in
96- [device, phy_interface; parent, parent_bridge_interface; bridge_name, bridge_interface],
97- [parent, primary_bridge_conf; bridge_name, secondary_bridge_conf]
98- end
101+ match vlan with
102+ | None ->
103+ [device, phy_interface; bridge_name, bridge_interface],
104+ [bridge_name, primary_bridge_conf]
105+ | Some vlan ->
106+ let parent = bridge_naming_convention device in
107+ let secondary_bridge_conf = {default_bridge with
108+ vlan = Some (parent, int_of_string vlan);
109+ bridge_mac = (Some mac);
110+ persistent_b = true
111+ } in
112+ let parent_bridge_interface = {default_interface with persistent_i = true } in
113+ [device, phy_interface; parent, parent_bridge_interface; bridge_name, bridge_interface],
114+ [parent, primary_bridge_conf; bridge_name, secondary_bridge_conf]
99115 in
100116 {interface_config = interface_config; bridge_config = bridge_config;
101117 gateway_interface = Some bridge_name; dns_interface = Some bridge_name}
0 commit comments