Merge "Add Arg to Force Non-partial Update in Policy VS"

This commit is contained in:
Zuul 2019-11-13 06:26:15 +00:00 committed by Gerrit Code Review
commit 256065ed37
3 changed files with 23 additions and 5 deletions

View File

@ -959,6 +959,22 @@ class TestPolicyLBVirtualServer(test_resources.NsxPolicyLibTestCase):
tenant=TEST_TENANT)
self.assert_called_with_def(update_call, expected_def)
def test_non_partial_update(self):
obj_id = '111'
vs_name = 'name-name'
with self.mock_get(obj_id, vs_name, max_concurrent_connections=80), \
self.mock_create_update() as update_call:
self.resourceApi.update(obj_id,
max_concurrent_connections=None,
tenant=TEST_TENANT,
allow_partial_updates=False)
expected_def = lb_defs.LBVirtualServerDef(
virtual_server_id=obj_id, name=vs_name,
max_concurrent_connections=None,
tenant=TEST_TENANT)
update_call.assert_called_with(mock.ANY, partial_updates=False)
self.assert_called_with_def(update_call, expected_def)
def test_add_lb_rule(self):
vs_obj_id = '111'
vs_name = 'name-name'

View File

@ -142,10 +142,10 @@ class NsxPolicyResourceBase(object):
return resource_def
def _update(self, **kwargs):
def _update(self, allow_partial_updates=True, **kwargs):
"""Helper for update function - ignore attrs without explicit value"""
if self.policy_api.partial_updates_supported():
if (allow_partial_updates and
self.policy_api.partial_updates_supported()):
policy_def = self._init_def(**kwargs)
partial_updates = True
else:

View File

@ -754,7 +754,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
max_concurrent_connections=IGNORE,
access_list_control=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
tenant=constants.POLICY_INFRA_TENANT,
allow_partial_updates=True):
@utils.retry_upon_exception(
nsxlib_exc.StaleRevision,
@ -777,7 +778,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
waf_profile_binding=waf_profile_binding,
max_concurrent_connections=max_concurrent_connections,
access_list_control=access_list_control,
tags=tags)
tags=tags,
allow_partial_updates=allow_partial_updates)
_update()