summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-14 17:56:21 +0000
committerGerrit Code Review <review@openstack.org>2017-06-14 17:56:21 +0000
commit977f5217bad5ba0074ce45ff60b5960b894e1e1b (patch)
tree986f6709260c6961f09cc08baf764ee0ffa2d88c
parente27ec5a03b20022a66c994c0ee89ef7023cc5c29 (diff)
parent1bb9cdd47d0055e38bc09ee0b2baa096ef6ba3b6 (diff)
Merge "Change name of HA redundancy router automatically"
-rw-r--r--networking_cisco/plugins/cisco/db/l3/ha_db.py14
-rw-r--r--networking_cisco/tests/unit/cisco/l3/test_ha_l3_router_appliance_plugin.py18
2 files changed, 30 insertions, 2 deletions
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):
406 router_requested) 406 router_requested)
407 # pick up updates to other attributes where it makes sense 407 # pick up updates to other attributes where it makes sense
408 # and push - right now it is only admin_state_up. 408 # and push - right now it is only admin_state_up.
409 other_updates_spec = {'router': {}}
409 if 'admin_state_up' in update_specification['router']: 410 if 'admin_state_up' in update_specification['router']:
410 other_updates_spec = {'router': {'admin_state_up': 411 other_updates_spec['router']['admin_state_up'] = (
411 update_specification['router']['admin_state_up']}} 412 update_specification['router']['admin_state_up'])
413 if 'name' in update_specification['router']:
414 other_updates_spec['router']['name'] = (
415 update_specification['router']['name'])
416 if other_updates_spec['router']:
412 self._process_other_router_updates(e_context, updated_router_db, 417 self._process_other_router_updates(e_context, updated_router_db,
413 other_updates_spec) 418 other_updates_spec)
414 # Ensure we get latest state from DB 419 # Ensure we get latest state from DB
@@ -444,7 +449,12 @@ class HA_db_mixin(object):
444 449
445 def _process_other_router_updates(self, context, router_db, update_spec): 450 def _process_other_router_updates(self, context, router_db, update_spec):
446 rr_ids = [] 451 rr_ids = []
452 new_name_stub = update_spec['router'].get('name')
447 for r_b_db in router_db.redundancy_bindings: 453 for r_b_db in router_db.redundancy_bindings:
454 if new_name_stub is not None:
455 idx = r_b_db.redundancy_router.name.split('_')[-1]
456 update_spec['router']['name'] = (
457 new_name_stub + REDUNDANCY_ROUTER_SUFFIX + idx)
448 update_spec['router'][ha.ENABLED] = False 458 update_spec['router'][ha.ENABLED] = False
449 self._update_router_no_notify( 459 self._update_router_no_notify(
450 context, r_b_db.redundancy_router_id, update_spec) 460 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(
1464 self._rr_routes_update_cleanup(p2['id'], None, r['id'], rr1_id, []) 1464 self._rr_routes_update_cleanup(p2['id'], None, r['id'], rr1_id, [])
1465 self._routes_update_cleanup(p1['id'], None, r['id'], []) 1465 self._routes_update_cleanup(p1['id'], None, r['id'], [])
1466 1466
1467 def test_router_update_change_name_changes_redundancy_routers(self):
1468 with self.router() as router:
1469 r = router['router']
1470 newName = 'routerOne'
1471 params = "&".join(["id=%s" % rr['id'] for rr in
1472 r[ha.DETAILS][ha.REDUNDANCY_ROUTERS]])
1473 r_routers = self._list('routers', query_params=params)['routers']
1474 rr_name_start = 'router1' + ha_db.REDUNDANCY_ROUTER_SUFFIX
1475 for rr in r_routers:
1476 self.assertTrue(rr['name'].startswith(rr_name_start))
1477 r_updated = self._update('routers', r['id'],
1478 {'router': {'name': newName}})['router']
1479 self.assertEqual(newName, r_updated['name'])
1480 rr_name_start = newName + ha_db.REDUNDANCY_ROUTER_SUFFIX
1481 r_routers = self._list('routers', query_params=params)['routers']
1482 for rr in r_routers:
1483 self.assertTrue(rr['name'].startswith(rr_name_start))
1484
1467 def test__notify_subnetpool_address_scope_update(self): 1485 def test__notify_subnetpool_address_scope_update(self):
1468 l3_plugin = bc.get_plugin(bc.constants.L3) 1486 l3_plugin = bc.get_plugin(bc.constants.L3)
1469 1487