Merge "NSX|P: Use policy search for getting neutron net id"
This commit is contained in:
commit
59dbb0dc0c
@ -3001,17 +3001,13 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||
for this, and cache the results.
|
||||
"""
|
||||
if lswitch_id not in NET_NSX_2_NEUTRON_ID_CACHE:
|
||||
# Go to the nsx using passthrough api to get the neutron id
|
||||
if not cfg.CONF.nsx_p.allow_passthrough:
|
||||
LOG.warning("Cannot get neutron id for ls %s without "
|
||||
"passthrough api", lswitch_id)
|
||||
segments_path = self.nsxpolicy.search_resource_by_realized_id(
|
||||
lswitch_id, "RealizedLogicalSwitch")
|
||||
if not segments_path or len(segments_path) != 1:
|
||||
LOG.warning("Could not find policy segment with realized id "
|
||||
"%s", lswitch_id)
|
||||
return []
|
||||
ls = self.nsxlib.logical_switch.get(lswitch_id)
|
||||
neutron_id = None
|
||||
for tag in ls.get('tags', []):
|
||||
if tag['scope'] == 'os-neutron-net-id':
|
||||
neutron_id = tag['tag']
|
||||
break
|
||||
neutron_id = p_utils.path_to_id(segments_path[0])
|
||||
if neutron_id:
|
||||
# Cache the result
|
||||
NET_NSX_2_NEUTRON_ID_CACHE[lswitch_id] = neutron_id
|
||||
|
@ -972,12 +972,12 @@ class NsxNativeMetadataTestCase(test_plugin.NsxPPluginTestCaseMixin):
|
||||
set([s1['subnet']['id'], s2['subnet']['id']]))
|
||||
lswitch_id = 'dummy'
|
||||
neutron_id = n1['network']['id']
|
||||
nsx_tag = {'tag': neutron_id, 'scope': 'os-neutron-net-id'}
|
||||
segment_path = '/infra/segments/%s' % neutron_id
|
||||
# Get only the subnets associated with a particular advanced
|
||||
# service provider (i.e. logical switch).
|
||||
with mock.patch('vmware_nsxlib.v3.core_resources.'
|
||||
'NsxLibLogicalSwitch.get',
|
||||
return_value={'tags': [nsx_tag]}):
|
||||
with mock.patch('vmware_nsxlib.v3.policy.NsxPolicyLib.'
|
||||
'search_resource_by_realized_id',
|
||||
return_value=[segment_path]):
|
||||
subnets = self._list('subnets', query_params='%s=%s' %
|
||||
(as_providers.ADV_SERVICE_PROVIDERS,
|
||||
lswitch_id))['subnets']
|
||||
|
Loading…
Reference in New Issue
Block a user