Expose allocation pool to router creation
Recently, platform exposes new API to create LR with allocation profile so that user can specify allocation pool for LoadBalancer. Also update the feature support util since this feature is only available on version 2.3 and after. This feature can be enabled based on nsx version. e.g. Create LR with LB SMALL allocation pool allocation_pool = { "allocation_pool_type": "LoadBalancerAllocationPool", "allocation_size": "SMALL"} create(..., allocation_pool=allocation_pool) Change-Id: I55cd17a81b3ff6705345b170d15f26fc9a5b0f74
This commit is contained in:
parent
a49a9dc94a
commit
6982eed2b4
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user