diff --git a/vmware_nsxlib/tests/unit/v3/test_resources.py b/vmware_nsxlib/tests/unit/v3/test_resources.py index d57068ce..3b3ec69f 100644 --- a/vmware_nsxlib/tests/unit/v3/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_resources.py @@ -640,15 +640,23 @@ class LogicalRouterTestCase(BaseTestResource): tier0_router = True description = 'dummy' tz_id = 'tz_id' + allocation_pool = { + 'allocation_pool_type': 'LoadBalancerAllocationPool', + 'allocation_size': 'SMALL' + } router.create(fake_router['display_name'], None, None, tier0_router, - description=description, transport_zone_id=tz_id) + description=description, transport_zone_id=tz_id, + allocation_pool=allocation_pool) data = { 'display_name': fake_router['display_name'], 'router_type': 'TIER0' if tier0_router else 'TIER1', 'tags': None, 'description': description, - 'advanced_config': {'transport_zone_id': tz_id} + 'advanced_config': {'transport_zone_id': tz_id}, + 'allocation_profile': { + 'allocation_pool': allocation_pool + } } test_client.assert_json_call( diff --git a/vmware_nsxlib/v3/__init__.py b/vmware_nsxlib/v3/__init__.py index b98312d7..bd981e78 100644 --- a/vmware_nsxlib/v3/__init__.py +++ b/vmware_nsxlib/v3/__init__.py @@ -328,6 +328,12 @@ class NsxLib(NsxLibBase): if (feature == nsx_constants.FEATURE_ICMP_STRICT): return True + if (version.LooseVersion(self.get_version()) >= + version.LooseVersion(nsx_constants.NSX_VERSION_2_3_0)): + # Features available since 2.3 + if (feature == nsx_constants.FEATURE_ALLOCATION_POOL): + return True + if (version.LooseVersion(self.get_version()) >= version.LooseVersion(nsx_constants.NSX_VERSION_2_2_0)): # Features available since 2.2 diff --git a/vmware_nsxlib/v3/core_resources.py b/vmware_nsxlib/v3/core_resources.py index 7b42d626..2b3c762f 100644 --- a/vmware_nsxlib/v3/core_resources.py +++ b/vmware_nsxlib/v3/core_resources.py @@ -650,7 +650,7 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase): return self.client.get(resource) def create(self, display_name, tags, edge_cluster_uuid=None, tier_0=False, - description=None, transport_zone_id=None): + description=None, transport_zone_id=None, allocation_pool=None): # TODO(salv-orlando): If possible do not manage edge clusters # in the main plugin logic. router_type = (nsx_constants.ROUTER_TYPE_TIER0 if tier_0 else @@ -665,6 +665,9 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase): if transport_zone_id: body['advanced_config'] = { 'transport_zone_id': transport_zone_id} + if allocation_pool: + body['allocation_profile'] = { + 'allocation_pool': allocation_pool} return self.client.create(self.get_path(), body=body) def delete(self, lrouter_id, force=False): diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index eaa40e2f..467a3db7 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -146,3 +146,4 @@ FEATURE_ROUTER_TRANSPORT_ZONE = 'Router Transport Zone' FEATURE_NO_DNAT_NO_SNAT = 'No DNAT/No SNAT' FEATURE_ENS_WITH_SEC = 'ENS with security' FEATURE_ICMP_STRICT = 'Strict list of supported ICMP types and codes' +FEATURE_ALLOCATION_POOL = 'Router Allocation Pool'