Browse Source

Migrate from Octavia to Octavia-Lib

This patch migrates from octavia to octavia-lib

Change-Id: I9542669c1f7f16c6ce8a7a10afcbf7f563f35919
Reedip 8 months ago
parent
commit
c9d6820dc4

+ 1
- 0
lower-constraints.txt View File

@@ -58,6 +58,7 @@ netaddr==0.7.18
58 58
 netifaces==0.10.4
59 59
 neutron==13.0.0.0b2
60 60
 neutron-lib==1.22.0
61
+octavia-lib==1.0.0
61 62
 openstackdocstheme==1.18.1
62 63
 openstacksdk==0.11.2
63 64
 os-client-config==1.28.0

+ 22
- 12
networking_ovn/octavia/ovn_driver.py View File

@@ -18,23 +18,25 @@ import threading
18 18
 
19 19
 from six.moves import queue as Queue
20 20
 
21
+from oslo_config import cfg
21 22
 from oslo_log import log as logging
22 23
 from oslo_serialization import jsonutils
23 24
 
24 25
 from ovs.stream import Stream
25 26
 from ovsdbapp.schema.ovn_northbound import impl_idl as idl_ovn
27
+from stevedore import driver
26 28
 
27
-from octavia.api.drivers import data_models as o_datamodels
28
-from octavia.api.drivers import driver_lib as o_driver_lib
29
-from octavia.api.drivers import exceptions as driver_exceptions
30
-from octavia.api.drivers import provider_base as driver_base
31
-from octavia.common import constants
32
-from octavia.common import utils
29
+from octavia_lib.api.drivers import data_models as o_datamodels
30
+from octavia_lib.api.drivers import driver_lib as o_driver_lib
31
+from octavia_lib.api.drivers import exceptions as driver_exceptions
32
+from octavia_lib.api.drivers import provider_base as driver_base
33
+from octavia_lib.common import constants
33 34
 
34 35
 from networking_ovn._i18n import _
35 36
 from networking_ovn.common import config as ovn_cfg
36 37
 from networking_ovn.common import utils as ovn_utils
37 38
 
39
+CONF = cfg.CONF  # Gets Octavia Conf as it runs under o-api domain
38 40
 
39 41
 LOG = logging.getLogger(__name__)
40 42
 
@@ -193,6 +195,15 @@ LB_EXT_IDS_VIP_KEY = 'neutron:vip'
193 195
 LB_EXT_IDS_VIP_PORT_ID_KEY = 'neutron:vip_port_id'
194 196
 
195 197
 
198
+def get_network_driver():
199
+    CONF.import_group('controller_worker', 'octavia.common.config')
200
+    return driver.DriverManager(
201
+        namespace='octavia.network.drivers',
202
+        name=CONF.controller_worker.network_driver,
203
+        invoke_on_load=True
204
+    ).driver
205
+
206
+
196 207
 class OvnProviderHelper(object):
197 208
 
198 209
     ovn_nbdb_api = None
@@ -317,7 +328,7 @@ class OvnProviderHelper(object):
317 328
         if network_id:
318 329
             ls_name = ovn_utils.ovn_name(network_id)
319 330
         else:
320
-            network_driver = utils.get_network_driver()
331
+            network_driver = get_network_driver()
321 332
             subnet = network_driver.get_subnet(subnet_id)
322 333
             ls_name = ovn_utils.ovn_name(subnet.network_id)
323 334
 
@@ -497,7 +508,7 @@ class OvnProviderHelper(object):
497 508
             # Get the port id of the vip and store it in the external_ids.
498 509
             # This is required to delete the port when the loadbalancer is
499 510
             # deleted.
500
-            network_driver = utils.get_network_driver()
511
+            network_driver = get_network_driver()
501 512
             ports = network_driver.neutron_client.list_ports(
502 513
                 network_id=loadbalancer['vip_network_id'])
503 514
             port = None
@@ -616,7 +627,7 @@ class OvnProviderHelper(object):
616 627
             self._execute_commands(commands)
617 628
 
618 629
             # We need to delete the vip port
619
-            network_driver = utils.get_network_driver()
630
+            network_driver = get_network_driver()
620 631
             network_driver.neutron_client.delete_port(
621 632
                 ovn_lb.external_ids[LB_EXT_IDS_VIP_PORT_ID_KEY])
622 633
         except Exception:
@@ -643,18 +654,17 @@ class OvnProviderHelper(object):
643 654
             lb_enabled = loadbalancer['admin_state_up']
644 655
 
645 656
             ovn_lb = self._find_ovn_lb(loadbalancer['id'])
646
-            external_ids = copy.deepcopy(ovn_lb.external_ids)
647 657
             if ovn_lb.external_ids['enabled'] != str(lb_enabled):
648 658
                 commands = []
649 659
                 enable_info = {'enabled': str(lb_enabled)}
650
-                external_ids['enabled'] = str(lb_enabled)
660
+                ovn_lb.external_ids['enabled'] = str(lb_enabled)
651 661
                 commands.append(
652 662
                     self.ovn_nbdb_api.db_set('Load_Balancer', ovn_lb.uuid,
653 663
                                              ('external_ids', enable_info))
654 664
                 )
655 665
 
656 666
                 commands.extend(
657
-                    self._refresh_lb_vips(ovn_lb.uuid, external_ids))
667
+                    self._refresh_lb_vips(ovn_lb.uuid, ovn_lb.external_ids))
658 668
 
659 669
                 self._execute_commands(commands)
660 670
             if lb_enabled:

+ 5
- 6
networking_ovn/tests/functional/octavia/test_ovn_driver.py View File

@@ -16,10 +16,9 @@
16 16
 import mock
17 17
 
18 18
 from neutron.common import utils as n_utils
19
-from octavia.api.drivers import data_models as octavia_data_model
20
-from octavia.api.drivers import exceptions as o_exceptions
21
-from octavia.common import constants as o_constants
22
-from octavia.common import utils as o_utils
19
+from octavia_lib.api.drivers import data_models as octavia_data_model
20
+from octavia_lib.api.drivers import exceptions as o_exceptions
21
+from octavia_lib.common import constants as o_constants
23 22
 from oslo_serialization import jsonutils
24 23
 from oslo_utils import uuidutils
25 24
 
@@ -40,8 +39,8 @@ class TestOctaviaOvnProviderDriver(base.TestOVNFunctionalBase):
40 39
         self._o_driver_lib = self.ovn_driver._ovn_helper._octavia_driver_lib
41 40
         self._o_driver_lib.update_loadbalancer_status = mock.Mock()
42 41
         self.fake_network_driver = mock.MagicMock()
43
-        o_utils.get_network_driver = mock.MagicMock()
44
-        o_utils.get_network_driver.return_value = self.fake_network_driver
42
+        ovn_driver.get_network_driver = mock.MagicMock()
43
+        ovn_driver.get_network_driver.return_value = self.fake_network_driver
45 44
         self.fake_network_driver.get_subnet = self._mock_get_subnet
46 45
         self.fake_network_driver.neutron_client.list_ports = (
47 46
             self._mock_list_ports)

+ 0
- 1
networking_ovn/tests/functional/requirements.txt View File

@@ -4,7 +4,6 @@
4 4
 # of appearance. Changing the order has an impact on the overall integration
5 5
 # process, which may cause wedges in the gate later.
6 6
 
7
-octavia>=3.0.0.0b3
8 7
 psutil>=1.1.1,<2.0.0
9 8
 psycopg2
10 9
 PyMySQL>=0.6.2  # MIT License

+ 1
- 0
test-requirements.txt View File

@@ -14,6 +14,7 @@ oslotest>=3.2.0 # Apache-2.0
14 14
 os-testr>=1.0.0 # Apache-2.0
15 15
 pylint==1.9.3;python_version=='2.7' # GPLv2
16 16
 pylint==2.1.1;python_version>='3.0' # GPLv2
17
+octavia-lib>=1.0.0
17 18
 testresources>=2.0.0 # Apache-2.0/BSD
18 19
 testscenarios>=0.4 # Apache-2.0/BSD
19 20
 WebTest>=2.0.27 # MIT

Loading…
Cancel
Save