Retry all delete calles on StaleRevision exception
Change-Id: Iab0e785a8075c26585bd7b34f445119deb403b44
This commit is contained in:
parent
4a08155c3e
commit
cccb3c87c7
@ -71,7 +71,7 @@ class NsxLibPortMirror(utils.NsxLibApiBase):
|
||||
:param mirror_session_id: string representing the UUID of the port
|
||||
mirror session to be deleted.
|
||||
"""
|
||||
self.client.delete(self.get_path(mirror_session_id))
|
||||
self._delete_with_retry(mirror_session_id)
|
||||
|
||||
|
||||
class NsxLibBridgeEndpointProfile(utils.NsxLibApiBase):
|
||||
@ -126,7 +126,7 @@ class NsxLibBridgeEndpointProfile(utils.NsxLibApiBase):
|
||||
the bridge endpoint profile to be
|
||||
deleted.
|
||||
"""
|
||||
self.client.delete(self.get_path(bridge_endpoint_profile_id))
|
||||
self._delete_with_retry(bridge_endpoint_profile_id)
|
||||
|
||||
|
||||
class NsxLibBridgeEndpoint(utils.NsxLibApiBase):
|
||||
@ -165,7 +165,7 @@ class NsxLibBridgeEndpoint(utils.NsxLibApiBase):
|
||||
:param bridge_endpoint_id: string representing the UUID of the bridge
|
||||
endpoint to be deleted.
|
||||
"""
|
||||
self.client.delete(self.get_path(bridge_endpoint_id))
|
||||
self._delete_with_retry(bridge_endpoint_id)
|
||||
|
||||
|
||||
class NsxLibLogicalSwitch(utils.NsxLibApiBase):
|
||||
@ -556,7 +556,7 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
|
||||
if utils.dict_match(kwargs, res):
|
||||
LOG.debug("Deleting %s from resource %s", res, resource)
|
||||
delete_resource = resource + "/" + str(res['id'])
|
||||
self.client.delete(delete_resource)
|
||||
self._delete_by_path_with_retry(delete_resource)
|
||||
matched_num = matched_num + 1
|
||||
if matched_num == 0:
|
||||
if skip_not_found:
|
||||
@ -647,9 +647,9 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
|
||||
return self.client.create(resource, body)
|
||||
|
||||
def delete_static_route(self, logical_router_id, static_route_id):
|
||||
resource = 'logical-routers/%s/routing/static-routes/%s' % (
|
||||
path = 'logical-routers/%s/routing/static-routes/%s' % (
|
||||
logical_router_id, static_route_id)
|
||||
self.client.delete(resource)
|
||||
self._delete_by_path_with_retry(path)
|
||||
|
||||
def delete_static_route_by_values(self, logical_router_id,
|
||||
dest_cidr=None, nexthop=None):
|
||||
@ -663,9 +663,9 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
|
||||
return self._delete_resource_by_values(resource, **kwargs)
|
||||
|
||||
def delete_nat_rule(self, logical_router_id, nat_rule_id):
|
||||
resource = 'logical-routers/%s/nat/rules/%s' % (logical_router_id,
|
||||
path = 'logical-routers/%s/nat/rules/%s' % (logical_router_id,
|
||||
nat_rule_id)
|
||||
self.client.delete(resource)
|
||||
self._delete_by_path_with_retry(path)
|
||||
|
||||
def delete_nat_rule_by_values(self, logical_router_id,
|
||||
strict_mode=True,
|
||||
@ -790,7 +790,7 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
|
||||
url = lrouter_id
|
||||
if force:
|
||||
url += '?force=%s' % force
|
||||
return self.client.delete(self.get_path(url))
|
||||
return self._delete_by_path_with_retry(self.get_path(url))
|
||||
|
||||
def update(self, lrouter_id, *args, **kwargs):
|
||||
body = {}
|
||||
@ -1017,7 +1017,7 @@ class NsxLibIpBlockSubnet(utils.NsxLibApiBase):
|
||||
|
||||
def delete(self, subnet_id):
|
||||
"""Delete a IP block subnet on the backend."""
|
||||
self.client.delete(self.get_path(subnet_id))
|
||||
self._delete_with_retry(subnet_id)
|
||||
|
||||
def list(self, ip_block_id):
|
||||
resource = '%s?block_id=%s' % (self.get_path(), ip_block_id)
|
||||
|
@ -153,7 +153,7 @@ class LoadBalancerBase(utils.NsxLibApiBase):
|
||||
|
||||
def delete(self, object_id):
|
||||
object_url = self.resource + '/' + object_id
|
||||
return self.client.delete(object_url)
|
||||
return self._delete_by_path_with_retry(object_url)
|
||||
|
||||
|
||||
class ApplicationProfile(LoadBalancerBase):
|
||||
|
@ -372,6 +372,16 @@ class NsxPolicyResourceBase(object):
|
||||
|
||||
_do_create_with_retry()
|
||||
|
||||
def _delete_with_retry(self, policy_def):
|
||||
|
||||
@utils.retry_upon_exception(
|
||||
exceptions.StaleRevision,
|
||||
max_attempts=self.policy_api.client.max_attempts)
|
||||
def do_delete():
|
||||
self.policy_api.delete(policy_def)
|
||||
|
||||
do_delete()
|
||||
|
||||
|
||||
class NsxPolicyDomainApi(NsxPolicyResourceBase):
|
||||
"""NSX Policy Domain."""
|
||||
@ -395,7 +405,7 @@ class NsxPolicyDomainApi(NsxPolicyResourceBase):
|
||||
|
||||
def delete(self, domain_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
domain_def = core_defs.DomainDef(domain_id=domain_id, tenant=tenant)
|
||||
self.policy_api.delete(domain_def)
|
||||
self._delete_with_retry(domain_def)
|
||||
|
||||
def get(self, domain_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -518,7 +528,7 @@ class NsxPolicyGroupApi(NsxPolicyResourceBase):
|
||||
group_def = core_defs.GroupDef(domain_id=domain_id,
|
||||
group_id=group_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(group_def)
|
||||
self._delete_with_retry(group_def)
|
||||
|
||||
def get(self, domain_id, group_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -635,7 +645,7 @@ class NsxPolicyServiceBase(NsxPolicyResourceBase):
|
||||
"""Delete the service with all its entries"""
|
||||
service_def = core_defs.ServiceDef(service_id=service_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(service_def)
|
||||
self._delete_with_retry(service_def)
|
||||
|
||||
def get(self, service_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -965,7 +975,7 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase):
|
||||
|
||||
def delete(self, tier1_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
tier1_def = self.entry_def(tier1_id=tier1_id, tenant=tenant)
|
||||
self.policy_api.delete(tier1_def)
|
||||
self._delete_with_retry(tier1_def)
|
||||
|
||||
def get(self, tier1_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -1116,7 +1126,7 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase):
|
||||
tier1_id=tier1_id,
|
||||
service_id=self._locale_service_id(tier1_id),
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(t1service_def)
|
||||
self._delete_with_retry(t1service_def)
|
||||
|
||||
def set_edge_cluster_path(self, tier1_id, edge_cluster_path,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -1172,7 +1182,7 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase):
|
||||
service_id=self._locale_service_id(tier1_id),
|
||||
interface_id=interface_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(t1interface_def)
|
||||
self._delete_with_retry(t1interface_def)
|
||||
|
||||
def get_realized_state(self, tier1_id, entity_type=None,
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
@ -1327,7 +1337,7 @@ class NsxPolicyTier0Api(NsxPolicyResourceBase):
|
||||
|
||||
def delete(self, tier0_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
tier0_def = self.entry_def(tier0_id=tier0_id, tenant=tenant)
|
||||
self.policy_api.delete(tier0_def)
|
||||
self._delete_with_retry(tier0_def)
|
||||
|
||||
def get(self, tier0_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -1517,7 +1527,7 @@ class NsxPolicyTier0NatRuleApi(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
nat_rule_def = self.entry_def(tier0_id=tier0_id, nat_id=nat_id,
|
||||
nat_rule_id=nat_rule_id, tenant=tenant)
|
||||
self.policy_api.delete(nat_rule_def)
|
||||
self._delete_with_retry(nat_rule_def)
|
||||
|
||||
def get(self, tier0_id, nat_rule_id, nat_id=DEFAULT_NAT_ID,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -1683,7 +1693,7 @@ class NsxPolicyTier1StaticRouteApi(NsxPolicyResourceBase):
|
||||
static_route_def = self.entry_def(tier1_id=tier1_id,
|
||||
static_route_id=static_route_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(static_route_def)
|
||||
self._delete_with_retry(static_route_def)
|
||||
|
||||
def get(self, tier1_id, static_route_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -1757,7 +1767,7 @@ class NsxPolicyTier1SegmentApi(NsxPolicyResourceBase):
|
||||
segment_def = self.entry_def(tier1_id=tier1_id,
|
||||
segment_id=segment_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(segment_def)
|
||||
self._delete_with_retry(segment_def)
|
||||
|
||||
def get(self, tier1_id, segment_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -1851,7 +1861,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
|
||||
delay=self.nsxlib_config.realization_wait_sec,
|
||||
max_attempts=self.nsxlib_config.realization_max_attempts)
|
||||
def do_delete():
|
||||
self.policy_api.delete(segment_def)
|
||||
self._delete_with_retry(segment_def)
|
||||
|
||||
do_delete()
|
||||
|
||||
@ -2030,7 +2040,7 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(port_def)
|
||||
self._delete_with_retry(port_def)
|
||||
|
||||
def get(self, segment_id, port_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
@ -2158,7 +2168,7 @@ class SegmentPortProfilesBindingMapBaseApi(NsxPolicyResourceBase):
|
||||
port_id=port_id,
|
||||
map_id=map_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(map_def)
|
||||
self._delete_with_retry(map_def)
|
||||
|
||||
def get(self, segment_id, port_id, map_id=DEFAULT_MAP_ID,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -2369,7 +2379,7 @@ class NsxPolicyTier1SegmentPortApi(NsxPolicyResourceBase):
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(port_def)
|
||||
self._delete_with_retry(port_def)
|
||||
|
||||
def get(self, tier1_id, segment_id, port_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
@ -2556,7 +2566,7 @@ class SegmentDhcpStaticBindingConfigApi(NsxPolicyResourceBase):
|
||||
binding_def = self.entry_def(segment_id=segment_id,
|
||||
binding_id=binding_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(binding_def)
|
||||
self._delete_with_retry(binding_def)
|
||||
|
||||
def get(self, segment_id, binding_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT,
|
||||
@ -2601,7 +2611,7 @@ class NsxPolicyIpBlockApi(NsxPolicyResourceBase):
|
||||
def delete(self, ip_block_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
ip_block_def = self.entry_def(ip_block_id=ip_block_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(ip_block_def)
|
||||
self._delete_with_retry(ip_block_def)
|
||||
|
||||
def get(self, ip_block_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -2648,7 +2658,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||
def delete(self, ip_pool_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
ip_pool_def = self.entry_def(ip_pool_id=ip_pool_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(ip_pool_def)
|
||||
self._delete_with_retry(ip_pool_def)
|
||||
|
||||
def get(self, ip_pool_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
ip_pool_def = self.entry_def(ip_pool_id=ip_pool_id,
|
||||
@ -2693,7 +2703,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||
ip_allocation_id=ip_allocation_id,
|
||||
ip_pool_id=ip_pool_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(ip_allocation_def)
|
||||
self._delete_with_retry(ip_allocation_def)
|
||||
|
||||
def list_allocations(self, ip_pool_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -2735,7 +2745,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||
ip_subnet_id=ip_subnet_id,
|
||||
ip_pool_id=ip_pool_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(ip_subnet_def)
|
||||
self._delete_with_retry(ip_subnet_def)
|
||||
|
||||
def list_block_subnets(self, ip_pool_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -2797,7 +2807,7 @@ class NsxPolicyIpPoolApi(NsxPolicyResourceBase):
|
||||
ip_subnet_id=ip_subnet_id,
|
||||
ip_pool_id=ip_pool_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(ip_subnet_def)
|
||||
self._delete_with_retry(ip_subnet_def)
|
||||
|
||||
def list_static_subnets(self, ip_pool_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -3098,7 +3108,7 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
|
||||
domain_id=domain_id,
|
||||
map_id=map_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(map_def)
|
||||
self._delete_with_retry(map_def)
|
||||
|
||||
def delete_entry(self, domain_id, map_id, entry_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -3107,7 +3117,7 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
|
||||
map_id=map_id,
|
||||
entry_id=entry_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(entry_def)
|
||||
self._delete_with_retry(entry_def)
|
||||
|
||||
def get(self, domain_id, map_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -3396,7 +3406,7 @@ class NsxPolicyEnforcementPointApi(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
ep_def = core_defs.EnforcementPointDef(
|
||||
ep_id=ep_id, tenant=tenant)
|
||||
self.policy_api.delete(ep_def)
|
||||
self._delete_with_retry(ep_def)
|
||||
|
||||
def get(self, ep_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -3647,7 +3657,7 @@ class NsxPolicyDeploymentMapApi(NsxPolicyResourceBase):
|
||||
|
||||
map_def = core_defs.DeploymentMapDef(
|
||||
map_id=map_id, domain_id=domain_id, tenant=tenant)
|
||||
self.policy_api.delete(map_def)
|
||||
self._delete_with_retry(map_def)
|
||||
|
||||
def get(self, map_id, domain_id=None,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
@ -3702,7 +3712,7 @@ class NsxSegmentProfileBaseApi(NsxPolicyResourceBase):
|
||||
def delete(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(profile_def)
|
||||
self._delete_with_retry(profile_def)
|
||||
|
||||
def get(self, profile_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -3935,7 +3945,7 @@ class NsxIpv6NdraProfileApi(NsxPolicyResourceBase):
|
||||
def delete(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(profile_def)
|
||||
self._delete_with_retry(profile_def)
|
||||
|
||||
def get(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
@ -3989,7 +3999,7 @@ class NsxDhcpRelayConfigApi(NsxPolicyResourceBase):
|
||||
|
||||
def delete(self, config_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
config_def = self.entry_def(config_id=config_id, tenant=tenant)
|
||||
self.policy_api.delete(config_def)
|
||||
self._delete_with_retry(config_def)
|
||||
|
||||
def get(self, config_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -4042,7 +4052,7 @@ class NsxDhcpServerConfigApi(NsxPolicyResourceBase):
|
||||
|
||||
def delete(self, config_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
config_def = self.entry_def(config_id=config_id, tenant=tenant)
|
||||
self.policy_api.delete(config_def)
|
||||
self._delete_with_retry(config_def)
|
||||
|
||||
def get(self, config_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -4101,7 +4111,7 @@ class NsxPolicyCertApi(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
certificate_def = self.entry_def(certificate_id=certificate_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(certificate_def)
|
||||
self._delete_with_retry(certificate_def)
|
||||
|
||||
def get(self, certificate_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
|
@ -58,7 +58,7 @@ class NsxIpsecVpnIkeProfileApi(core_resources.NsxPolicyResourceBase):
|
||||
def delete(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(profile_def)
|
||||
self._delete_with_retry(profile_def)
|
||||
|
||||
def get(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
@ -123,7 +123,7 @@ class NsxIpsecVpnTunnelProfileApi(core_resources.NsxPolicyResourceBase):
|
||||
def delete(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(profile_def)
|
||||
self._delete_with_retry(profile_def)
|
||||
|
||||
def get(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
@ -184,7 +184,7 @@ class NsxIpsecVpnDpdProfileApi(core_resources.NsxPolicyResourceBase):
|
||||
def delete(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(profile_def)
|
||||
self._delete_with_retry(profile_def)
|
||||
|
||||
def get(self, profile_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
profile_def = self.entry_def(profile_id=profile_id,
|
||||
@ -249,7 +249,7 @@ class NsxIpsecVpnServiceApi(core_resources.NsxPolicyResourceBase):
|
||||
service_id=self._locale_service_id(tier1_id),
|
||||
vpn_service_id=vpn_service_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(service_def)
|
||||
self._delete_with_retry(service_def)
|
||||
|
||||
def get(self, tier1_id, vpn_service_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -334,7 +334,7 @@ class NsxIpsecVpnLocalEndpointApi(core_resources.NsxPolicyResourceBase):
|
||||
vpn_service_id=vpn_service_id,
|
||||
endpoint_id=endpoint_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(endpoint_def)
|
||||
self._delete_with_retry(endpoint_def)
|
||||
|
||||
def get(self, tier1_id, vpn_service_id, endpoint_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -441,7 +441,7 @@ class NsxIpsecVpnSessionApi(core_resources.NsxPolicyResourceBase):
|
||||
vpn_service_id=vpn_service_id,
|
||||
session_id=session_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(session_def)
|
||||
self._delete_with_retry(session_def)
|
||||
|
||||
def get(self, tier1_id, vpn_service_id, session_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
|
@ -77,7 +77,7 @@ class NsxPolicyLBAppProfileBase(NsxPolicyResourceBase):
|
||||
lb_app_profile_def = self.entry_def(
|
||||
lb_app_profile_id=lb_app_profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(lb_app_profile_def)
|
||||
self._delete_with_retry(lb_app_profile_def)
|
||||
|
||||
def get(self, lb_app_profile_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -184,7 +184,7 @@ class NsxPolicyLoadBalancerClientSSLProfileApi(NsxPolicyResourceBase):
|
||||
lb_client_ssl_profile_def = self.entry_def(
|
||||
client_ssl_profile_id=client_ssl_profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(lb_client_ssl_profile_def)
|
||||
self._delete_with_retry(lb_client_ssl_profile_def)
|
||||
|
||||
def get(self, client_ssl_profile_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -244,7 +244,7 @@ class NsxPolicyLoadBalancerPersistenceProfileApi(
|
||||
persistence_profile_def = self.entry_def(
|
||||
persistence_profile_id=persistence_profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(persistence_profile_def)
|
||||
self._delete_with_retry(persistence_profile_def)
|
||||
|
||||
def get(self, persistence_profile_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -436,7 +436,7 @@ class NsxPolicyLoadBalancerPoolApi(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
lb_pool_def = self.entry_def(
|
||||
lb_pool_id=lb_pool_id, tenant=tenant)
|
||||
self.policy_api.delete(lb_pool_def)
|
||||
self._delete_with_retry(lb_pool_def)
|
||||
|
||||
def get(self, lb_pool_id, tenant=constants.POLICY_INFRA_TENANT,
|
||||
silent=False):
|
||||
@ -588,7 +588,7 @@ class NsxPolicyLoadBalancerServiceApi(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
lb_service_def = self.entry_def(
|
||||
lb_service_id=lb_service_id, tenant=tenant)
|
||||
self.policy_api.delete(lb_service_def)
|
||||
self._delete_with_retry(lb_service_def)
|
||||
|
||||
def get(self, lb_service_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
lb_service_def = self.entry_def(
|
||||
@ -709,7 +709,7 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
lbvs_def = self.entry_def(
|
||||
virtual_server_id=virtual_server_id, tenant=tenant)
|
||||
self.policy_api.delete(lbvs_def)
|
||||
self._delete_with_retry(lbvs_def)
|
||||
|
||||
def get(self, virtual_server_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
@ -933,7 +933,7 @@ class NsxPolicyLBMonitorProfileBase(NsxPolicyResourceBase):
|
||||
lb_monitor_profile_def = self.entry_def(
|
||||
lb_monitor_profile_id=lb_monitor_profile_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(lb_monitor_profile_def)
|
||||
self._delete_with_retry(lb_monitor_profile_def)
|
||||
|
||||
def get(self, lb_monitor_profile_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
|
@ -559,7 +559,7 @@ class IpPool(utils.NsxLibApiBase):
|
||||
url = pool_id
|
||||
if force:
|
||||
url += '?force=%s' % force
|
||||
return self.client.delete(self.get_path(url))
|
||||
return self._delete_by_path_with_retry(self.get_path(url))
|
||||
|
||||
def _update_param_in_pool(self, args_dict, key, pool_data):
|
||||
# update the arg only if it exists in the args dictionary
|
||||
|
@ -244,7 +244,7 @@ class NsxLibNsGroup(utils.NsxLibApiBase):
|
||||
|
||||
def delete(self, nsgroup_id):
|
||||
try:
|
||||
return self.client.delete(
|
||||
return self._delete_by_path_with_retry(
|
||||
'%s?force=true' % self.get_path(nsgroup_id))
|
||||
# FIXME(roeyc): Should only except NotFound error.
|
||||
except Exception:
|
||||
|
@ -61,7 +61,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
|
||||
|
||||
def delete_cert(self, cert_id):
|
||||
resource = CERT_SECTION + '/' + cert_id
|
||||
self.client.delete(resource)
|
||||
self._delete_by_path_with_retry(resource)
|
||||
|
||||
def find_cert_with_pem(self, cert_pem):
|
||||
# Find certificate with cert_pem
|
||||
@ -89,7 +89,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
|
||||
|
||||
def delete_identity(self, identity_id):
|
||||
resource = ID_SECTION + '/' + identity_id
|
||||
self.client.delete(resource)
|
||||
self._delete_by_path_with_retry(resource)
|
||||
|
||||
def find_cert_and_identity(self, name, cert_pem):
|
||||
certs = self.get_certs()
|
||||
|
@ -304,6 +304,8 @@ class NsxLibApiBase(object):
|
||||
self.nsxlib = nsxlib
|
||||
super(NsxLibApiBase, self).__init__()
|
||||
self.cache = NsxLibCache(self.cache_timeout)
|
||||
self.max_attempts = (self.client.max_attempts
|
||||
if hasattr(self.client, 'max_attempts') else 1)
|
||||
|
||||
@abc.abstractproperty
|
||||
def uri_segment(self):
|
||||
@ -353,7 +355,7 @@ class NsxLibApiBase(object):
|
||||
def delete(self, uuid):
|
||||
if self.use_cache_for_get:
|
||||
self.cache.remove(uuid)
|
||||
return self.client.delete(self.get_path(uuid))
|
||||
return self._delete_with_retry(uuid)
|
||||
|
||||
def find_by_display_name(self, display_name):
|
||||
found = []
|
||||
@ -414,9 +416,8 @@ class NsxLibApiBase(object):
|
||||
# NSX has, we will get a 412: Precondition Failed.
|
||||
# In that case we need to re-fetch, patch the response and send
|
||||
# it again with the new revision_id
|
||||
@retry_upon_exception(
|
||||
nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.client.max_attempts)
|
||||
@retry_upon_exception(nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.max_attempts)
|
||||
def do_update():
|
||||
return self._internal_update_resource(
|
||||
resource, payload,
|
||||
@ -437,20 +438,21 @@ class NsxLibApiBase(object):
|
||||
update_payload_cbk=update_payload_cbk)
|
||||
|
||||
def _delete_with_retry(self, resource):
|
||||
self._delete_by_path_with_retry(self.get_path(resource))
|
||||
|
||||
def _delete_by_path_with_retry(self, path):
|
||||
# Using internal method so we can access max_attempts in the decorator
|
||||
@retry_upon_exception(
|
||||
nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.client.max_attempts)
|
||||
@retry_upon_exception(nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.max_attempts)
|
||||
def _do_delete():
|
||||
self.client.delete(self.get_path(resource))
|
||||
self.client.delete(path)
|
||||
|
||||
_do_delete()
|
||||
|
||||
def _create_with_retry(self, resource, body=None, headers=None):
|
||||
# Using internal method so we can access max_attempts in the decorator
|
||||
@retry_upon_exception(
|
||||
nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.client.max_attempts)
|
||||
@retry_upon_exception(nsxlib_exceptions.StaleRevision,
|
||||
max_attempts=self.max_attempts)
|
||||
def _do_create():
|
||||
return self.client.create(resource, body, headers=headers)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user