Only run migration if allowed units is present

This commit is contained in:
Liam Young 2015-04-23 09:49:03 +01:00
parent b74d932f86
commit 52a55ec0e8
2 changed files with 6 additions and 11 deletions

View File

@ -105,11 +105,13 @@ def conditional_neutron_migration():
if is_elected_leader(CLUSTER_RES):
allowed_units = relation_get('allowed_units')
if allowed_units and local_unit() not in allowed_units.split():
log('Allowed_units list provided and this unit not present')
if allowed_units and local_unit() in allowed_units.split():
migrate_neutron_database()
service_restart('neutron-server')
else:
log('Not running neutron database migration, either no'
' allowed_units or this unit is not present')
return
migrate_neutron_database()
service_restart('neutron-server')
else:
log('Not running neutron database migration, not leader')

View File

@ -720,10 +720,3 @@ class NeutronAPIHooksTests(CharmTestCase):
'Not running neutron database migration as migrations are handled '
'by the neutron-server process or nova-cloud-controller charm.'
)
def test_conditional_neutron_migration_not_clustered(self):
self.relation_ids.return_value = ['nova-cc/o']
self.os_release.return_value = 'kilo'
hooks.conditional_neutron_migration()
self.migrate_neutron_database.assert_called_with()
self.service_restart.assert_called_with('neutron-server')