Merge "Support turn off partial patch in LbPool update call"

This commit is contained in:
Zuul 2020-05-24 13:51:40 +00:00 committed by Gerrit Code Review
commit aeaa12cac7
2 changed files with 40 additions and 2 deletions

View File

@ -1570,6 +1570,43 @@ class TestPolicyLBPoolApi(test_resources.NsxPolicyLibTestCase):
tenant=TEST_TENANT)
self.assert_called_with_def(update_call, expected_def)
def test_update_without_partial_patch(self):
obj_id = '111'
name = 'new name'
description = 'new desc'
members = [{'ip_address': '10.0.0.1'}]
algorithm = 'algo'
active_monitor_paths = ['path1']
member_group = 'group1'
snat_translation = False
with mock.patch.object(self.policy_api, "get",
return_value={'id': obj_id}), \
mock.patch.object(self.policy_api,
"create_or_update") as update_call:
self.resourceApi.update(obj_id,
name=name,
description=description,
members=members,
active_monitor_paths=active_monitor_paths,
algorithm=algorithm,
member_group=member_group,
snat_translation=snat_translation,
tenant=TEST_TENANT,
allow_partial_updates=False)
expected_def = lb_defs.LBPoolDef(
lb_pool_id=obj_id,
name=name,
description=description,
members=members,
active_monitor_paths=active_monitor_paths,
algorithm=algorithm,
member_group=member_group,
snat_translation=snat_translation,
tenant=TEST_TENANT)
update_call.assert_called_with(mock.ANY, partial_updates=False,
force=False)
self.assert_called_with_def(update_call, expected_def)
def test_add_monitor_to_pool(self):
obj_id = '111'
active_monitor_paths = ['path1']

View File

@ -512,7 +512,8 @@ class NsxPolicyLoadBalancerPoolApi(NsxPolicyResourceBase):
tags=IGNORE, members=IGNORE, algorithm=IGNORE,
active_monitor_paths=IGNORE, member_group=IGNORE,
snat_translation=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
tenant=constants.POLICY_INFRA_TENANT,
allow_partial_updates=True):
self._update(
lb_pool_id=lb_pool_id,
name=name,
@ -523,7 +524,7 @@ class NsxPolicyLoadBalancerPoolApi(NsxPolicyResourceBase):
algorithm=algorithm,
member_group=member_group,
snat_translation=snat_translation,
tenant=tenant)
tenant=tenant, allow_partial_updates=allow_partial_updates)
def add_monitor_to_pool(self, lb_pool_id, active_monitor_paths,
tenant=constants.POLICY_INFRA_TENANT):