Browse Source

Fix update of the pool member backup state

Change-Id: I405bc36559998f16bf67eb6b807e1fd95c2358e1
changes/88/760888/3
asarfaty 4 months ago
committed by Adit Sarfaty
parent
commit
f475834a1c
3 changed files with 10 additions and 6 deletions
  1. +8
    -4
      vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py
  2. +1
    -1
      vmware_nsxlib/v3/policy/lb_defs.py
  3. +1
    -1
      vmware_nsxlib/v3/policy/lb_resources.py

+ 8
- 4
vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py View File

@ -14,6 +14,7 @@
# under the License.
#
import copy
import mock
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
@ -1497,7 +1498,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]}), \
@ -1505,11 +1507,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)


+ 1
- 1
vmware_nsxlib/v3/policy/lb_defs.py View File

@ -77,7 +77,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


+ 1
- 1
vmware_nsxlib/v3/policy/lb_resources.py View File

@ -531,7 +531,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