magpie #46

Supports: trusty xenial bionic eoan focal
Add to new model

Description

Magpie will check ICMP, DNS, MTU and rx/tx speed between itself and any
peer units deployed - deploy more than one magpie unit for meaningful results.


Leadership Layer for Juju Charms

The Leadership layer is for charm-tools and 'charm build', making it
easier for layered charms to deal with Juju leadership.

This layer will initialize charms.reactive states, allowing you to
write handlers that will be activated by these states. It allows you
to completely avoid writing leader-elected and leader-settings-changed
hooks. As a simple example, these two handlers are all that is required
to make the leader unit generate a password if it is not already set,
and have the shared password stored in a file on all units:

import charms.leadership
from charmhelpers.core.host import pwgen


@when('leadership.is_leader')
@when_not('leadership.set.admin_password')
def generate_secret():
    charms.leadership.leader_set(admin_password=pwgen())


@when('leadership.changed.admin_password')
def store_secret():
    write_file('/etc/foopass', leader_get('admin_password'))

States

The following states are set appropriately on startup, before any @hook
decorated methods are invoked:

  • leadership.is_leader

This state is set when the unit is the leader. The unit will remain
the leader for the remainder of the hook, but may not be leader in
future hooks.

  • leadership.set.{varname}

This state is set for each leadership setting (ie. the
leadership.set.foo state will be set if the leader has set
the foo leadership setting to any value). It will remain
set for the remainder of the hook, unless the unit is the leader
and calls reactive.leadership.leader_set() and resets the value
to None.

  • leadership.changed.{varname}

This state is set for each leadership setting that has changed
since the last hook. It will remain set for the remainder of the
hook. It will not be set in the next hook, unless the leader has
changed the leadership setting yet again.

  • leadership.changed

One or more leadership settings has changed since the last hook.
This state will remain set for the remainder of the hook. It will
not be set in the next hook, unless the leader has made further
changes.

Methods

The charms.leadership module exposes the leader_set() and
leader_get() methods, which match the methods found in the
charmhelpers.core.hookenv module. reactive.leadership.leader_set()
should be used instead of the charmhelpers function to ensure that
the reactive state is updated when the leadership settings are. If you
do not do this, then you risk handlers waiting on these states to not
be run on the leader (because when the leader changes settings, it
triggers leader-settings-changed hooks on the follower units but
no hooks on itself).

Support

This layer is maintained on Launchpad by
Stuart Bishop (stuart.bishop@canonical.com).

Code is available using git at git+ssh://git.launchpad.net/layer-leadership.

Bug reports can be made at https://bugs.launchpad.net/layer-leadership.

Queries and comments can be made on the Juju mailing list, Juju IRC
channels, or at https://answers.launchpad.net/layer-leadership.


Configuration

check_bonds
(string) Comma separated list of expected bonds
check_dns
(boolean) Check if peers are resolveble
True
check_iperf
(boolean) Execute iperf network performance test
True
check_local_hostname
(boolean) Check if local hostname is resolvable
True
check_port_description
(boolean) Check LLDP port description to match hostname
dns_server
(string) Use unit default DNS server
dns_time
(int) Timeout in seconds per DNS query try
3
dns_tries
(int) Number of DNS resolution attempts per query
1
min_speed
(int) Minimum transfer speed in mbit/s required to pass the test. 0 disables.
ping_timeout
(int) Timeout in seconds per ICMP request
2
ping_tries
(int) Number of ICMP packets per ping
1
required_mtu
(int) Desired MTU for all nodes - block if the unit MTU is different (accounting for encapsulation). 0 disables.
source
(string) Repository to add to unit before installing any dependencies. May be one of the following: distro (default) ppa:somecustom/ppa (PPA name must include UCA OpenStack Release name) deb url sources entry|key id or a supported Ubuntu Cloud Archive pocket.
distro
supress_status
(boolean) Enable this if you intend to consume this layer - supresses status messages
use_lldp
(boolean) Enable LLDP agent and collect data