Revert "Revert "Add sync_realization while creating ip-pool/ip-subnet for nsx-keeper""
This reverts commit d2836e3452
.
Reason for revert: backend support is now available
Change-Id: I835c4a99f38760e5cb834852adb4fb56b3bd234e
This commit is contained in:
parent
d049dbc406
commit
acb8f2d53f
|
@ -5008,6 +5008,34 @@ class TestPolicyIpPool(NsxPolicyLibTestCase):
|
|||
start_ip=start_ip)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
|
||||
def test_allocate_block_subnet_sync_realization(self):
|
||||
ip_pool_id = '111'
|
||||
ip_block_id = 'block-id'
|
||||
size = 256
|
||||
ip_subnet_id = 'subnet-id'
|
||||
start_ip = '192.168.1.0'
|
||||
sync_realization = True
|
||||
|
||||
with mock.patch.object(
|
||||
self.policy_api, "create_or_update") as api_call, \
|
||||
mock.patch.object(self.resourceApi, 'version',
|
||||
nsx_constants.NSX_VERSION_4_1_1):
|
||||
self.resourceApi.allocate_block_subnet(
|
||||
ip_pool_id, ip_block_id, size, ip_subnet_id,
|
||||
tenant=TEST_TENANT, start_ip=start_ip,
|
||||
sync_realization=sync_realization)
|
||||
|
||||
expected_def = core_defs.IpPoolBlockSubnetDef(
|
||||
nsx_version=nsx_constants.NSX_VERSION_4_1_1,
|
||||
ip_pool_id=ip_pool_id,
|
||||
ip_block_id=ip_block_id,
|
||||
ip_subnet_id=ip_subnet_id,
|
||||
subnet_size='%s' % size,
|
||||
tenant=TEST_TENANT,
|
||||
start_ip=start_ip,
|
||||
sync_realization=sync_realization)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
|
||||
def test_allocate_block_subnet_with_unsupported_attribute(self):
|
||||
ip_pool_id = '111'
|
||||
ip_block_id = 'block-id'
|
||||
|
|
|
@ -166,6 +166,7 @@ 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'
|
||||
NSX_VERSION_4_1_1 = '4.1.1'
|
||||
|
||||
# Features available depending on the NSX Manager backend version
|
||||
FEATURE_MAC_LEARNING = 'MAC Learning'
|
||||
|
|
|
@ -1525,8 +1525,13 @@ class IpPoolDef(ResourceDef):
|
|||
def get_obj_dict(self):
|
||||
body = super(IpPoolDef, self).get_obj_dict()
|
||||
self._set_attr_if_specified(body, 'ip_release_delay')
|
||||
self._set_attr_if_supported(body, 'sync_realization')
|
||||
return body
|
||||
|
||||
@property
|
||||
def version_dependant_attr_map(self):
|
||||
return {'sync_realization': nsx_constants.NSX_VERSION_4_1_1}
|
||||
|
||||
|
||||
class IpPoolAllocationDef(ResourceDef):
|
||||
'''Infra IpPoolAllocation'''
|
||||
|
@ -1595,6 +1600,8 @@ class IpPoolBlockSubnetDef(IpPoolSubnetDef):
|
|||
# Attrs supported from NSX 4.1.0
|
||||
self._set_attrs_if_supported(body, ['subnet_size',
|
||||
'allocation_range'])
|
||||
# Attrs supported from NSX 4.1.1
|
||||
self._set_attr_if_supported(body, 'sync_realization')
|
||||
# Attribute "subnet size" is replacement for "size" attribute
|
||||
# thus, removing redundancy
|
||||
if 'subnet_size' in body:
|
||||
|
@ -1603,9 +1610,11 @@ class IpPoolBlockSubnetDef(IpPoolSubnetDef):
|
|||
|
||||
@property
|
||||
def version_dependant_attr_map(self):
|
||||
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}
|
||||
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,
|
||||
'sync_realization': nsx_constants.NSX_VERSION_4_1_1}
|
||||
|
||||
|
||||
class IpPoolStaticSubnetDef(IpPoolSubnetDef):
|
||||
|
|
|
@ -3351,14 +3351,17 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
|||
description=IGNORE,
|
||||
tags=IGNORE,
|
||||
ip_release_delay=IGNORE,
|
||||
sync_realization=False,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
|
||||
ip_pool_id = self._init_obj_uuid(ip_pool_id)
|
||||
|
||||
ip_pool_def = self._init_def(ip_pool_id=ip_pool_id,
|
||||
name=name,
|
||||
description=description,
|
||||
tags=tags,
|
||||
ip_release_delay=ip_release_delay,
|
||||
sync_realization=sync_realization,
|
||||
tenant=tenant)
|
||||
self._create_or_store(ip_pool_def)
|
||||
return ip_pool_id
|
||||
|
@ -3434,8 +3437,11 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
|||
name=IGNORE, description=IGNORE, tags=IGNORE,
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
start_ip=IGNORE, v6_allocation_range=IGNORE,
|
||||
force=False):
|
||||
force=False, sync_realization=False):
|
||||
ip_subnet_id = self._init_obj_uuid(ip_subnet_id)
|
||||
# suppose all NSXT 4.1.0 build support sync_realization
|
||||
# else we need to check if it supports sync_realization
|
||||
# it's just a temp patch
|
||||
args = self._get_user_args(
|
||||
ip_pool_id=ip_pool_id,
|
||||
ip_block_id=ip_block_id,
|
||||
|
@ -3448,7 +3454,8 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
|||
tenant=tenant,
|
||||
start_ip=start_ip,
|
||||
subnet_size=str(size),
|
||||
allocation_range=v6_allocation_range)
|
||||
allocation_range=v6_allocation_range,
|
||||
sync_realization=sync_realization)
|
||||
|
||||
ip_subnet_def = core_defs.IpPoolBlockSubnetDef(
|
||||
nsx_version=self.version, **args)
|
||||
|
|
Loading…
Reference in New Issue