Skip to content

Commit bbb642e

Browse files
authored
Write IPv6 management config as well when ejecting an host (xapi-project#6013)
Until now only the IPv4 config was written and an IPv6 ejected host would loose its config after restarting in its own pool.
2 parents 150f62f + 8466733 commit bbb642e

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

ocaml/xapi/xapi_pool.ml

+27-3
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,11 @@ let eject_self ~__context ~host =
18921892
| `Static ->
18931893
"static"
18941894
in
1895+
let mode_v6 =
1896+
Record_util.ipv6_configuration_mode_to_string
1897+
pif.API.pIF_ipv6_configuration_mode
1898+
|> String.uncapitalize_ascii
1899+
in
18951900
let write_first_boot_management_interface_configuration_file () =
18961901
(* During firstboot, now inventory has an empty MANAGEMENT_INTERFACE *)
18971902
let bridge = "" in
@@ -1905,7 +1910,11 @@ let eject_self ~__context ~host =
19051910
(* If the management_interface exists on a vlan, write the vlan id into management.conf *)
19061911
let vlan_id = Int64.to_int pif.API.pIF_VLAN in
19071912
let config_base =
1908-
[sprintf "LABEL='%s'" management_device; sprintf "MODE='%s'" mode]
1913+
[
1914+
sprintf "LABEL='%s'" management_device
1915+
; sprintf "MODE='%s'" mode
1916+
; sprintf "MODEV6='%s'" mode_v6
1917+
]
19091918
in
19101919
let config_static =
19111920
if mode <> "static" then
@@ -1915,17 +1924,32 @@ let eject_self ~__context ~host =
19151924
sprintf "IP='%s'" pif.API.pIF_IP
19161925
; sprintf "NETMASK='%s'" pif.API.pIF_netmask
19171926
; sprintf "GATEWAY='%s'" pif.API.pIF_gateway
1918-
; sprintf "DNS='%s'" pif.API.pIF_DNS
19191927
]
19201928
in
1929+
let configv6_static =
1930+
if mode_v6 <> "static" then
1931+
[]
1932+
else
1933+
[
1934+
sprintf "IPv6='%s'" (String.concat "," pif.API.pIF_IPv6)
1935+
; sprintf "IPv6_GATEWAY='%s'" pif.API.pIF_ipv6_gateway
1936+
]
1937+
in
1938+
let config_dns =
1939+
if mode = "static" || mode_v6 = "static" then
1940+
[sprintf "DNS='%s'" pif.API.pIF_DNS]
1941+
else
1942+
[]
1943+
in
19211944
let config_vlan =
19221945
if vlan_id = -1 then
19231946
[]
19241947
else
19251948
[sprintf "VLAN='%d'" vlan_id]
19261949
in
19271950
let configuration_file =
1928-
List.concat [config_base; config_static; config_vlan]
1951+
List.concat
1952+
[config_base; config_static; configv6_static; config_dns; config_vlan]
19291953
|> String.concat "\n"
19301954
in
19311955
Unixext.write_string_to_file

0 commit comments

Comments
 (0)