charmhelpers.contrib.hahelpers package

charmhelpers.contrib.hahelpers.apache module

charmhelpers.contrib.hahelpers.apache.get_ca_cert()
charmhelpers.contrib.hahelpers.apache.get_cert(cn=None)
charmhelpers.contrib.hahelpers.apache.install_ca_cert(ca_cert)

charmhelpers.contrib.hahelpers.cluster module

Helpers for clustering and determining “cluster leadership” and other clustering-related helpers.

exception charmhelpers.contrib.hahelpers.cluster.CRMDCNotFound

Bases: exceptions.Exception

exception charmhelpers.contrib.hahelpers.cluster.CRMResourceNotFound

Bases: exceptions.Exception

exception charmhelpers.contrib.hahelpers.cluster.HAIncompleteConfig

Bases: exceptions.Exception

charmhelpers.contrib.hahelpers.cluster.canonical_url(configs, vip_setting='vip')

Returns the correct HTTP URL to this host given the state of HTTPS configuration and hacluster.

:configs : OSTemplateRenderer: A config tempating object to inspect for
a complete https context.
Vip_setting:str: Setting in charm config that specifies VIP address.
charmhelpers.contrib.hahelpers.cluster.determine_apache_port(public_port, singlenode_mode=False)

Description: Determine correct apache listening port based on public IP + state of the cluster.

public_port: int: standard public port for given service

singlenode_mode: boolean: Shuffle ports when only a single unit is present

returns: int: the correct listening port for the HAProxy service

charmhelpers.contrib.hahelpers.cluster.determine_api_port(public_port, singlenode_mode=False)

Determine correct API server listening port based on existence of HTTPS reverse proxy and/or haproxy.

public_port: int: standard public port for given service

singlenode_mode: boolean: Shuffle ports when only a single unit is present

returns: int: the correct listening port for the API service

charmhelpers.contrib.hahelpers.cluster.eligible_leader(resource)
charmhelpers.contrib.hahelpers.cluster.get_hacluster_config(exclude_keys=None)

Obtains all relevant configuration from charm configuration required for initiating a relation to hacluster:

ha-bindiface, ha-mcastport, vip

param: exclude_keys: list of setting key(s) to be excluded. returns: dict: A dict containing settings keyed by setting name. raises: HAIncompleteConfig if settings are missing.

charmhelpers.contrib.hahelpers.cluster.https()

Determines whether enough data has been provided in configuration or relation data to configure HTTPS . returns: boolean

charmhelpers.contrib.hahelpers.cluster.is_clustered()
charmhelpers.contrib.hahelpers.cluster.is_crm_dc()

Determine leadership by querying the pacemaker Designated Controller

charmhelpers.contrib.hahelpers.cluster.is_elected_leader(resource)

Returns True if the charm executing this is the elected cluster leader.

It relies on two mechanisms to determine leadership:
1. If juju is sufficiently new and leadership election is supported, the is_leader command will be used. 2. If the charm is part of a corosync cluster, call corosync to determine leadership. 3. If the charm is not part of a corosync cluster, the leader is determined as being “the alive unit with the lowest unit numer”. In other words, the oldest surviving unit.
charmhelpers.contrib.hahelpers.cluster.is_leader(resource)
charmhelpers.contrib.hahelpers.cluster.oldest_peer(peers)

Determines who the oldest peer is by comparing unit numbers.

charmhelpers.contrib.hahelpers.cluster.peer_ips(peer_relation='cluster', addr_key='private-address')

Return a dict of peers and their private-address

charmhelpers.contrib.hahelpers.cluster.peer_units(peer_relation='cluster')