Add Arg to Force Non-partial Update in Policy VS

In Policy API, currently whether partial update is used or not is
decided internally based on NSX version. There exists cases where
non-partial updates are required to remove some optional attr from an
existing resource. This patch only exposes such functionality to Policy
VS API. Other resources are not affected.

Change-Id: I27df2e81c9555af33ae3db20fd42a2e7f21a8bb6
This commit is contained in:
Shawn Wang 2019-11-12 01:18:34 -08:00
parent 4215eed1d4
commit 80a1e11490
No known key found for this signature in database
GPG Key ID: C98A86CC967E89A7
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()