From 54308ced90b687a28c597d4fbff82d60c1410051 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Wed, 6 Jan 2021 08:11:35 +0200 Subject: [PATCH] Support segment overlay-id Change-Id: If873748ccced944efd62e4b7ed5753c864b662b8 --- vmware_nsxlib/tests/unit/v3/policy/test_resources.py | 7 ++++++- vmware_nsxlib/v3/nsx_constants.py | 1 + vmware_nsxlib/v3/policy/core_defs.py | 5 +++-- vmware_nsxlib/v3/policy/core_resources.py | 2 ++ vmware_nsxlib/v3/trust_management.py | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index e3943508..4f4b454d 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -4246,7 +4246,7 @@ class TestPolicySegment(NsxPolicyLibTestCase): def _test_create(self, tier1_id=None, tier0_id=None, mdproxy=None, dhcp_server=None, admin_state=None, ip_pool_id='external-ip-pool', ls_id=None, - unique_id=None, tz_id=None, ep_id=None): + unique_id=None, tz_id=None, ep_id=None, overlay_id=None): name = 'test' description = 'desc' subnets = [core_defs.Subnet(gateway_address="2.2.2.0/24")] @@ -4267,6 +4267,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 if ls_id: kwargs['ls_id'] = ls_id @@ -4340,6 +4342,9 @@ class TestPolicySegment(NsxPolicyLibTestCase): def test_create_with_transport_zone_id_and_default_ep(self): self._test_create(tz_id='tz_id1') + 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: diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index 925add7b..c67c194d 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -153,6 +153,7 @@ NSX_VERSION_2_5_0 = '2.5.0' NSX_VERSION_3_0_0 = '3.0.0' NSX_VERSION_3_0_2 = '3.0.2' 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' diff --git a/vmware_nsxlib/v3/policy/core_defs.py b/vmware_nsxlib/v3/policy/core_defs.py index dfaca1a9..2d710823 100644 --- a/vmware_nsxlib/v3/policy/core_defs.py +++ b/vmware_nsxlib/v3/policy/core_defs.py @@ -984,7 +984,8 @@ class SegmentDef(BaseSegmentDef): 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, - 'unique_id': nsx_constants.NSX_VERSION_3_1_0} + 'unique_id': nsx_constants.NSX_VERSION_3_1_0, + 'overlay_id': nsx_constants.NSX_VERSION_3_1_0} def get_obj_dict(self): body = super(SegmentDef, self).get_obj_dict() @@ -1058,7 +1059,7 @@ class SegmentDef(BaseSegmentDef): value=admin_state) self._set_attr_if_supported(body, 'unique_id') - + self._set_attr_if_supported(body, 'overlay_id') return body diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index 672219e2..fa211416 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -2072,6 +2072,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): ls_id=IGNORE, unique_id=IGNORE, ep_id=IGNORE, + overlay_id=IGNORE, tags=IGNORE, tenant=constants.POLICY_INFRA_TENANT): @@ -2098,6 +2099,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): ls_id=ls_id, unique_id=unique_id, ep_id=ep_id, + overlay_id=overlay_id, tags=tags, tenant=tenant) self._create_or_store(segment_def) diff --git a/vmware_nsxlib/v3/trust_management.py b/vmware_nsxlib/v3/trust_management.py index 6d232bdf..024c4db9 100644 --- a/vmware_nsxlib/v3/trust_management.py +++ b/vmware_nsxlib/v3/trust_management.py @@ -105,7 +105,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)