Use memcache for coordination

This commit is contained in:
James Page 2017-07-06 18:03:26 +01:00
parent 6154bf4d2f
commit 75335257a8
5 changed files with 30 additions and 4 deletions

View File

@ -1,4 +1,4 @@
includes: ['layer:openstack-api', 'interface:ceph-client', 'interface:gnocchi']
includes: ['layer:openstack-api', 'interface:ceph-client', 'interface:gnocchi', 'interface:memcache']
options:
basic:
use_venv: True

View File

@ -21,6 +21,7 @@ CEPH_CONF = '/etc/ceph/ceph.conf'
CEPH_POOL_NAME = 'gnocchi'
# TODO(jamespage): charms.openstack
class StorageCephRelationAdapter(adapters.OpenStackRelationAdapter):
"""
@ -36,12 +37,29 @@ class StorageCephRelationAdapter(adapters.OpenStackRelationAdapter):
to access Ceph.
"""
hosts = self.relation.mon_hosts()
if len(hosts) > 1:
if len(hosts) > 0:
return ','.join(hosts)
else:
return None
# TODO(jamespage): charms.openstack
class MemcacheRelationAdapter(adapters.OpenStackRelationAdapter):
"""
Adapter for the MemcacheRequires relation interface.
"""
interface_type = 'memcache'
@property
def url(self):
hosts = self.relation.memcache_hosts()
if hosts:
return "memcached://{}:11211?timeout=5".format(hosts[0])
return None
class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):
"""
@ -52,6 +70,7 @@ class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):
'storage_ceph': StorageCephRelationAdapter,
'shared_db': adapters.DatabaseRelationAdapter,
'cluster': adapters.PeerHARelationAdapter,
'coordinator': MemcacheRelationAdapter,
}
@ -86,7 +105,8 @@ class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
services = ['gnocchi-metricd', 'apache2']
required_relations = ['shared-db', 'identity-service', 'storage-ceph']
required_relations = ['shared-db', 'identity-service',
'storage-ceph', 'coordinator']
restart_map = {
GNOCCHI_CONF: services,

View File

@ -20,3 +20,5 @@ provides:
requires:
storage-ceph:
interface: ceph-client
coordinator:
interface: memcache

View File

@ -29,9 +29,9 @@ charm.use_defaults(
'update-status')
@reactive.when('coordinator.available')
@reactive.when('shared-db.available')
@reactive.when('identity-service.available')
@reactive.when('storage-ceph.available')
@reactive.when('storage-ceph.pools.available')
def render_config(*args):
"""Render the configuration for charm when all the interfaces are

View File

@ -17,6 +17,10 @@ url = {{ shared_db.uri }}
{%- endif %}
[storage]
{% if coordinator.url -%}
coordination_url = {{ coordinator.url }}
{%- endif %}
{% if storage_ceph.key -%}
driver = ceph
ceph_pool = gnocchi