Add ip_release_delay when creating IpPool

When creating IpPool, ip_release_delay can be set
to indicate the delay for releasing allocated IP address from IP pool.
Default is 2mins.

Change-Id: I56e9edd09df34f7909a7ce47339ae903f518fbda
This commit is contained in:
lxiaopei 2023-02-24 15:24:46 +08:00
parent 0d922467e8
commit d049dbc406
3 changed files with 10 additions and 0 deletions

View File

@ -4897,17 +4897,20 @@ class TestPolicyIpPool(NsxPolicyLibTestCase):
name = 'test'
description = 'desc'
ip_pool_id = '111'
ip_release_delay = 10
with mock.patch.object(self.policy_api,
"create_or_update") as api_call:
result = self.resourceApi.create_or_overwrite(
name, ip_pool_id, description=description,
ip_release_delay=ip_release_delay,
tenant=TEST_TENANT)
expected_def = core_defs.IpPoolDef(
ip_pool_id=ip_pool_id,
name=name,
description=description,
ip_release_delay=ip_release_delay,
tenant=TEST_TENANT)
self.assert_called_with_def(api_call, expected_def)

View File

@ -1522,6 +1522,11 @@ class IpPoolDef(ResourceDef):
def path_defs(self):
return (TenantDef,)
def get_obj_dict(self):
body = super(IpPoolDef, self).get_obj_dict()
self._set_attr_if_specified(body, 'ip_release_delay')
return body
class IpPoolAllocationDef(ResourceDef):
'''Infra IpPoolAllocation'''

View File

@ -3350,6 +3350,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
ip_pool_id=None,
description=IGNORE,
tags=IGNORE,
ip_release_delay=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
ip_pool_id = self._init_obj_uuid(ip_pool_id)
@ -3357,6 +3358,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
name=name,
description=description,
tags=tags,
ip_release_delay=ip_release_delay,
tenant=tenant)
self._create_or_store(ip_pool_def)
return ip_pool_id