juju-solutions / interface-etcd

1 stars 5 forks source link

Overview

This interface layer handles the communication with Etcd via the etcd interface.

Usage

Requires

This interface layer will set the following states, as appropriate:

For example, a common application for this is configuring an applications backend key/value storage, like Docker.

@when('etcd.available', 'docker.available')
def swarm_etcd_cluster_setup(etcd):
    con_string = etcd.connection_string().replace('http', 'etcd')
    opts = {}
    opts['connection_string'] = con_string
    render('docker-compose.yml', 'files/swarm/docker-compose.yml', opts)

Provides

A charm providing this interface is providing the Etcd rest api service.

This interface layer will set the following states, as appropriate:

Example:

@when('db.connected')
def send_connection_details(db):
    cert = leader_get('client_certificate')
    key = leader_get('client_key')
    ca = leader_get('certificate_authority')
    # Set the key, cert, and ca on the db relation
    db.set_client_credentials(key, cert, ca)

    port = hookenv.config().get('port')
    # Get all the peers participating in the cluster relation.
    addresses = cluster.get_peer_addresses()
    connections = []
    for address in addresses:
        connections.append('http://{0}:{1}'.format(address, port))
    # Set the connection string on the db relation.
    db.set_connection_string(','.join(conections))

Contact Information

Maintainer

Etcd