Allow nova-c-c to trigger service restart post-db migration.
This commit is contained in:
commit
80f6a915c1
@ -273,6 +273,14 @@ class CloudComputeContext(context.OSContextGenerator):
|
||||
self.network_manager)
|
||||
return ctxt
|
||||
|
||||
def restart_trigger(self):
|
||||
rt = None
|
||||
for rid in relation_ids('cloud-compute'):
|
||||
for unit in related_units(rid):
|
||||
rt = relation_get('restart_trigger', rid=rid, unit=unit)
|
||||
if rt:
|
||||
return rt
|
||||
|
||||
def __call__(self):
|
||||
rids = relation_ids('cloud-compute')
|
||||
if not rids:
|
||||
@ -289,6 +297,9 @@ class CloudComputeContext(context.OSContextGenerator):
|
||||
if vol_service:
|
||||
ctxt['volume_service'] = vol_service
|
||||
|
||||
if self.restart_trigger():
|
||||
ctxt['restart_trigger'] = self.restart_trigger()
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
{% if restart_trigger -%}
|
||||
# restart trigger: {{ restart_trigger }}
|
||||
{% endif -%}
|
||||
###############################################################################
|
||||
--dhcpbridge_flagfile=/etc/nova/nova.conf
|
||||
--dhcpbridge=/usr/bin/nova-dhcpbridge
|
||||
|
@ -2,6 +2,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
{% if restart_trigger -%}
|
||||
# restart trigger: {{ restart_trigger }}
|
||||
{% endif -%}
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
dhcpbridge_flagfile=/etc/nova/nova.conf
|
||||
|
@ -2,6 +2,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
{% if restart_trigger -%}
|
||||
# restart trigger: {{ restart_trigger }}
|
||||
{% endif -%}
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
dhcpbridge_flagfile=/etc/nova/nova.conf
|
||||
|
@ -2,6 +2,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
{% if restart_trigger -%}
|
||||
# restart trigger: {{ restart_trigger }}
|
||||
{% endif -%}
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
dhcpbridge_flagfile=/etc/nova/nova.conf
|
||||
|
@ -66,6 +66,20 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
cloud_compute = context.CloudComputeContext()
|
||||
self.assertEquals({}, cloud_compute())
|
||||
|
||||
@patch.object(context, '_network_manager')
|
||||
def test_cloud_compute_context_restart_trigger(self, nm):
|
||||
nm.return_value = None
|
||||
cloud_compute = context.CloudComputeContext()
|
||||
with patch.object(cloud_compute, 'restart_trigger') as rt:
|
||||
rt.return_value = 'footrigger'
|
||||
ctxt = cloud_compute()
|
||||
self.assertEquals(ctxt.get('restart_trigger'), 'footrigger')
|
||||
|
||||
with patch.object(cloud_compute, 'restart_trigger') as rt:
|
||||
rt.return_value = None
|
||||
ctxt = cloud_compute()
|
||||
self.assertEquals(ctxt.get('restart_trigger'), None)
|
||||
|
||||
@patch.object(context, '_network_manager')
|
||||
def test_cloud_compute_volume_context_cinder(self, netman):
|
||||
netman.return_value = None
|
||||
|
Loading…
Reference in New Issue
Block a user