From 349c4c39991f6b30593a9cb958e1927104e6eb9a Mon Sep 17 00:00:00 2001 From: Gautam Verma Date: Thu, 22 Dec 2022 22:03:04 +0530 Subject: [PATCH] Allow using force option to create and release IPBlockSubnets Change-Id: I95cd3b5ada9fc4a612bec83ca759258ed1029f81 --- vmware_nsxlib/v3/policy/core_resources.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index fc3dd6a7..ac43e5cc 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -3422,7 +3422,8 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): ip_subnet_id=None, auto_assign_gateway=IGNORE, name=IGNORE, description=IGNORE, tags=IGNORE, tenant=constants.POLICY_INFRA_TENANT, - start_ip=IGNORE, v6_allocation_range=IGNORE): + start_ip=IGNORE, v6_allocation_range=IGNORE, + force=False): ip_subnet_id = self._init_obj_uuid(ip_subnet_id) args = self._get_user_args( ip_pool_id=ip_pool_id, @@ -3440,15 +3441,16 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): ip_subnet_def = core_defs.IpPoolBlockSubnetDef( nsx_version=self.version, **args) - self._create_or_store(ip_subnet_def) + self._create_or_store(ip_subnet_def, force=force) def release_block_subnet(self, ip_pool_id, ip_subnet_id, - tenant=constants.POLICY_INFRA_TENANT): + tenant=constants.POLICY_INFRA_TENANT, + force=False): ip_subnet_def = core_defs.IpPoolBlockSubnetDef( ip_subnet_id=ip_subnet_id, ip_pool_id=ip_pool_id, tenant=tenant) - self._delete_with_retry(ip_subnet_def) + self._delete_with_retry(ip_subnet_def, force=force) def list_block_subnets(self, ip_pool_id, tenant=constants.POLICY_INFRA_TENANT): @@ -3489,7 +3491,8 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): allocation_ranges, ip_subnet_id=None, name=IGNORE, description=IGNORE, gateway_ip=IGNORE, tags=IGNORE, - tenant=constants.POLICY_INFRA_TENANT): + tenant=constants.POLICY_INFRA_TENANT, + force=False): ip_subnet_id = self._init_obj_uuid(ip_subnet_id) args = self._get_user_args( ip_pool_id=ip_pool_id, @@ -3502,15 +3505,16 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase): tenant=tenant) ip_subnet_def = core_defs.IpPoolStaticSubnetDef(**args) - self._create_or_store(ip_subnet_def) + self._create_or_store(ip_subnet_def, force=force) def release_static_subnet(self, ip_pool_id, ip_subnet_id, - tenant=constants.POLICY_INFRA_TENANT): + tenant=constants.POLICY_INFRA_TENANT, + force=False): ip_subnet_def = core_defs.IpPoolStaticSubnetDef( ip_subnet_id=ip_subnet_id, ip_pool_id=ip_pool_id, tenant=tenant) - self._delete_with_retry(ip_subnet_def) + self._delete_with_retry(ip_subnet_def, force=force) def list_static_subnets(self, ip_pool_id, tenant=constants.POLICY_INFRA_TENANT):