Support segment overlay-id

Change-Id: If873748ccced944efd62e4b7ed5753c864b662b8
This commit is contained in:
asarfaty 2021-01-06 08:11:35 +02:00
parent d1afc77e58
commit 70d2a55400
5 changed files with 13 additions and 3 deletions

View File

@ -3869,7 +3869,7 @@ class TestPolicySegment(NsxPolicyLibTestCase):
self.resourceApi = self.policy_lib.segment
def _test_create(self, tier1_id=None, tier0_id=None, mdproxy=None,
dhcp_server=None, admin_state=None):
dhcp_server=None, admin_state=None, overlay_id=None):
name = 'test'
description = 'desc'
subnets = [core_defs.Subnet(gateway_address="2.2.2.0/24")]
@ -3890,6 +3890,8 @@ class TestPolicySegment(NsxPolicyLibTestCase):
kwargs['dhcp_server_config_id'] = dhcp_server
if admin_state:
kwargs['admin_state'] = admin_state
if overlay_id:
kwargs['overlay_id'] = overlay_id
with mock.patch.object(self.policy_api,
"create_or_update") as api_call:
@ -3929,6 +3931,9 @@ class TestPolicySegment(NsxPolicyLibTestCase):
def test_create_with_admin_state_down(self):
self._test_create(admin_state=False)
def test_create_with_overlay_id(self):
self._test_create(overlay_id=100)
def test_delete(self):
segment_id = '111'
with mock.patch.object(self.policy_api, "delete") as api_call:

View File

@ -150,6 +150,7 @@ NSX_VERSION_2_4_0 = '2.4.0'
NSX_VERSION_2_5_0 = '2.5.0'
NSX_VERSION_3_0_0 = '3.0.0'
NSX_VERSION_3_1_0 = '3.1.0'
NSX_VERSION_3_2_0 = '3.2.0'
# Features available depending on the NSX Manager backend version
FEATURE_MAC_LEARNING = 'MAC Learning'

View File

@ -929,7 +929,8 @@ class SegmentDef(BaseSegmentDef):
def version_dependant_attr_map(self):
return {'metadata_proxy_id': nsx_constants.NSX_VERSION_3_0_0,
'dhcp_server_config_id': nsx_constants.NSX_VERSION_3_0_0,
'admin_state': nsx_constants.NSX_VERSION_3_0_0}
'admin_state': nsx_constants.NSX_VERSION_3_0_0,
'overlay_id': nsx_constants.NSX_VERSION_3_1_0}
def get_obj_dict(self):
body = super(SegmentDef, self).get_obj_dict()
@ -1001,6 +1002,7 @@ class SegmentDef(BaseSegmentDef):
self._set_attr_if_specified(body, 'admin_state',
value=admin_state)
self._set_attr_if_supported(body, 'overlay_id')
return body

View File

@ -1953,6 +1953,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
metadata_proxy_id=IGNORE,
dhcp_server_config_id=IGNORE,
admin_state=IGNORE,
overlay_id=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
@ -1976,6 +1977,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
metadata_proxy_id=metadata_proxy_id,
dhcp_server_config_id=dhcp_server_config_id,
admin_state=admin_state,
overlay_id=overlay_id,
tags=tags,
tenant=tenant)
self._create_or_store(segment_def)

View File

@ -107,7 +107,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
if cert['pem_encoded'] == cert_pem]
if not cert_ids:
raise nsxlib_exc.ResourceNotFound(
manager=self.client.nsx_api_managers,
manager=getattr(self.client, 'nsx_api_managers'),
operation="find_certificate")
identities = self.get_identities(name)