Giter Club home page Giter Club logo

interface-etcd's Introduction

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:

  • {relation_name}.connected The relation is established, but Etcd may not yet have provided any connection or service information.

  • {relation_name}.available Etcd has provided its connection string information, and is ready to serve as a KV store. The provided information can be accessed via the following methods:

    • etcd.get_connection_string()
    • etcd.get_version()
  • {relation_name}.tls.available Etcd has provided the connection string information, and the tls client credentials to communicate with it. The client credentials can be accessed via:

    • {relation_name}.get_client_credentials() returning a dictionary of the clinet certificate, key and CA.
    • {relation_name}.save_client_credentials(key, cert, ca) is a convenience method to save the client certificate, key and CA to files of your choosing.

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:

  • {relation_name}.connected One or more clients of any type have been related. The charm should call the following methods to provide the appropriate information to the clients:

    • {relation_name}.set_connection_string(string, version)
    • {relation_name}.set_client_credentials(key, cert, ca)

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

interface-etcd's People

Contributors

cynerva avatar ktsakalozos avatar lazypower avatar mbruzek avatar wwwtyro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.