Browse Source

Fix update of the pool member backup state

Change-Id: I405bc36559998f16bf67eb6b807e1fd95c2358e1
changes/95/760795/1
asarfaty 2 years ago
parent
commit
620c918579
  1. 12
      vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py
  2. 2
      vmware_nsxlib/v3/policy/lb_defs.py
  3. 2
      vmware_nsxlib/v3/policy/lb_resources.py

12
vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py

@ -14,6 +14,7 @@
# under the License.
#
import copy
from unittest import mock
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
@ -1727,7 +1728,8 @@ class TestPolicyLBPoolApi(test_resources.NsxPolicyLibTestCase):
ip_address = '1.1.1.1'
port = '80'
new_name = 'mem1'
member = {'ip_address': ip_address, 'port': port}
member = {'ip_address': ip_address, 'port': port,
'backup_member': True}
with mock.patch.object(self.policy_api, "get",
return_value={'id': obj_id,
'members': [member]}), \
@ -1735,11 +1737,13 @@ class TestPolicyLBPoolApi(test_resources.NsxPolicyLibTestCase):
"create_or_update") as update_call:
self.resourceApi.update_pool_member(
obj_id, ip_address, port=port, display_name=new_name,
tenant=TEST_TENANT)
member['display_name'] = new_name
backup_member=False, tenant=TEST_TENANT)
new_member = copy.copy(member)
new_member['display_name'] = new_name
new_member['backup_member'] = False
expected_def = lb_defs.LBPoolDef(
lb_pool_id=obj_id,
members=[member],
members=[new_member],
tenant=TEST_TENANT)
self.assert_called_with_def(update_call, expected_def)

2
vmware_nsxlib/v3/policy/lb_defs.py

@ -79,7 +79,7 @@ class LBPoolMemberDef(object):
body['weight'] = self.weight
if self.admin_state:
body['admin_state'] = self.admin_state
if self.backup_member:
if self.backup_member is not None:
body['backup_member'] = self.backup_member
return body

2
vmware_nsxlib/v3/policy/lb_resources.py

@ -585,7 +585,7 @@ class NsxPolicyLoadBalancerPoolApi(NsxPolicyResourceBase):
member_to_update[0]['weight'] = weight
if admin_state:
member_to_update[0]['admin_state'] = admin_state
if backup_member:
if backup_member is not None:
member_to_update[0]['backup_member'] = backup_member
self._update(lb_pool_id=lb_pool_id, members=lb_pool_members,
tenant=tenant)

Loading…
Cancel
Save