Add sync_realization while creating ip-pool/ip-subnet for nsx-keeper
Change-Id: I3b797c7130a7deb858a21c2d63580e91211a665f
This commit is contained in:
parent
44ac0a020a
commit
b0c97de660
|
@ -5005,6 +5005,34 @@ class TestPolicyIpPool(NsxPolicyLibTestCase):
|
||||||
start_ip=start_ip)
|
start_ip=start_ip)
|
||||||
self.assert_called_with_def(api_call, expected_def)
|
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):
|
def test_allocate_block_subnet_with_unsupported_attribute(self):
|
||||||
ip_pool_id = '111'
|
ip_pool_id = '111'
|
||||||
ip_block_id = 'block-id'
|
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_3_2_1 = '3.2.1'
|
||||||
NSX_VERSION_4_0_0 = '4.0.0'
|
NSX_VERSION_4_0_0 = '4.0.0'
|
||||||
NSX_VERSION_4_1_0 = '4.1.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
|
# Features available depending on the NSX Manager backend version
|
||||||
FEATURE_MAC_LEARNING = 'MAC Learning'
|
FEATURE_MAC_LEARNING = 'MAC Learning'
|
||||||
|
|
|
@ -1522,6 +1522,15 @@ class IpPoolDef(ResourceDef):
|
||||||
def path_defs(self):
|
def path_defs(self):
|
||||||
return (TenantDef,)
|
return (TenantDef,)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version_dependant_attr_map(self):
|
||||||
|
return {'sync_realization': nsx_constants.NSX_VERSION_4_1_1}
|
||||||
|
|
||||||
|
def get_obj_dict(self):
|
||||||
|
body = super(IpPoolDef, self).get_obj_dict()
|
||||||
|
self._set_attr_if_supported(body, 'sync_realization')
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
class IpPoolAllocationDef(ResourceDef):
|
class IpPoolAllocationDef(ResourceDef):
|
||||||
'''Infra IpPoolAllocation'''
|
'''Infra IpPoolAllocation'''
|
||||||
|
@ -1590,6 +1599,8 @@ class IpPoolBlockSubnetDef(IpPoolSubnetDef):
|
||||||
# Attrs supported from NSX 4.1.0
|
# Attrs supported from NSX 4.1.0
|
||||||
self._set_attrs_if_supported(body, ['subnet_size',
|
self._set_attrs_if_supported(body, ['subnet_size',
|
||||||
'allocation_range'])
|
'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
|
# Attribute "subnet size" is replacement for "size" attribute
|
||||||
# thus, removing redundancy
|
# thus, removing redundancy
|
||||||
if 'subnet_size' in body:
|
if 'subnet_size' in body:
|
||||||
|
@ -1598,9 +1609,11 @@ class IpPoolBlockSubnetDef(IpPoolSubnetDef):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version_dependant_attr_map(self):
|
def version_dependant_attr_map(self):
|
||||||
return {'start_ip': nsx_constants.NSX_VERSION_3_0_0,
|
return {
|
||||||
'subnet_size': nsx_constants.NSX_VERSION_4_1_0,
|
'start_ip': nsx_constants.NSX_VERSION_3_0_0,
|
||||||
'allocation_range': nsx_constants.NSX_VERSION_4_1_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):
|
class IpPoolStaticSubnetDef(IpPoolSubnetDef):
|
||||||
|
|
|
@ -3346,14 +3346,18 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||||
ip_pool_id=None,
|
ip_pool_id=None,
|
||||||
description=IGNORE,
|
description=IGNORE,
|
||||||
tags=IGNORE,
|
tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT):
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
|
sync_realization=False):
|
||||||
|
|
||||||
ip_pool_id = self._init_obj_uuid(ip_pool_id)
|
ip_pool_id = self._init_obj_uuid(ip_pool_id)
|
||||||
|
|
||||||
ip_pool_def = self._init_def(ip_pool_id=ip_pool_id,
|
ip_pool_def = self._init_def(ip_pool_id=ip_pool_id,
|
||||||
name=name,
|
name=name,
|
||||||
description=description,
|
description=description,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
tenant=tenant)
|
tenant=tenant,
|
||||||
|
sync_realization=sync_realization)
|
||||||
|
|
||||||
self._create_or_store(ip_pool_def)
|
self._create_or_store(ip_pool_def)
|
||||||
return ip_pool_id
|
return ip_pool_id
|
||||||
|
|
||||||
|
@ -3428,8 +3432,11 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||||
name=IGNORE, description=IGNORE, tags=IGNORE,
|
name=IGNORE, description=IGNORE, tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT,
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
start_ip=IGNORE, v6_allocation_range=IGNORE,
|
start_ip=IGNORE, v6_allocation_range=IGNORE,
|
||||||
force=False):
|
force=False, sync_realization=False):
|
||||||
ip_subnet_id = self._init_obj_uuid(ip_subnet_id)
|
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(
|
args = self._get_user_args(
|
||||||
ip_pool_id=ip_pool_id,
|
ip_pool_id=ip_pool_id,
|
||||||
ip_block_id=ip_block_id,
|
ip_block_id=ip_block_id,
|
||||||
|
@ -3442,7 +3449,8 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||||
tenant=tenant,
|
tenant=tenant,
|
||||||
start_ip=start_ip,
|
start_ip=start_ip,
|
||||||
subnet_size=str(size),
|
subnet_size=str(size),
|
||||||
allocation_range=v6_allocation_range)
|
allocation_range=v6_allocation_range,
|
||||||
|
sync_realization=sync_realization)
|
||||||
|
|
||||||
ip_subnet_def = core_defs.IpPoolBlockSubnetDef(
|
ip_subnet_def = core_defs.IpPoolBlockSubnetDef(
|
||||||
nsx_version=self.version, **args)
|
nsx_version=self.version, **args)
|
||||||
|
|
Loading…
Reference in New Issue