Fix create_vip_port prototype based on octavia-lib

Commit [0] updated the prototype of the create_vip_port function in the
ProviderDriver class. Now that the multi-vip feature is being added in
octavia [1], the parameter will be passed to the providers by the
octavia-api.
Adding the parameter to the ovn-provider will prevent exceptions [2]
when the feature is merged.

[0] https://review.opendev.org/c/openstack/octavia-lib/+/664510
[1] https://review.opendev.org/c/openstack/octavia/+/660239
[2] "create_vip_port() takes 4 positional arguments but 5 were given"

Change-Id: I59f10b7267151e333c437d498af1d45b8beaf0ec
This commit is contained in:
Gregory Thiemonge 2022-08-26 10:54:08 +02:00
parent bb077b4eb7
commit 7c027e859f
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,