Merge "Retry all delete calles on StaleRevision exception"

This commit is contained in:
Zuul 2020-02-20 06:09:55 +00:00 committed by Gerrit Code Review
commit 68dc449e80
9 changed files with 85 additions and 73 deletions

View File

@ -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:
@ -650,9 +650,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):
@ -666,9 +666,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,
nat_rule_id)
self.client.delete(resource)
path = 'logical-routers/%s/nat/rules/%s' % (logical_router_id,
nat_rule_id)
self._delete_by_path_with_retry(path)
def delete_nat_rule_by_values(self, logical_router_id,
strict_mode=True,
@ -801,7 +801,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 = {}
@ -1075,7 +1075,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)

View File

@ -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):

View File

@ -383,8 +383,18 @@ class NsxPolicyResourceBase(object):
transaction.store_def(policy_def, self.policy_api.client)
else:
# No transaction - apply now
self._delete_with_retry(policy_def)
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."""
@ -408,7 +418,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):
@ -531,7 +541,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):
@ -662,7 +672,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):
@ -996,7 +1006,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):
@ -1149,7 +1159,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):
@ -1220,7 +1230,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 list_segment_interface(self, tier1_id,
tenant=constants.POLICY_INFRA_TENANT):
@ -1384,7 +1394,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):
@ -1624,7 +1634,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):
@ -1790,7 +1800,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):
@ -1864,7 +1874,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):
@ -1960,7 +1970,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()
@ -2138,7 +2148,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,
@ -2271,7 +2281,7 @@ class SegmentProfilesBindingMapBaseApi(NsxPolicyResourceBase):
map_def = self.entry_def(segment_id=segment_id,
map_id=map_id,
tenant=tenant)
self.policy_api.delete(map_def)
self._delete_with_retry(map_def)
def get(self, segment_id, map_id=DEFAULT_MAP_ID,
tenant=constants.POLICY_INFRA_TENANT):
@ -2340,7 +2350,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):
@ -2553,7 +2563,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,
@ -2745,7 +2755,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,
@ -2790,7 +2800,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):
@ -2837,7 +2847,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,
@ -2882,7 +2892,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):
@ -2927,7 +2937,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):
@ -2989,7 +2999,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):
@ -3296,7 +3306,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):
@ -3305,7 +3315,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):
@ -3598,7 +3608,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):
@ -3865,7 +3875,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):
@ -3920,7 +3930,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):
@ -4153,7 +4163,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,
@ -4207,7 +4217,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):
@ -4260,7 +4270,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):
@ -4319,7 +4329,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):
@ -4421,7 +4431,7 @@ class NsxPolicyTier0RouteMapApi(NsxPolicyResourceBase):
route_map_def = self.entry_def(tier0_id=tier0_id,
route_map_id=route_map_id,
tenant=tenant)
self.policy_api.delete(route_map_def)
self._delete_with_retry(route_map_def)
def get(self, tier0_id, route_map_id,
tenant=constants.POLICY_INFRA_TENANT):
@ -4492,7 +4502,7 @@ class NsxPolicyTier0PrefixListApi(NsxPolicyResourceBase):
prefix_list_def = self.entry_def(tier0_id=tier0_id,
prefix_list_id=prefix_list_id,
tenant=tenant)
self.policy_api.delete(prefix_list_def)
self._delete_with_retry(prefix_list_def)
def get(self, tier0_id, prefix_list_id,
tenant=constants.POLICY_INFRA_TENANT):

View File

@ -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):

View File

@ -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):
@ -182,7 +182,7 @@ class NsxPolicyLoadBalancerServerSSLProfileApi(NsxPolicyResourceBase):
lb_server_ssl_profile_def = self.entry_def(
server_ssl_profile_id=server_ssl_profile_id,
tenant=tenant)
self.policy_api.delete(lb_server_ssl_profile_def)
self._delete_with_retry(lb_server_ssl_profile_def)
def get(self, server_ssl_profile_id,
tenant=constants.POLICY_INFRA_TENANT):
@ -239,7 +239,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):
@ -299,7 +299,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):
@ -501,7 +501,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):
@ -662,7 +662,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(
@ -785,7 +785,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):
@ -1030,7 +1030,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):

View File

@ -571,7 +571,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

View File

@ -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:

View File

@ -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()

View File

@ -318,6 +318,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):
@ -367,7 +369,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 = []
@ -428,9 +430,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,
@ -451,20 +452,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)