File tree 5 files changed +73
-19
lines changed
5 files changed +73
-19
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,15 @@ let refresh_localhost_info ~__context info =
126
126
) else
127
127
Db.Host. remove_from_other_config ~__context ~self: host
128
128
~key: Xapi_globs. host_no_local_storage ;
129
+ let options =
130
+ match Helpers. get_management_iface_primary_address_type ~__context with
131
+ | `IPv4 ->
132
+ [" check" ; " 80" ]
133
+ | `IPv6 ->
134
+ [" -6" ; " check" ; " 80" ]
135
+ in
129
136
let script_output =
130
- Helpers. call_script ! Xapi_globs. firewall_port_config_script [ " check " ; " 80 " ]
137
+ Helpers. call_script ! Xapi_globs. firewall_port_config_script options
131
138
in
132
139
try
133
140
let network_state = Scanf. sscanf script_output " Port 80 open: %B" Fun. id in
Original file line number Diff line number Diff line change @@ -150,6 +150,18 @@ let get_management_ip_addr ~__context =
150
150
let dbg = Context. string_of_task __context in
151
151
Option. map fst (Networking_info. get_management_ip_addr ~dbg )
152
152
153
+ let get_management_interface ~__context ~host =
154
+ let pifs =
155
+ Db.PIF. get_refs_where ~__context
156
+ ~expr:
157
+ (And
158
+ ( Eq (Field " host" , Literal (Ref. string_of host))
159
+ , Eq (Field " management" , Literal " true" )
160
+ )
161
+ )
162
+ in
163
+ match pifs with [] -> raise Not_found | pif :: _ -> pif
164
+
153
165
let get_localhost_uuid () =
154
166
Xapi_inventory. lookup Xapi_inventory. _installation_uuid
155
167
@@ -165,6 +177,11 @@ let get_localhost ~__context =
165
177
| true ->
166
178
get_localhost_uncached ~__context
167
179
180
+ let get_management_iface_primary_address_type ~__context =
181
+ let host = get_localhost ~__context in
182
+ let management_pif = get_management_interface ~__context ~host in
183
+ Db.PIF. get_primary_address_type ~__context ~self: management_pif
184
+
168
185
(* Determine the gateway and DNS PIFs:
169
186
* If one of the PIFs with IP has other_config:defaultroute=true, then
170
187
* pick this one as gateway PIF. If there are multiple, pick a random one of these.
Original file line number Diff line number Diff line change @@ -796,10 +796,20 @@ let bring_pif_up ~__context ?(management_interface = false) (pif : API.ref_PIF)
796
796
| `vxlan ->
797
797
debug
798
798
" Opening VxLAN UDP port for tunnel with protocol 'vxlan'" ;
799
+ let options =
800
+ match
801
+ Helpers. get_management_iface_primary_address_type
802
+ ~__context
803
+ with
804
+ | `IPv4 ->
805
+ [" open" ; " 4789" ; " udp" ]
806
+ | `IPv6 ->
807
+ [" -6" ; " open" ; " 4789" ; " udp" ]
808
+ in
799
809
ignore
800
810
@@ Helpers. call_script
801
811
! Xapi_globs. firewall_port_config_script
802
- [ " open " ; " 4789 " ; " udp " ]
812
+ options
803
813
| `gre ->
804
814
()
805
815
)
@@ -857,6 +867,16 @@ let bring_pif_down ~__context ?(force = false) (pif : API.ref_PIF) =
857
867
in
858
868
if no_more_vxlan then (
859
869
debug " Last VxLAN tunnel was closed, closing VxLAN UDP port" ;
870
+ let options =
871
+ match
872
+ Helpers. get_management_iface_primary_address_type
873
+ ~__context
874
+ with
875
+ | `IPv4 ->
876
+ [" close" ; " 4789" ; " udp" ]
877
+ | `IPv6 ->
878
+ [" -6" ; " close" ; " 4789" ; " udp" ]
879
+ in
860
880
ignore
861
881
@@ Helpers. call_script
862
882
! Xapi_globs. firewall_port_config_script
Original file line number Diff line number Diff line change @@ -274,9 +274,18 @@ module Daemon = struct
274
274
raise Api_errors. (Server_error (not_implemented, [" Cluster.create" ]))
275
275
) ;
276
276
( try
277
+ let options =
278
+ match
279
+ Helpers. get_management_iface_primary_address_type ~__context
280
+ with
281
+ | `IPv4 ->
282
+ [" open" ; port]
283
+ | `IPv6 ->
284
+ [" -6" ; " open" ; port]
285
+ in
277
286
maybe_call_script ~__context
278
287
! Xapi_globs. firewall_port_config_script
279
- [ " open " ; port] ;
288
+ options ;
280
289
maybe_call_script ~__context ! Xapi_globs. systemctl [" enable" ; service] ;
281
290
maybe_call_script ~__context ! Xapi_globs. systemctl [" start" ; service]
282
291
with _ ->
@@ -295,9 +304,14 @@ module Daemon = struct
295
304
Atomic. set enabled false ;
296
305
maybe_call_script ~__context ! Xapi_globs. systemctl [" disable" ; service] ;
297
306
maybe_call_script ~__context ! Xapi_globs. systemctl [" stop" ; service] ;
298
- maybe_call_script ~__context
299
- ! Xapi_globs. firewall_port_config_script
300
- [" close" ; port] ;
307
+ let options =
308
+ match Helpers. get_management_iface_primary_address_type ~__context with
309
+ | `IPv4 ->
310
+ [" close" ; port]
311
+ | `IPv6 ->
312
+ [" -6" ; " close" ; port]
313
+ in
314
+ maybe_call_script ~__context ! Xapi_globs. firewall_port_config_script options ;
301
315
debug " Cluster daemon: disabled & stopped"
302
316
303
317
let restart ~__context =
Original file line number Diff line number Diff line change @@ -1221,16 +1221,7 @@ let syslog_reconfigure ~__context ~host:_ =
1221
1221
()
1222
1222
1223
1223
let get_management_interface ~__context ~host =
1224
- let pifs =
1225
- Db.PIF. get_refs_where ~__context
1226
- ~expr:
1227
- (And
1228
- ( Eq (Field " host" , Literal (Ref. string_of host))
1229
- , Eq (Field " management" , Literal " true" )
1230
- )
1231
- )
1232
- in
1233
- match pifs with [] -> raise Not_found | pif :: _ -> pif
1224
+ Helpers. get_management_interface ~__context ~host
1234
1225
1235
1226
let change_management_interface ~__context interface primary_address_type =
1236
1227
debug " Changing management interface" ;
@@ -3045,10 +3036,15 @@ let set_https_only ~__context ~self ~value =
3045
3036
let state = match value with true -> " close" | false -> " open" in
3046
3037
match cc_prep () with
3047
3038
| false ->
3039
+ let options =
3040
+ match Helpers. get_management_iface_primary_address_type ~__context with
3041
+ | `IPv4 ->
3042
+ [state; " 80" ]
3043
+ | `IPv6 ->
3044
+ [" -6" ; state; " 80" ]
3045
+ in
3048
3046
ignore
3049
- @@ Helpers. call_script
3050
- ! Xapi_globs. firewall_port_config_script
3051
- [state; " 80" ] ;
3047
+ @@ Helpers. call_script ! Xapi_globs. firewall_port_config_script options ;
3052
3048
Db.Host. set_https_only ~__context ~self ~value
3053
3049
| true when value = Db.Host. get_https_only ~__context ~self ->
3054
3050
(* the new value is the same as the old value *)
You can’t perform that action at this time.
0 commit comments