[hopem, r=gnuoy]

Add support for cinder-backup subordinate
This commit is contained in:
Liam Young 2015-10-08 15:28:50 +01:00
commit e99d382d7f
9 changed files with 35 additions and 15 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

@ -159,6 +159,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())
# overwrite config is not in conf file. so We can't use restart_on_change
if config_value_changed('overwrite'):
@ -523,6 +527,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

@ -185,7 +185,7 @@ CONFIG_FILES = OrderedDict([
cinder_contexts.HAProxyContext(),
cinder_contexts.ImageServiceContext(),
cinder_contexts.CinderSubordinateConfigContext(
interface='storage-backend',
interface=['storage-backend', 'backup-backend'],
service='cinder',
config_file=CINDER_CONF),
cinder_contexts.StorageBackendContext(),
@ -195,7 +195,7 @@ CONFIG_FILES = OrderedDict([
service_user='cinder'),
context.BindHostContext(),
context.WorkerConfigContext()],
'services': ['cinder-api', 'cinder-volume',
'services': ['cinder-api', 'cinder-volume', 'cinder-backup',
'cinder-scheduler', 'haproxy']
}),
(CINDER_API_CONF, {
@ -204,7 +204,7 @@ CONFIG_FILES = OrderedDict([
}),
(ceph_config_file(), {
'hook_contexts': [context.CephContext()],
'services': ['cinder-volume']
'services': ['cinder-volume', 'cinder-backup']
}),
(HAPROXY_CONF, {
'hook_contexts': [context.HAProxyContext(singlenode_mode=True),

View File

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

View File

@ -1,18 +1,18 @@
{% if sections and 'DEFAULT' in sections -%}
{% for key, value in sections['DEFAULT'] -%}
{{ key }} = {{ value }}
{% endfor -%}
{% endif -%}
{% endfor %}
{%- endif %}
{% if backends -%}
enabled_backends = {{ backends }}
{% endif -%}
{%- endif %}
{% for section in sections -%}
{% if section != 'DEFAULT' -%}
[{{ section }}]
{% for key, value in sections[section] -%}
{{ key }} = {{ value }}
{% endfor -%}
{% endif -%}
{% endfor -%}
{% endfor %}
{% endif %}
{%- endfor %}

View File

@ -151,16 +151,18 @@ class TestCinderUtils(CharmTestCase):
def test_services(self):
self.assertEquals(cinder_utils.services(),
['haproxy', 'apache2', 'cinder-api',
'cinder-volume', 'cinder-scheduler'])
['haproxy', 'cinder-backup', 'cinder-api',
'cinder-volume', 'apache2', 'cinder-scheduler'])
def test_creates_restart_map_all_enabled(self):
'It creates correct restart map when all services enabled'
ex_map = OrderedDict([
('/etc/cinder/cinder.conf', ['cinder-api', 'cinder-volume',
'cinder-scheduler', 'haproxy']),
'cinder-backup', 'cinder-scheduler',
'haproxy']),
('/etc/cinder/api-paste.ini', ['cinder-api']),
('/var/lib/charm/cinder/ceph.conf', ['cinder-volume']),
('/var/lib/charm/cinder/ceph.conf', ['cinder-volume',
'cinder-backup']),
('/etc/haproxy/haproxy.cfg', ['haproxy']),
('/etc/apache2/sites-available/openstack_https_frontend',
['apache2']),
@ -723,8 +725,8 @@ class TestCinderUtils(CharmTestCase):
]
self.assertEquals(render.call_args_list, expected)
expected = [
call('tgtd'), call('haproxy'), call('apache2'),
call('cinder-api'), call('cinder-volume'),
call('tgtd'), call('haproxy'), call('cinder-backup'),
call('cinder-api'), call('cinder-volume'), call('apache2'),
call('cinder-scheduler'),
]
self.assertEquals(service_restart.call_args_list, expected)