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.
|
for this, and cache the results.
|
||||||
"""
|
"""
|
||||||
if lswitch_id not in NET_NSX_2_NEUTRON_ID_CACHE:
|
if lswitch_id not in NET_NSX_2_NEUTRON_ID_CACHE:
|
||||||
# Go to the nsx using passthrough api to get the neutron id
|
segments_path = self.nsxpolicy.search_resource_by_realized_id(
|
||||||
if not cfg.CONF.nsx_p.allow_passthrough:
|
lswitch_id, "RealizedLogicalSwitch")
|
||||||
LOG.warning("Cannot get neutron id for ls %s without "
|
if not segments_path or len(segments_path) != 1:
|
||||||
"passthrough api", lswitch_id)
|
LOG.warning("Could not find policy segment with realized id "
|
||||||
|
"%s", lswitch_id)
|
||||||
return []
|
return []
|
||||||
ls = self.nsxlib.logical_switch.get(lswitch_id)
|
neutron_id = p_utils.path_to_id(segments_path[0])
|
||||||
neutron_id = None
|
|
||||||
for tag in ls.get('tags', []):
|
|
||||||
if tag['scope'] == 'os-neutron-net-id':
|
|
||||||
neutron_id = tag['tag']
|
|
||||||
break
|
|
||||||
if neutron_id:
|
if neutron_id:
|
||||||
# Cache the result
|
# Cache the result
|
||||||
NET_NSX_2_NEUTRON_ID_CACHE[lswitch_id] = neutron_id
|
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']]))
|
set([s1['subnet']['id'], s2['subnet']['id']]))
|
||||||
lswitch_id = 'dummy'
|
lswitch_id = 'dummy'
|
||||||
neutron_id = n1['network']['id']
|
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
|
# Get only the subnets associated with a particular advanced
|
||||||
# service provider (i.e. logical switch).
|
# service provider (i.e. logical switch).
|
||||||
with mock.patch('vmware_nsxlib.v3.core_resources.'
|
with mock.patch('vmware_nsxlib.v3.policy.NsxPolicyLib.'
|
||||||
'NsxLibLogicalSwitch.get',
|
'search_resource_by_realized_id',
|
||||||
return_value={'tags': [nsx_tag]}):
|
return_value=[segment_path]):
|
||||||
subnets = self._list('subnets', query_params='%s=%s' %
|
subnets = self._list('subnets', query_params='%s=%s' %
|
||||||
(as_providers.ADV_SERVICE_PROVIDERS,
|
(as_providers.ADV_SERVICE_PROVIDERS,
|
||||||
lswitch_id))['subnets']
|
lswitch_id))['subnets']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user