Add support for cinder-backup subordinate

This commit is contained in:
Edward Hope-Morley 2015-06-01 23:43:04 +01:00
parent 15f52309b9
commit 171ac119a0
8 changed files with 46 additions and 5 deletions

View File

@ -0,0 +1 @@
cinder_hooks.py

View File

@ -0,0 +1 @@
cinder_hooks.py

View File

@ -0,0 +1 @@
cinder_hooks.py

View File

@ -0,0 +1 @@
cinder_hooks.py

View File

@ -3,12 +3,15 @@ from charmhelpers.core.hookenv import (
relation_ids,
service_name,
related_units,
relation_get
relation_get,
log,
DEBUG,
)
from charmhelpers.contrib.openstack.context import (
OSContextGenerator,
ApacheSSLContext as SSLContext,
SubordinateConfigContext as BaseSubordinateConfigContext,
)
from charmhelpers.contrib.openstack.utils import (
@ -20,6 +23,9 @@ from charmhelpers.contrib.hahelpers.cluster import (
determine_api_port,
)
CINDER_CONF_DIR = "/etc/cinder"
CINDER_CONF = '%s/cinder.conf' % CINDER_CONF_DIR
class ImageServiceContext(OSContextGenerator):
interfaces = ['image-service']
@ -106,6 +112,26 @@ class StorageBackendContext(OSContextGenerator):
return {}
class SubordinateConfigContext(OSContextGenerator):
def __call__(self):
cls = BaseSubordinateConfigContext
ctxt1 = cls(interface='storage-backend',
service='cinder',
config_file=CINDER_CONF)()
ctxt2 = cls(interface='backup-backend',
service='cinder',
config_file=CINDER_CONF)()
for key in ctxt2:
if key not in ctxt1:
ctxt1[key] = ctxt2[key]
ctxt1[key] += ctxt2[key]
else:
ctxt1[key].update(ctxt2[key])
return ctxt1
class LoggingConfigContext(OSContextGenerator):
def __call__(self):

View File

@ -140,6 +140,10 @@ def config_changed():
for rid in relation_ids('storage-backend'):
relation_set(relation_id=rid,
upgrade_nonce=uuid.uuid4())
# NOTE(hopem) tell any backup-backends we just upgraded
for rid in relation_ids('backup-backend'):
relation_set(relation_id=rid,
upgrade_nonce=uuid.uuid4())
CONFIGS.write_all()
configure_https()
@ -500,6 +504,13 @@ def storage_backend():
CONFIGS.write(CINDER_CONF)
@hooks.hook('backup-backend-relation-changed')
@hooks.hook('backup-backend-relation-broken')
@restart_on_change(restart_map())
def backup_backend():
CONFIGS.write(CINDER_CONF)
@hooks.hook('nrpe-external-master-relation-joined',
'nrpe-external-master-relation-changed')
def update_nrpe_config():

View File

@ -161,10 +161,7 @@ CONFIG_FILES = OrderedDict([
cinder_contexts.CephContext(),
cinder_contexts.HAProxyContext(),
cinder_contexts.ImageServiceContext(),
context.SubordinateConfigContext(
interface='storage-backend',
service='cinder',
config_file=CINDER_CONF),
cinder_contexts.SubordinateConfigContext(),
cinder_contexts.StorageBackendContext(),
cinder_contexts.LoggingConfigContext(),
context.IdentityServiceContext(

View File

@ -30,6 +30,9 @@ requires:
storage-backend:
interface: cinder-backend
scope: container
backup-backend:
interface: cinder-backup
scope: container
peers:
cluster:
interface: cinder-ha