diff --git a/hooks/backup-backend-relation-broken b/hooks/backup-backend-relation-broken new file mode 120000 index 00000000..6dcd0084 --- /dev/null +++ b/hooks/backup-backend-relation-broken @@ -0,0 +1 @@ +cinder_hooks.py \ No newline at end of file diff --git a/hooks/backup-backend-relation-changed b/hooks/backup-backend-relation-changed new file mode 120000 index 00000000..6dcd0084 --- /dev/null +++ b/hooks/backup-backend-relation-changed @@ -0,0 +1 @@ +cinder_hooks.py \ No newline at end of file diff --git a/hooks/backup-backend-relation-departed b/hooks/backup-backend-relation-departed new file mode 120000 index 00000000..6dcd0084 --- /dev/null +++ b/hooks/backup-backend-relation-departed @@ -0,0 +1 @@ +cinder_hooks.py \ No newline at end of file diff --git a/hooks/backup-backend-relation-joined b/hooks/backup-backend-relation-joined new file mode 120000 index 00000000..6dcd0084 --- /dev/null +++ b/hooks/backup-backend-relation-joined @@ -0,0 +1 @@ +cinder_hooks.py \ No newline at end of file diff --git a/hooks/cinder_contexts.py b/hooks/cinder_contexts.py index 6bd1da45..067870f8 100644 --- a/hooks/cinder_contexts.py +++ b/hooks/cinder_contexts.py @@ -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): diff --git a/hooks/cinder_hooks.py b/hooks/cinder_hooks.py index 85a3852c..c7f63ec1 100755 --- a/hooks/cinder_hooks.py +++ b/hooks/cinder_hooks.py @@ -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(): diff --git a/hooks/cinder_utils.py b/hooks/cinder_utils.py index 4550dddb..c0f67e5d 100644 --- a/hooks/cinder_utils.py +++ b/hooks/cinder_utils.py @@ -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( diff --git a/metadata.yaml b/metadata.yaml index d1223cc2..cc9c46d7 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -30,6 +30,9 @@ requires: storage-backend: interface: cinder-backend scope: container + backup-backend: + interface: cinder-backup + scope: container peers: cluster: interface: cinder-ha