File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ let get_start_time () =
81
81
82
82
(* not sufficient just to fill in this data on create time [Xen caps may change if VT enabled in BIOS etc.] *)
83
83
84
+ (* may raise Scan_failure *)
85
+
84
86
(* * Update the information in the Host structure *)
85
87
let refresh_localhost_info ~__context info =
86
88
let host = ! Xapi_globs. localhost_ref in
@@ -122,8 +124,25 @@ let refresh_localhost_info ~__context info =
122
124
~key: Xapi_globs. host_no_local_storage ~value: " true"
123
125
) else
124
126
Db.Host. remove_from_other_config ~__context ~self: host
125
- ~key: Xapi_globs. host_no_local_storage
126
-
127
+ ~key: Xapi_globs. host_no_local_storage ;
128
+ let script_output =
129
+ Helpers. call_script ! Xapi_globs. firewall_port_config_script [" check" ; " 80" ]
130
+ in
131
+ try
132
+ let network_state = Scanf. sscanf script_output " Port 80 open: %B" Fun. id in
133
+ Db.Host. set_https_only ~__context ~self: host ~value: network_state
134
+ with _ ->
135
+ raise
136
+ Api_errors. (
137
+ Server_error
138
+ ( internal_error
139
+ , [
140
+ Printf. sprintf
141
+ " unexpected output from /etc/xapi.d/plugins/firewall-port: %s"
142
+ script_output
143
+ ]
144
+ )
145
+ )
127
146
(* ************** update database tools ******************)
128
147
129
148
(* * Record host memory properties in database *)
Original file line number Diff line number Diff line change @@ -47,10 +47,19 @@ case "${OP}" in
47
47
service iptables save
48
48
fi
49
49
;;
50
+ check)
51
+ if [[ -z ` iptables -S $CHAIN | grep " $PORT " ` ]]
52
+ then
53
+ echo " Port $PORT open: true"
54
+ else
55
+ echo " Port $PORT open: false"
56
+ fi
57
+ ;;
50
58
* )
51
- echo $" Usage: $0 {open|close} {port} {protocol}" 1>&2
59
+ echo $" Usage: $0 {open|close|check } {port} {protocol}" 1>&2
52
60
exit 1
53
61
;;
54
62
esac
63
+
55
64
exit 0
56
65
You can’t perform that action at this time.
0 commit comments