diff --git a/networking_cisco/plugins/cisco/db/l3/ha_db.py b/networking_cisco/plugins/cisco/db/l3/ha_db.py index b91a8b4..8dcebc1 100644 --- a/networking_cisco/plugins/cisco/db/l3/ha_db.py +++ b/networking_cisco/plugins/cisco/db/l3/ha_db.py @@ -406,9 +406,14 @@ class HA_db_mixin(object): router_requested) # pick up updates to other attributes where it makes sense # and push - right now it is only admin_state_up. + other_updates_spec = {'router': {}} if 'admin_state_up' in update_specification['router']: - other_updates_spec = {'router': {'admin_state_up': - update_specification['router']['admin_state_up']}} + other_updates_spec['router']['admin_state_up'] = ( + update_specification['router']['admin_state_up']) + if 'name' in update_specification['router']: + other_updates_spec['router']['name'] = ( + update_specification['router']['name']) + if other_updates_spec['router']: self._process_other_router_updates(e_context, updated_router_db, other_updates_spec) # Ensure we get latest state from DB @@ -444,7 +449,12 @@ class HA_db_mixin(object): def _process_other_router_updates(self, context, router_db, update_spec): rr_ids = [] + new_name_stub = update_spec['router'].get('name') for r_b_db in router_db.redundancy_bindings: + if new_name_stub is not None: + idx = r_b_db.redundancy_router.name.split('_')[-1] + update_spec['router']['name'] = ( + new_name_stub + REDUNDANCY_ROUTER_SUFFIX + idx) update_spec['router'][ha.ENABLED] = False self._update_router_no_notify( context, r_b_db.redundancy_router_id, update_spec) diff --git a/networking_cisco/tests/unit/cisco/l3/test_ha_l3_router_appliance_plugin.py b/networking_cisco/tests/unit/cisco/l3/test_ha_l3_router_appliance_plugin.py index bf037ab..aa2d1d2 100644 --- a/networking_cisco/tests/unit/cisco/l3/test_ha_l3_router_appliance_plugin.py +++ b/networking_cisco/tests/unit/cisco/l3/test_ha_l3_router_appliance_plugin.py @@ -1464,6 +1464,24 @@ class HAL3RouterApplianceVMTestCase( self._rr_routes_update_cleanup(p2['id'], None, r['id'], rr1_id, []) self._routes_update_cleanup(p1['id'], None, r['id'], []) + def test_router_update_change_name_changes_redundancy_routers(self): + with self.router() as router: + r = router['router'] + newName = 'routerOne' + params = "&".join(["id=%s" % rr['id'] for rr in + r[ha.DETAILS][ha.REDUNDANCY_ROUTERS]]) + r_routers = self._list('routers', query_params=params)['routers'] + rr_name_start = 'router1' + ha_db.REDUNDANCY_ROUTER_SUFFIX + for rr in r_routers: + self.assertTrue(rr['name'].startswith(rr_name_start)) + r_updated = self._update('routers', r['id'], + {'router': {'name': newName}})['router'] + self.assertEqual(newName, r_updated['name']) + rr_name_start = newName + ha_db.REDUNDANCY_ROUTER_SUFFIX + r_routers = self._list('routers', query_params=params)['routers'] + for rr in r_routers: + self.assertTrue(rr['name'].startswith(rr_name_start)) + def test__notify_subnetpool_address_scope_update(self): l3_plugin = bc.get_plugin(bc.constants.L3)