Change name of HA redundancy router automatically
With this patch the initial part of the name of a HA redundancy router will be automatically updated when the name of its HA user visible router peer is updated. That way it is easier to understand for admins which user visible router a certain HA redundancy router is a peer of. AKA: DE3462 Change-Id: If83e7c3bdd6c2ddee77d102bdc93f70918befc1c Closes-Bug: #1680113
This commit is contained in:
parent
f83d6ffcfa
commit
1bb9cdd47d
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue