From 3068bfacb66488c1e3eb944f944b66777ea0451e Mon Sep 17 00:00:00 2001 From: tathgurt Date: Thu, 13 Oct 2022 10:58:40 -0700 Subject: [PATCH] Support large IPv6 subnet via NSX IPAM New field Introduced in IPblockSubnet in order to cap the maximum Ip Subnets across different clusters. Jira: #NCP-439 Change-Id: I2e01f7e787c5be5d20256b96b19e9ce8b68edbe6 (cherry picked from commit 7b16449dabedb8524a61a372976e6792811fd026) --- vmware_nsxlib/v3/nsx_constants.py | 1 + vmware_nsxlib/v3/policy/core_defs.py | 12 +++++++++++- vmware_nsxlib/v3/policy/core_resources.py | 6 ++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index 8bacde33..fb7dbd9f 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -165,6 +165,7 @@ NSX_VERSION_3_1_0 = '3.1.0' NSX_VERSION_3_2_0 = '3.2.0' NSX_VERSION_3_2_1 = '3.2.1' NSX_VERSION_4_0_0 = '4.0.0' +NSX_VERSION_4_1_0 = '4.1.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 fd93b0db..4f37e370 100644 --- a/vmware_nsxlib/v3/policy/core_defs.py +++ b/vmware_nsxlib/v3/policy/core_defs.py @@ -1585,12 +1585,22 @@ class IpPoolBlockSubnetDef(IpPoolSubnetDef): self._set_attr_if_specified( body, 'ip_block_id', body_attr='ip_block_path', value=ip_block_path) + # Attrs supported from NSX 3.0.0 self._set_attr_if_supported(body, 'start_ip') + # Attrs supported from NSX 4.1.0 + self._set_attrs_if_supported(body, ['subnet_size', + 'allocation_range']) + # Attribute "subnet size" is replacement for "size" attribute + # thus, removing redundancy + if 'subnet_size' in body: + body.pop('size', None) return body @property def version_dependant_attr_map(self): - return {'start_ip': nsx_constants.NSX_VERSION_3_0_0} + return {'start_ip': nsx_constants.NSX_VERSION_3_0_0, + 'subnet_size': nsx_constants.NSX_VERSION_4_1_0, + 'allocation_range': nsx_constants.NSX_VERSION_4_1_0} class IpPoolStaticSubnetDef(IpPoolSubnetDef): diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index c44f7512..fc3dd6a7 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -3422,7 +3422,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): ip_subnet_id=None, auto_assign_gateway=IGNORE, name=IGNORE, description=IGNORE, tags=IGNORE, tenant=constants.POLICY_INFRA_TENANT, - start_ip=IGNORE): + start_ip=IGNORE, v6_allocation_range=IGNORE): ip_subnet_id = self._init_obj_uuid(ip_subnet_id) args = self._get_user_args( ip_pool_id=ip_pool_id, @@ -3434,7 +3434,9 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): description=description, tags=tags, tenant=tenant, - start_ip=start_ip) + start_ip=start_ip, + subnet_size=str(size), + allocation_range=v6_allocation_range) ip_subnet_def = core_defs.IpPoolBlockSubnetDef( nsx_version=self.version, **args)