Add configuration for policy realization retries

Change-Id: I3cbaeb324f05e48772a8ac13991f3660d65eb5c8
This commit is contained in:
Adit Sarfaty 2018-12-25 11:17:10 +02:00
parent 8643a69a11
commit a0421812b2
3 changed files with 13 additions and 6 deletions

View File

@ -395,7 +395,8 @@ class NsxPolicyLib(NsxLibBase):
else:
self.nsx_api = None
self.nsx_version = self.get_version()
args = (self.policy_api, self.nsx_api, self.nsx_version)
args = (self.policy_api, self.nsx_api, self.nsx_version,
self.nsxlib_config)
# Initialize all the different resources
self.domain = policy_resources.NsxPolicyDomainApi(*args)

View File

@ -82,6 +82,9 @@ class NsxLibConfig(object):
-- Additional parameters which are relevant only for the Policy manager:
:param allow_passthrough: If True, use nsx manager api for cases which are
not supported by the policy manager api.
:param realization_max_attempts: Maximum number of times to retry while
waiting for a resource to be realized.
.
"""
def __init__(self,
@ -107,7 +110,9 @@ class NsxLibConfig(object):
allow_overwrite_header=False,
rate_limit_retry=True,
cluster_unavailable_retry=False,
allow_passthrough=False):
allow_passthrough=False,
# TODO(asarfaty): reduce the default once plugin is stable
realization_max_attempts=50):
self.nsx_api_managers = nsx_api_managers
self._username = username
@ -131,6 +136,7 @@ class NsxLibConfig(object):
self.rate_limit_retry = rate_limit_retry
self.cluster_unavailable_retry = cluster_unavailable_retry
self.allow_passthrough = allow_passthrough
self.realization_max_attempts = realization_max_attempts
if dhcp_profile_uuid:
# this is deprecated, and never used.

View File

@ -49,10 +49,11 @@ class NsxPolicyResourceBase(object):
"""
SINGLE_ENTRY_ID = 'entry'
def __init__(self, policy_api, nsx_api, version):
def __init__(self, policy_api, nsx_api, version, nsxlib_config):
self.policy_api = policy_api
self.nsx_api = nsx_api
self.version = version
self.nsxlib_config = nsxlib_config
@property
def entry_def(self):
@ -190,11 +191,10 @@ class NsxPolicyResourceBase(object):
Return the realization info, or raise an error
"""
# TODO(asarfaty): add configurations for sleep/attempts?
if sleep is None:
sleep = 1
sleep = 0.5
if max_attempts is None:
max_attempts = 200
max_attempts = self.nsxlib_config.realization_max_attempts
test_num = 0
while test_num < max_attempts: