Support remove persistence profile from DLB VirtualServer
DistributedLoadBalancer VirtualServer doesn't support setting lb_persistence_profile_path as empty string to remove it. Instead, use non-partial-patch with existing attributes and omit lb_persistence_profile_path to achieve removal. Change-Id: Ia9612d076a1e2ccab1d2fa758006a74703c4d061
This commit is contained in:
parent
a1b5793114
commit
d524357af2
|
@ -1372,6 +1372,18 @@ class TestPolicyLBVirtualServer(test_resources.NsxPolicyLibTestCase):
|
|||
virtual_server_id=vs_id, name=vs_name)
|
||||
self.assert_called_with_def(update_call, expected_def)
|
||||
|
||||
def test_remove_dlb_virtual_server_persistence_profile(self):
|
||||
vs_id = 'test-id'
|
||||
vs_name = 'test-name'
|
||||
with self.mock_get(
|
||||
vs_id, vs_name, lb_persistence_profile_path='test-profile'), \
|
||||
self.mock_create_update() as update_call:
|
||||
self.resourceApi.remove_dlb_virtual_server_persistence_profile(
|
||||
vs_id)
|
||||
expected_def = lb_defs.LBVirtualServerDef(
|
||||
virtual_server_id=vs_id, name=vs_name)
|
||||
self.assert_called_with_def(update_call, expected_def)
|
||||
|
||||
|
||||
class TestPolicyLBPoolApi(test_resources.NsxPolicyLibTestCase):
|
||||
|
||||
|
|
|
@ -910,6 +910,17 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
|||
self.policy_api.create_or_update(
|
||||
lbvs_def, partial_updates=False)
|
||||
|
||||
def remove_dlb_virtual_server_persistence_profile(
|
||||
self, virtual_server_id, tenant=constants.POLICY_INFRA_TENANT):
|
||||
dlb_vs_def = self._get_and_update_def(
|
||||
virtual_server_id=virtual_server_id, tenant=tenant)
|
||||
body = dlb_vs_def.body if dlb_vs_def.body else {}
|
||||
body.pop('lb_persistence_profile_path', None)
|
||||
if body:
|
||||
dlb_vs_def.set_obj_dict(body)
|
||||
self.policy_api.create_or_update(
|
||||
dlb_vs_def, partial_updates=False)
|
||||
|
||||
def update_virtual_server_with_vip(self, virtual_server_id, vip,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
return self.update(
|
||||
|
|
Loading…
Reference in New Issue