7587a4b6e8
Add required configuration files and generally update the interface after move to OpenStack git/gerrit. Change-Id: If80a3393d566953c3349c74e62b860b582961769 |
||
---|---|---|
.gitignore | ||
.gitreview | ||
README.md | ||
copyright | ||
interface.yaml | ||
peer.py | ||
provides.py | ||
requires.py | ||
test-requirements.txt | ||
tox.ini |
README.md
Overview
This interface layer handles the communication with MySQL via the mysql-shared
interface protocol.
Usage
Requires
The interface layer will set the following states, as appropriate:
{relation_name}.connected
The relation is established, but MySQL has not been provided the database information.{relation_name}.available
MySQL is ready for use. You can get the base connection information via the following methods:allowed_units()
database()
db_host()
hostname()
username()
password()
{relation_name}.available.access_network
MySQL access network is ready for use. You can get this optional connection information via the following method:access_network()
{relation_name}.available.ssl
MySQL ssl data is ready for use. You can get this optional connection information via the following methods:ssl_ca()
ssl_cert()
ssl_key()
For example:
from charmhelpers.core.hookenv import log, status_set, unit_get
from charms.reactive import when, when_not
@when('database.connected')
def setup_database(database):
host = unit_get('private-address')
database.configure('mydatabase', 'myusername', host, prefix="first")
database.configure('mydatabase2', 'myusername2', host, prefix="second")
@when('database.available')
def use_database(database):
# base data provided by our charm layer
log("first_database=%s" % database.database("first"))
log("first_username=%s" % database.username("first"))
log("first_hostname=%s" % database.hostname("first"))
log("second_database=%s" % database.database("second"))
log("second_username=%s" % database.username("second"))
log("second_hostname=%s" % database.hostname("second"))
# base data provided by mysql
log("db_host=%s" % database.db_host())
log("first_password=%s" % database.password("first"))
log("first_allowed_units=%s" % database.allowed_units("first"))
log("second_password=%s" % database.password("second"))
log("second_allowed_units=%s" % database.allowed_units("second"))
@when('database.available.access_network')
def use_database_access_network(database):
# optional data provided by mysql
log("access-network=%s" % database.access_network())
@when('database.available.ssl')
def use_database_ssl(database):
# optional data provided by mysql
log("ssl_ca=%s" % database.ssl_ca())
log("ssl_cert=%s" % database.ssl_cert())
log("ssl_key=%s" % database.ssl_key())
@when('database.connected')
@when_not('database.available')
def waiting_mysql(database):
status_set('waiting', 'Waiting for MySQL')
@when('database.connected', 'database.available')
def unit_ready(database):
status_set('active', 'Unit is ready')