Add stale revision retry on policy update calls (using PATCH)
Change-Id: Ic6c4a8dc1af50818012df48d77314a1e5f1737ac
This commit is contained in:
parent
24b15000ca
commit
540b7b07fb
|
@ -145,19 +145,24 @@ class NsxPolicyResourceBase(object):
|
|||
|
||||
def _update(self, **kwargs):
|
||||
"""Helper for update function - ignore attrs without explicit value"""
|
||||
@utils.retry_upon_exception(
|
||||
exceptions.StaleRevision,
|
||||
max_attempts=self.policy_api.client.max_attempts)
|
||||
def _do_update_with_retry():
|
||||
if self.policy_api.partial_updates_supported():
|
||||
policy_def = self._init_def(**kwargs)
|
||||
partial_updates = True
|
||||
else:
|
||||
policy_def = self._get_and_update_def(**kwargs)
|
||||
partial_updates = False
|
||||
|
||||
if self.policy_api.partial_updates_supported():
|
||||
policy_def = self._init_def(**kwargs)
|
||||
partial_updates = True
|
||||
else:
|
||||
policy_def = self._get_and_update_def(**kwargs)
|
||||
partial_updates = False
|
||||
if policy_def.bodyless():
|
||||
# Nothing to update - only keys provided in kwargs
|
||||
return
|
||||
self.policy_api.create_or_update(
|
||||
policy_def, partial_updates=partial_updates)
|
||||
|
||||
if policy_def.bodyless():
|
||||
# Nothing to update - only keys provided in kwargs
|
||||
return
|
||||
self.policy_api.create_or_update(
|
||||
policy_def, partial_updates=partial_updates)
|
||||
return _do_update_with_retry()
|
||||
|
||||
@staticmethod
|
||||
def _init_obj_uuid(obj_uuid):
|
||||
|
|
Loading…
Reference in New Issue