NSX: Fix status sync with correct mappings
The code that syncs router status to the neutron_db was using the nsx router id instead of the neutron router id thus synchronize_router would never update the database. Also, the switch synchronization routine was not fetching the appropriate neutron id tag thus causing switch synchronization to be skipped. This patch also fixes the error in the unit tests which allowed for the bug to be introduced. Co-Authored-By: Salvatore Orlando <salv.orlando@gmail.com> Closes-bug: 1283856 Change-Id: I26342ecea6ad546b224b7fca1e55f754b4883363
This commit is contained in:
parent
9c54044152
commit
b52884a692
|
@ -300,7 +300,7 @@ class NvpSynchronizer():
|
|||
lswitch = (self._nvp_cache[ls_uuid].get('data') or
|
||||
self._nvp_cache[ls_uuid].get('data_bk'))
|
||||
tags = self._get_tag_dict(lswitch['tags'])
|
||||
neutron_id = tags.get('neutron_net_id', ls_uuid)
|
||||
neutron_id = tags.get('quantum_net_id')
|
||||
neutron_net_ids.add(neutron_id)
|
||||
neutron_nvp_mappings[neutron_id] = (
|
||||
neutron_nvp_mappings.get(neutron_id, []) +
|
||||
|
@ -309,7 +309,6 @@ class NvpSynchronizer():
|
|||
filters = {'router:external': [False]}
|
||||
if not scan_missing:
|
||||
filters['id'] = neutron_net_ids
|
||||
# TODO(salv-orlando): Filter out external networks
|
||||
networks = self._plugin._get_collection_query(
|
||||
ctx, models_v2.Network, filters=filters)
|
||||
for network in networks:
|
||||
|
@ -356,8 +355,20 @@ class NvpSynchronizer():
|
|||
def _synchronize_lrouters(self, ctx, lr_uuids, scan_missing=False):
|
||||
if not lr_uuids and not scan_missing:
|
||||
return
|
||||
neutron_router_mappings = (
|
||||
dict((lr_uuid, self._nvp_cache[lr_uuid]) for lr_uuid in lr_uuids))
|
||||
# TODO(salvatore-orlando): Deal with the case the tag
|
||||
# has been tampered with
|
||||
neutron_router_mappings = {}
|
||||
for lr_uuid in lr_uuids:
|
||||
lrouter = (self._nvp_cache[lr_uuid].get('data') or
|
||||
self._nvp_cache[lr_uuid].get('data_bk'))
|
||||
tags = self._get_tag_dict(lrouter['tags'])
|
||||
neutron_router_id = tags.get('q_router_id')
|
||||
if neutron_router_id:
|
||||
neutron_router_mappings[neutron_router_id] = (
|
||||
self._nvp_cache[lr_uuid])
|
||||
else:
|
||||
LOG.warn(_("Unable to find Neutron router id for "
|
||||
"NSX logical router: %s"), lr_uuid)
|
||||
# Fetch neutron routers from database
|
||||
filters = ({} if scan_missing else
|
||||
{'id': neutron_router_mappings.keys()})
|
||||
|
|
|
@ -428,9 +428,12 @@ class NvpSyncTestCase(base.BaseTestCase):
|
|||
with self._populate_data(ctx):
|
||||
sp = sync.SyncParameters(100)
|
||||
self._plugin._synchronizer._synchronize_state(sp)
|
||||
# Ensure the synchronizer performs a resync
|
||||
sp.init_sync_performed = True
|
||||
self._test_sync(
|
||||
constants.NET_STATUS_DOWN, constants.PORT_STATUS_DOWN,
|
||||
constants.NET_STATUS_DOWN, self._action_callback_status_down)
|
||||
constants.NET_STATUS_DOWN, self._action_callback_status_down,
|
||||
sp=sp)
|
||||
|
||||
def _action_callback_del_resource(self, ls_uuid, lp_uuid, lr_uuid):
|
||||
del self.fc._fake_lswitch_dict[ls_uuid]
|
||||
|
@ -449,9 +452,12 @@ class NvpSyncTestCase(base.BaseTestCase):
|
|||
with self._populate_data(ctx):
|
||||
sp = sync.SyncParameters(100)
|
||||
self._plugin._synchronizer._synchronize_state(sp)
|
||||
# Ensure the synchronizer performs a resync
|
||||
sp.init_sync_performed = True
|
||||
self._test_sync(
|
||||
constants.NET_STATUS_ERROR, constants.PORT_STATUS_ERROR,
|
||||
constants.NET_STATUS_ERROR, self._action_callback_del_resource)
|
||||
constants.NET_STATUS_ERROR, self._action_callback_del_resource,
|
||||
sp=sp)
|
||||
|
||||
def _test_sync_with_chunk_larger_maxpagesize(
|
||||
self, net_size, port_size, router_size, chunk_size, exp_calls):
|
||||
|
|
Loading…
Reference in New Issue