Skip to content

Commit 309884a

Browse files
committed
CA-303529/CA-287657: Immediately setup management on first boot
Since we put in support for management-on-VLAN, setting up the management IP address on first boot has been a little different. In the past, xcp-networkd would set this up immediately by taking the configuration from the MANAGEMENT_INTERFACE key in the inventory, and the management.conf file in the first-boot data, both written by the host installer. Then, we changed the host installer to no longer write the MANAGEMENT_INTERFACE key, because we do not have a deterministic name for VLAN bridges: the management bridge name becomes know only once the first-boot scripts run. Besides, it is good to not have this naming policy encoded in the host installer as well as in the Toolstack. The startup sequence of xcp-networkd was changed to not configure anything in this case, and instead wait for xapi and the first-boot scripts. This mean that, on first boot, the management IP address was set much later than before. Unfortunately, there are services that run at host boot time, such as ntpdate, that do not cope with this very well. This commit changes back to the old behaviour, where xcp-networkd immediately configures the network on first boot, by having it derive the bridge name itself. For the non-VLAN case, this is easy, because of the deterministic naming policy. For the VLAN case, a bridge with a temporary name is created, which is later replaced by xapi once the first-boot scripts run. This is in fact the same as what happens during an emergency network reset (see xe-reset-networking). Signed-off-by: Rob Hoes <[email protected]>
1 parent 6aec118 commit 309884a

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

lib/network_config.ml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)