Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ocaml/xapi/dbsync_slave.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,20 @@ let refresh_localhost_info ~__context info =
~key:Xapi_globs.host_no_local_storage ~value:"true"
) else
Db.Host.remove_from_other_config ~__context ~self:host
~key:Xapi_globs.host_no_local_storage

~key:Xapi_globs.host_no_local_storage ;
let script_output =
Helpers.call_script !Xapi_globs.firewall_port_config_script ["check"; "80"]
in
try
let network_state = Scanf.sscanf script_output "Port 80 open: %B" Fun.id in
Db.Host.set_https_only ~__context ~self:host ~value:network_state
with _ ->
let message =
Printf.sprintf
"unexpected output from /etc/xapi.d/plugins/firewall-port: %s"
script_output
in
raise Api_errors.(Server_error (internal_error, [message]))
(*************** update database tools ******************)

(** Record host memory properties in database *)
Expand Down
11 changes: 10 additions & 1 deletion scripts/plugins/firewall-port
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,19 @@ case "${OP}" in
service iptables save
fi
;;
check)
if [[ -z `iptables -S $CHAIN | grep " $PORT "` ]]
then
echo "Port $PORT open: true"
else
echo "Port $PORT open: false"
fi
;;
*)
echo $"Usage: $0 {open|close} {port} {protocol}" 1>&2
echo $"Usage: $0 {open|close|check} {port} {protocol}" 1>&2
exit 1
;;
esac

exit 0