From cc28f054e65a3bbe0be3e6b279ef2971f97f2cd0 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 17 Nov 2009 20:47:28 -0500 Subject: Reload HAProxy configuration on sync'd peers --- config/haproxy/haproxy.inc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'config/haproxy') diff --git a/config/haproxy/haproxy.inc b/config/haproxy/haproxy.inc index 6c226269..652d0a63 100644 --- a/config/haproxy/haproxy.inc +++ b/config/haproxy/haproxy.inc @@ -287,4 +287,34 @@ function haproxy_do_xmlrpc_sync($sync_to_ip, $password) { } } + /* tell haproxy to reload our settings on the destionation sync host. */ + $method = 'pfsense.exec_php'; + $execcmd = "require_once('/usr/local/pkg/haproxy.inc');\n"; + $execcmd .= "haproxy_configure();\n"; + + /* assemble xmlrpc payload */ + $params = array( + XML_RPC_encode($password), + XML_RPC_encode($execcmd) + ); + + log_error("HAProxy XMLRPC reload data {$url}:{$port}."); + $msg = new XML_RPC_Message($method, $params); + $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); + $cli->setCredentials('admin', $password); + $resp = $cli->send($msg, "250"); + if(!$resp) { + $error = "A communications error occurred while attempting HAProxy XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Reload", ""); + } elseif($resp->faultCode()) { + $cli->setDebug(1); + $resp = $cli->send($msg, "250"); + $error = "An error code was received while attempting HAProxy XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Sync", ""); + } else { + log_error("HAProxy XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + } + ?> \ No newline at end of file -- cgit v1.2.3