Skip to content

Commit

Permalink
[CP-2505] Change Pool.eject so that it writes first-boot networking d…
Browse files Browse the repository at this point in the history
…ata for only the management interface, and not for every interface.

Signed-off-by: Jonathan Knowles <jonathan.knowles@eu.citrix.com>
  • Loading branch information
jonathanknowles committed Mar 23, 2011
1 parent 060fd0f commit efb92d5
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions ocaml/xapi/xapi_pool.ml
Expand Up @@ -723,46 +723,41 @@ let eject ~__context ~host =
debug "Pool.eject: rewrite networking first-boot files";
let management_pif = Xapi_host.get_management_interface ~__context ~host in
let pif = Db.PIF.get_record ~__context ~self:management_pif in
let management_mac =
let management_device =
(* assumes that the management interface is either physical or a bond *)
if pif.API.pIF_bond_master_of <> [] then
let bond = List.hd pif.API.pIF_bond_master_of in
let slaves = Db.Bond.get_slaves ~__context ~self:bond in
let first_slave = List.hd slaves in
Db.PIF.get_MAC ~__context ~self:first_slave
Db.PIF.get_device ~__context ~self:first_slave
else
pif.API.pIF_MAC
pif.API.pIF_device
in
let mode = match pif.API.pIF_ip_configuration_mode with
| `None -> "none"
| `DHCP -> "dhcp"
| `Static -> "static"
in
let t = Xapi_pif.make_tables ~__context ~host in
let interfaces = List.fold_left
(fun ifs (mac, device) ->
let s =
if mac <> management_mac then
"LABEL='" ^ device ^ "'\nMODE=none\n"
else begin
let bridge = Xapi_pif.bridge_naming_convention device in
Xapi_inventory.update Xapi_inventory._management_interface bridge;
"LABEL='" ^ device ^ "'\nMODE=" ^ mode ^
if mode = "static" then
"\nIP=" ^ pif.API.pIF_IP ^
"\nNETMASK=" ^ pif.API.pIF_netmask ^
"\nGATEWAY=" ^ pif.API.pIF_gateway ^
"\nDNS=" ^ pif.API.pIF_DNS ^ "\n"
else
"\n"
end
in
Unixext.write_string_to_file (Xapi_globs.first_boot_dir ^ "data/interface-" ^ mac ^ ".conf") s;
mac :: ifs
) [] t.Xapi_pif.mac_to_biosname_table
in
let s = "ADMIN_INTERFACE='" ^ management_mac ^ "'\nINTERFACES='" ^ (String.concat " " interfaces) ^ "'\n" in
Unixext.write_string_to_file (Xapi_globs.first_boot_dir ^ "data/network.conf") s;

let write_first_boot_management_interface_configuration_file () =
let bridge = Xapi_pif.bridge_naming_convention management_device in
Xapi_inventory.update Xapi_inventory._management_interface bridge;
let configuration_file_contents = begin
"LABEL='" ^ management_device ^ "'\nMODE=" ^ mode ^
if mode = "static" then
"\nIP=" ^ pif.API.pIF_IP ^
"\nNETMASK=" ^ pif.API.pIF_netmask ^
"\nGATEWAY=" ^ pif.API.pIF_gateway ^
"\nDNS=" ^ pif.API.pIF_DNS ^ "\n"
else
"\n"
end in
Unixext.write_string_to_file
(Xapi_globs.first_boot_dir ^ "data/management.conf")
(configuration_file_contents) in

write_first_boot_management_interface_configuration_file ();

Xapi_inventory.update Xapi_inventory._current_interfaces "";

debug "Pool.eject: deleting Host record (the point of no return)";
Expand Down

0 comments on commit efb92d5

Please sign in to comment.