Merge "Fix create_vip_port prototype based on octavia-lib"

This commit is contained in:
Zuul 2022-09-05 17:50:45 +00:00 committed by Gerrit Code Review
commit d490778979
2 changed files with 24 additions and 6 deletions

View File

@ -440,7 +440,22 @@ class OvnProviderDriver(driver_base.ProviderDriver):
user_fault_string=msg,
operator_fault_string=msg)
def create_vip_port(self, lb_id, project_id, vip_dict):
def create_vip_port(self, lb_id, project_id, vip_dict,
additional_vip_dicts=None):
"""Create the VIP port of a load balancer
:param lb_id: The ID of the load balancer
:param project_id: The ID of the project that owns the load balancer
:param vip_dict: A dict that contains the provider VIP information
('network_id', 'port_id', 'subnet_id' and/or 'ip_address')
:param additional_vip_dicts: An optional list of dicts of additional
VIP. An additional VIP dict might contain the 'ip_address',
'network_id', 'port_id' and/or 'subnet_id' of the secondary
VIPs.
:return: a tuple that contains the VIP provider dictionary and a list
of additional VIP dictionaries
"""
# TODO(gthiemonge): implement additional_vip_dicts
try:
port = self._ovn_helper.create_vip_port(
project_id, lb_id, vip_dict)['port']
@ -454,7 +469,7 @@ class OvnProviderDriver(driver_base.ProviderDriver):
'operator_fault_string': e.message}
raise driver_exceptions.DriverError(
**kwargs)
return vip_dict
return vip_dict, []
def _validate_hm_support(self, hm, action='create'):
if not self._is_health_check_supported():

View File

@ -911,11 +911,13 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
def test_create_vip_port(self):
with mock.patch.object(clients, 'get_neutron_client'):
port_dict = self.driver.create_vip_port(self.loadbalancer_id,
self.project_id,
self.vip_dict)
port_dict, add_vip_dicts = (
self.driver.create_vip_port(self.loadbalancer_id,
self.project_id,
self.vip_dict, []))
self.assertIsNotNone(port_dict.pop('vip_address', None))
self.assertIsNotNone(port_dict.pop('vip_port_id', None))
self.assertEqual(len(add_vip_dicts), 0)
# The network_driver function is mocked, therefore the
# created port vip_address and vip_port_id are also mocked.
# Check if it exists and move on.
@ -932,7 +934,8 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
self.driver.create_vip_port,
self.loadbalancer_id,
self.project_id,
self.vip_dict)
self.vip_dict,
[])
def test_health_monitor_create(self):
info = {'id': self.ref_health_monitor.healthmonitor_id,