lighthouse.haproxy.config

class lighthouse.haproxy.config.HAProxyConfig(global_stanza, defaults_stanza, proxy_stanzas=None, stats_stanza=None, meta_clusters=None, bind_address=None)[source]

Bases: object

Class for generating HAProxy config file content.

Requires global and defaults stanzas to be passed, can optionally take a stats_stanza for enabling a stats portal.

generate(clusters, version=None)[source]

Generates HAProxy config file content based on a given list of clusters.

get_meta_clusters(clusters)[source]

Returns a dictionary keyed off of meta cluster names, where the values are lists of clusters associated with the meta cluster name.

If a meta cluster name doesn’t have a port defined in the meta_cluster_ports attribute an error is given and the meta cluster is removed from the mapping.