lighthouse.haproxy.control
¶lighthouse.haproxy.control.
HAProxyControl
(config_file_path, socket_file_path, pid_file_path)[source]¶Bases: object
Class used to control a running HAProxy process.
Includes basic functionality for soft restarts as well as gathering info about the HAProxy process and its active nodes, plus methods for enabling or disabling nodes on the fly.
Also allows for sending commands to the HAProxy control socket itself.
get_version
()[source]¶Returns a tuple representing the installed HAProxy version.
The value of the tuple is (<major>, <minor>, <patch>), e.g. if HAProxy
version 1.5.3 is installed, this will return (1, 5, 3)
.
get_info
()[source]¶Parses the output of a “show info” HAProxy command and returns a simple dictionary of the results.
get_active_nodes
()[source]¶Returns a dictionary of lists, where the key is the name of a service and the list includes all active nodes associated with that service.
enable_node
(service_name, node_name)[source]¶Enables a given node name for the given service name via the “enable server” HAProxy command.
disable_node
(service_name, node_name)[source]¶Disables a given node name for the given service name via the “disable server” HAProxy command.
lighthouse.haproxy.control.
HAProxyControlError
[source]¶Bases: exceptions.Exception
Base exception for HAProxyControl-related actions.
lighthouse.haproxy.control.
UnknownCommandError
[source]¶Bases: lighthouse.haproxy.control.HAProxyControlError
Exception raised if an unrecognized command was sent to the HAProxy socket.
lighthouse.haproxy.control.
PermissionError
[source]¶Bases: lighthouse.haproxy.control.HAProxyControlError
Exception denoting that the HAProxy control socket does not have proper authentication level for executing a given command.
For example, if the socket is set up with a a level lower than “admin”, the enable/disable server commands will fail.
lighthouse.haproxy.control.
UnknownServerError
[source]¶Bases: lighthouse.haproxy.control.HAProxyControlError
Exception raised if an enable/disable server command is executed against a backend that HAProxy doesn’t know about.