Browse Source

Merge "Fix member_batch_update function to follow api v2"

master
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
79104e2d7f
3 changed files with 9 additions and 28 deletions
  1. +1
    -15
      ovn_octavia_provider/driver.py
  2. +1
    -1
      ovn_octavia_provider/tests/functional/base.py
  3. +7
    -12
      ovn_octavia_provider/tests/unit/test_driver.py

+ 1
- 15
ovn_octavia_provider/driver.py View File

@@ -273,23 +273,9 @@ class OvnProviderDriver(driver_base.ProviderDriver):
'info': request_info}
self._ovn_helper.add_request(request)

def member_batch_update(self, members):
# Note(rbanerje): all members belong to the same pool.
def member_batch_update(self, pool_id, members):
request_list = []
skipped_members = []
pool_id = None
try:
pool_id = members[0].pool_id
except IndexError:
msg = _('No member information has been passed')
raise driver_exceptions.UnsupportedOptionError(
user_fault_string=msg,
operator_fault_string=msg)
except AttributeError:
msg = _('Member does not have proper pool information')
raise driver_exceptions.UnsupportedOptionError(
user_fault_string=msg,
operator_fault_string=msg)
pool_key, ovn_lb = self._ovn_helper._find_ovn_lb_by_pool_id(pool_id)
external_ids = copy.deepcopy(ovn_lb.external_ids)
existing_members = external_ids[pool_key].split(',')


+ 1
- 1
ovn_octavia_provider/tests/functional/base.py View File

@@ -742,7 +742,7 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
pool = self._get_pool_from_lb_data(lb_data, pool_id=pool_id)
expected_status = []
self._o_driver_lib.update_loadbalancer_status.reset_mock()
self.ovn_driver.member_batch_update(members)
self.ovn_driver.member_batch_update(pool_id, members)
for member in members:
expected_status.append(
{'pools': [{'id': pool.pool_id,


+ 7
- 12
ovn_octavia_provider/tests/unit/test_driver.py View File

@@ -285,39 +285,34 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
mock_ip_differs.assert_not_called()

def test_member_batch_update(self):
self.driver.member_batch_update([self.ref_member, self.update_member])
self.driver.member_batch_update(self.pool_id,
[self.ref_member, self.update_member])
self.assertEqual(self.mock_add_request.call_count, 3)

def test_member_batch_update_no_members(self):
self.assertRaises(exceptions.UnsupportedOptionError,
self.driver.member_batch_update, [])

def test_member_batch_update_missing_pool(self):
delattr(self.ref_member, 'pool_id')
self.assertRaises(exceptions.UnsupportedOptionError,
self.driver.member_batch_update, [self.ref_member])

def test_member_batch_update_skipped_monitor(self):
self.ref_member.monitor_address = '10.11.1.1'
self.assertRaises(exceptions.UnsupportedOptionError,
self.driver.member_batch_update,
self.pool_id,
[self.ref_member])

def test_member_batch_update_skipped_mixed_ip(self):
self.ref_member.address = 'fc00::1'
self.assertRaises(exceptions.UnsupportedOptionError,
self.driver.member_batch_update,
self.pool_id,
[self.ref_member])

def test_member_batch_update_unset_admin_state_up(self):
self.ref_member.admin_state_up = data_models.UnsetType()
self.driver.member_batch_update([self.ref_member])
self.driver.member_batch_update(self.pool_id, [self.ref_member])
self.assertEqual(self.mock_add_request.call_count, 2)

def test_member_batch_update_missing_subnet_id(self):
self.ref_member.subnet_id = None
self.assertRaises(exceptions.UnsupportedOptionError,
self.driver.member_batch_update, [self.ref_member])
self.driver.member_batch_update,
self.pool_id, [self.ref_member])

def test_member_update_failure(self):
self.assertRaises(exceptions.UnsupportedOptionError,


Loading…
Cancel
Save