Browse Source

Refactoring config options for ml2 config opts

Refactoring neutron ml2 config opts to be in neutron/conf/plugins/ml2.
This would allow centralization of all configuration options and
provides an easy way to import.

NeutronLibImpact

Change-Id: Ibc5a9ab268578c243ef13f7e0041bacd6c0c410b
Partial-Bug: #1563069
Needed-By: Id0a97dda7718f06e33b2d30ce01cdcb3e9a46f7d
tags/12.0.0.0b1
Aradhana Singh 2 years ago
parent
commit
d00a50aad1

+ 1
- 1
neutron/cmd/sanity_check.py View File

@@ -35,7 +35,7 @@ def setup_conf():
35 35
                           'agent.common.config')
36 36
     cfg.CONF.import_group('VXLAN', 'neutron.plugins.ml2.drivers.linuxbridge.'
37 37
                           'agent.common.config')
38
-    cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config')
38
+    cfg.CONF.import_group('ml2', 'neutron.conf.plugins.ml2.config')
39 39
     cfg.CONF.import_group('SECURITYGROUP', 'neutron.agent.securitygroups_rpc')
40 40
     dhcp_agent.register_options(cfg.CONF)
41 41
     cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS)

neutron/plugins/ml2/config.py → neutron/conf/plugins/ml2/config.py View File

@@ -69,4 +69,5 @@ ml2_opts = [
69 69
 ]
70 70
 
71 71
 
72
-cfg.CONF.register_opts(ml2_opts, "ml2")
72
+def register_ml2_plugin_opts(cfg=cfg.CONF):
73
+    cfg.register_opts(ml2_opts, "ml2")

+ 2
- 2
neutron/opts.py View File

@@ -33,6 +33,7 @@ import neutron.conf.agent.xenapi_conf
33 33
 import neutron.conf.cache_utils
34 34
 import neutron.conf.common
35 35
 import neutron.conf.extensions.allowedaddresspairs
36
+import neutron.conf.plugins.ml2.config
36 37
 import neutron.conf.plugins.ml2.drivers.agent
37 38
 import neutron.conf.plugins.ml2.drivers.driver_type
38 39
 import neutron.conf.plugins.ml2.drivers.linuxbridge
@@ -54,7 +55,6 @@ import neutron.db.l3_hamode_db
54 55
 import neutron.db.migration.cli
55 56
 import neutron.extensions.l3
56 57
 import neutron.extensions.securitygroup
57
-import neutron.plugins.ml2.config
58 58
 import neutron.plugins.ml2.drivers.mech_sriov.agent.common.config
59 59
 import neutron.wsgi
60 60
 
@@ -235,7 +235,7 @@ def list_metering_agent_opts():
235 235
 def list_ml2_conf_opts():
236 236
     return [
237 237
         ('ml2',
238
-         neutron.plugins.ml2.config.ml2_opts),
238
+         neutron.conf.plugins.ml2.config.ml2_opts),
239 239
         ('ml2_type_flat',
240 240
          neutron.conf.plugins.ml2.drivers.driver_type.flat_opts),
241 241
         ('ml2_type_vlan',

+ 2
- 0
neutron/plugins/ml2/managers.py View File

@@ -25,6 +25,7 @@ from oslo_utils import excutils
25 25
 import stevedore
26 26
 
27 27
 from neutron._i18n import _
28
+from neutron.conf.plugins.ml2 import config
28 29
 from neutron.db import api as db_api
29 30
 from neutron.db import segments_db
30 31
 from neutron.extensions import external_net
@@ -37,6 +38,7 @@ from neutron.plugins.ml2 import models
37 38
 LOG = log.getLogger(__name__)
38 39
 
39 40
 MAX_BINDING_LEVELS = 10
41
+config.register_ml2_plugin_opts()
40 42
 
41 43
 
42 44
 class TypeManager(stevedore.named.NamedExtensionManager):

+ 0
- 1
neutron/plugins/ml2/plugin.py View File

@@ -81,7 +81,6 @@ from neutron.extensions import providernet as provider
81 81
 from neutron.extensions import vlantransparent
82 82
 from neutron.plugins.common import utils as p_utils
83 83
 from neutron.plugins.ml2.common import exceptions as ml2_exc
84
-from neutron.plugins.ml2 import config  # noqa
85 84
 from neutron.plugins.ml2 import db
86 85
 from neutron.plugins.ml2 import driver_context
87 86
 from neutron.plugins.ml2.extensions import qos as qos_ext

+ 3
- 4
neutron/tests/unit/extensions/test_dns.py View File

@@ -23,7 +23,6 @@ from oslo_config import cfg
23 23
 from neutron.common import utils
24 24
 from neutron.db import db_base_plugin_v2
25 25
 from neutron.extensions import dns
26
-from neutron.plugins.ml2 import config
27 26
 from neutron.tests.unit.db import test_db_base_plugin_v2
28 27
 from neutron.tests.unit.plugins.ml2 import test_plugin
29 28
 
@@ -57,9 +56,9 @@ class DnsExtensionTestCase(test_plugin.Ml2PluginV2TestCase):
57 56
     _extension_drivers = ['dns']
58 57
 
59 58
     def setUp(self):
60
-        config.cfg.CONF.set_override('extension_drivers',
61
-                                     self._extension_drivers,
62
-                                     group='ml2')
59
+        cfg.CONF.set_override('extension_drivers',
60
+                              self._extension_drivers,
61
+                              group='ml2')
63 62
         super(DnsExtensionTestCase, self).setUp()
64 63
 
65 64
     def _create_network(self, fmt, name, admin_state_up,

+ 15
- 16
neutron/tests/unit/extensions/test_l3.py View File

@@ -55,7 +55,6 @@ from neutron.db import models_v2
55 55
 from neutron.extensions import dns
56 56
 from neutron.extensions import external_net
57 57
 from neutron.extensions import l3
58
-from neutron.plugins.ml2 import config
59 58
 from neutron.services.revisions import revision_plugin
60 59
 from neutron.tests import base
61 60
 from neutron.tests.common import helpers
@@ -4004,12 +4003,12 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4004 4003
     def setUp(self):
4005 4004
         ext_mgr = L3TestExtensionManagerWithDNS()
4006 4005
         plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
4007
-        config.cfg.CONF.set_override('extension_drivers',
4008
-                                     self._extension_drivers,
4009
-                                     group='ml2')
4006
+        cfg.CONF.set_override('extension_drivers',
4007
+                              self._extension_drivers,
4008
+                              group='ml2')
4010 4009
         super(L3NatDBFloatingIpTestCaseWithDNS, self).setUp(plugin=plugin,
4011 4010
                                                             ext_mgr=ext_mgr)
4012
-        config.cfg.CONF.set_override('external_dns_driver', 'designate')
4011
+        cfg.CONF.set_override('external_dns_driver', 'designate')
4013 4012
         self.mock_client.reset_mock()
4014 4013
         self.mock_admin_client.reset_mock()
4015 4014
 
@@ -4096,8 +4095,8 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4096 4095
     def _get_bytes_or_nybles_to_skip(self, in_addr_name):
4097 4096
         if 'in-addr.arpa' in in_addr_name:
4098 4097
             return ((
4099
-                32 - config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
4100
-        return (128 - config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
4098
+                32 - cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
4099
+        return (128 - cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
4101 4100
 
4102 4101
     def _get_in_addr(self, record):
4103 4102
         in_addr_name = netaddr.IPAddress(record).reverse_dns
@@ -4133,7 +4132,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4133 4132
 
4134 4133
     @mock.patch(MOCK_PATH, **mock_config)
4135 4134
     def test_floatingip_create_with_net_port_dns(self, mock_args):
4136
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4135
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4137 4136
         with self._create_floatingip_with_dns(net_dns_domain=self.DNS_DOMAIN,
4138 4137
                 port_dns_name=self.DNS_NAME, assoc_port=True) as flip:
4139 4138
             floatingip = flip
@@ -4143,7 +4142,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4143 4142
     def test_floatingip_create_with_flip_and_net_port_dns(self, mock_args):
4144 4143
         # If both network+port and the floating ip have dns domain and
4145 4144
         # dns name, floating ip's information should take priority
4146
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4145
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4147 4146
         with self._create_floatingip_with_dns(net_dns_domain='junkdomain.org.',
4148 4147
                 port_dns_name='junk', flip_dns_domain=self.DNS_DOMAIN,
4149 4148
                 flip_dns_name=self.DNS_NAME, assoc_port=True) as flip:
@@ -4173,7 +4172,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4173 4172
 
4174 4173
     @mock.patch(MOCK_PATH, **mock_config)
4175 4174
     def test_floatingip_associate_port_with_net_port_dns(self, mock_args):
4176
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4175
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4177 4176
         with self._create_floatingip_with_dns_on_update(
4178 4177
                 net_dns_domain=self.DNS_DOMAIN,
4179 4178
                 port_dns_name=self.DNS_NAME) as flip:
@@ -4185,7 +4184,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4185 4184
                                                                   mock_args):
4186 4185
         # If both network+port and the floating ip have dns domain and
4187 4186
         # dns name, floating ip's information should take priority
4188
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4187
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4189 4188
         with self._create_floatingip_with_dns_on_update(
4190 4189
                 net_dns_domain='junkdomain.org.',
4191 4190
                 port_dns_name='junk',
@@ -4198,7 +4197,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4198 4197
 
4199 4198
     @mock.patch(MOCK_PATH, **mock_config)
4200 4199
     def test_floatingip_disassociate_port(self, mock_args):
4201
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4200
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4202 4201
         with self._create_floatingip_with_dns(net_dns_domain=self.DNS_DOMAIN,
4203 4202
                 port_dns_name=self.DNS_NAME, assoc_port=True) as flip:
4204 4203
             fake_recordset = {'id': '',
@@ -4224,7 +4223,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4224 4223
 
4225 4224
     @mock.patch(MOCK_PATH, **mock_config)
4226 4225
     def test_floatingip_delete(self, mock_args):
4227
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4226
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4228 4227
         with self._create_floatingip_with_dns(flip_dns_domain=self.DNS_DOMAIN,
4229 4228
                 flip_dns_name=self.DNS_NAME) as flip:
4230 4229
             floatingip = flip
@@ -4243,13 +4242,13 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
4243 4242
 
4244 4243
     @mock.patch(MOCK_PATH, **mock_config)
4245 4244
     def test_floatingip_no_PTR_record(self, mock_args):
4246
-        config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4245
+        cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
4247 4246
 
4248 4247
         # Disabling this option should stop the admin client from creating
4249 4248
         # PTR records. So set this option and make sure the admin client
4250 4249
         # wasn't called to create any records
4251
-        config.cfg.CONF.set_override('allow_reverse_dns_lookup', False,
4252
-                                     group='designate')
4250
+        cfg.CONF.set_override('allow_reverse_dns_lookup', False,
4251
+                              group='designate')
4253 4252
 
4254 4253
         with self._create_floatingip_with_dns(flip_dns_domain=self.DNS_DOMAIN,
4255 4254
                 flip_dns_name=self.DNS_NAME) as flip:

+ 14
- 15
neutron/tests/unit/extensions/test_segment.py View File

@@ -44,7 +44,6 @@ from neutron.extensions import l2_adjacency
44 44
 from neutron.extensions import segment as ext_segment
45 45
 from neutron.objects import network
46 46
 from neutron.plugins.common import constants as p_constants
47
-from neutron.plugins.ml2 import config
48 47
 from neutron.services.segments import db
49 48
 from neutron.services.segments import exceptions as segment_exc
50 49
 from neutron.services.segments import placement_client
@@ -472,9 +471,9 @@ class HostSegmentMappingTestCase(SegmentTestCase):
472 471
     _mechanism_drivers = ['logger']
473 472
 
474 473
     def setUp(self, plugin=None):
475
-        config.cfg.CONF.set_override('mechanism_drivers',
476
-                                     self._mechanism_drivers,
477
-                                     group='ml2')
474
+        cfg.CONF.set_override('mechanism_drivers',
475
+                              self._mechanism_drivers,
476
+                              group='ml2')
478 477
 
479 478
         # NOTE(dasm): ml2_type_vlan requires to be registered before used.
480 479
         # This piece was refactored and removed from .config, so it causes
@@ -482,9 +481,9 @@ class HostSegmentMappingTestCase(SegmentTestCase):
482 481
         # There is no problem when tests are running without debugger.
483 482
         driver_type.register_ml2_drivers_vlan_opts()
484 483
 
485
-        config.cfg.CONF.set_override('network_vlan_ranges',
486
-                                     ['phys_net1', 'phys_net2'],
487
-                                     group='ml2_type_vlan')
484
+        cfg.CONF.set_override('network_vlan_ranges',
485
+                              ['phys_net1', 'phys_net2'],
486
+                              group='ml2_type_vlan')
488 487
         if not plugin:
489 488
             plugin = 'ml2'
490 489
         super(HostSegmentMappingTestCase, self).setUp(plugin=plugin)
@@ -1434,7 +1433,7 @@ class TestSegmentAwareIpamML2(TestSegmentAwareIpam):
1434 1433
         # a problem, when tests are executed with pdb.
1435 1434
         # There is no problem when tests are running without debugger.
1436 1435
         driver_type.register_ml2_drivers_vlan_opts()
1437
-        config.cfg.CONF.set_override(
1436
+        cfg.CONF.set_override(
1438 1437
             'network_vlan_ranges',
1439 1438
             ['physnet:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
1440 1439
              'physnet0:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
@@ -1456,13 +1455,13 @@ class TestNovaSegmentNotifier(SegmentAwareIpamTestCase):
1456 1455
     _mechanism_drivers = ['openvswitch', 'logger']
1457 1456
 
1458 1457
     def setUp(self):
1459
-        config.cfg.CONF.set_override('mechanism_drivers',
1460
-                                     self._mechanism_drivers,
1461
-                                     group='ml2')
1462
-        config.cfg.CONF.set_override('network_vlan_ranges',
1463
-                                     ['physnet:200:209', 'physnet0:200:209',
1464
-                                      'physnet1:200:209', 'physnet2:200:209'],
1465
-                                     group='ml2_type_vlan')
1458
+        cfg.CONF.set_override('mechanism_drivers',
1459
+                              self._mechanism_drivers,
1460
+                              group='ml2')
1461
+        cfg.CONF.set_override('network_vlan_ranges',
1462
+                              ['physnet:200:209', 'physnet0:200:209',
1463
+                               'physnet1:200:209', 'physnet2:200:209'],
1464
+                              group='ml2_type_vlan')
1466 1465
         super(TestNovaSegmentNotifier, self).setUp(plugin='ml2')
1467 1466
         # Need notifier here
1468 1467
         self.patch_notifier.stop()

+ 14
- 14
neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py View File

@@ -17,12 +17,12 @@ import mock
17 17
 from neutron_lib import context
18 18
 from neutron_lib import exceptions as exc
19 19
 from neutron_lib.plugins.ml2 import api
20
+from oslo_config import cfg
20 21
 from six import moves
21 22
 import testtools
22 23
 from testtools import matchers
23 24
 
24 25
 from neutron.plugins.common import constants as p_const
25
-from neutron.plugins.ml2 import config
26 26
 from neutron.plugins.ml2.drivers import type_tunnel
27 27
 
28 28
 TUNNEL_IP_ONE = "10.10.10.10"
@@ -359,7 +359,7 @@ class TunnelRpcCallbackTestMixin(object):
359 359
         self._test_tunnel_sync(kwargs)
360 360
 
361 361
     def test_tunnel_sync_called_with_host_passed_ipv6(self):
362
-        config.cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
362
+        cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
363 363
         kwargs = {'tunnel_ip': TUNNEL_IPV6_ONE, 'tunnel_type': self.TYPE,
364 364
                   'host': HOST_ONE}
365 365
         self._test_tunnel_sync(kwargs)
@@ -402,13 +402,13 @@ class TunnelRpcCallbackTestMixin(object):
402 402
         self._test_tunnel_sync_raises(kwargs)
403 403
 
404 404
     def test_tunnel_sync_called_with_tunnel_overlay_mismatch(self):
405
-        config.cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
405
+        cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
406 406
         kwargs = {'tunnel_ip': TUNNEL_IP_ONE, 'tunnel_type': self.TYPE,
407 407
                   'host': HOST_ONE}
408 408
         self._test_tunnel_sync_raises(kwargs)
409 409
 
410 410
     def test_tunnel_sync_called_with_tunnel_overlay_mismatch_ipv6(self):
411
-        config.cfg.CONF.set_override('overlay_ip_version', 4, group='ml2')
411
+        cfg.CONF.set_override('overlay_ip_version', 4, group='ml2')
412 412
         kwargs = {'tunnel_ip': TUNNEL_IPV6_ONE, 'tunnel_type': self.TYPE,
413 413
                   'host': HOST_ONE}
414 414
         self._test_tunnel_sync_raises(kwargs)
@@ -425,30 +425,30 @@ class TunnelTypeMTUTestMixin(object):
425 425
         self.driver = self.DRIVER_CLASS()
426 426
 
427 427
     def _test_get_mtu(self, ip_version):
428
-        config.cfg.CONF.set_override('overlay_ip_version', ip_version,
429
-                                     group='ml2')
428
+        cfg.CONF.set_override('overlay_ip_version', ip_version,
429
+                              group='ml2')
430 430
         ip_header_length = p_const.IP_HEADER_LENGTH[ip_version]
431 431
 
432
-        config.cfg.CONF.set_override('global_physnet_mtu', 1500)
433
-        config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
432
+        cfg.CONF.set_override('global_physnet_mtu', 1500)
433
+        cfg.CONF.set_override('path_mtu', 1475, group='ml2')
434 434
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
435 435
         self.assertEqual(1475 - self.ENCAP_OVERHEAD - ip_header_length,
436 436
                          self.driver.get_mtu('physnet1'))
437 437
 
438
-        config.cfg.CONF.set_override('global_physnet_mtu', 1450)
439
-        config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
438
+        cfg.CONF.set_override('global_physnet_mtu', 1450)
439
+        cfg.CONF.set_override('path_mtu', 1475, group='ml2')
440 440
         self.driver.physnet_mtus = {'physnet1': 1400, 'physnet2': 1425}
441 441
         self.assertEqual(1450 - self.ENCAP_OVERHEAD - ip_header_length,
442 442
                          self.driver.get_mtu('physnet1'))
443 443
 
444
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
445
-        config.cfg.CONF.set_override('path_mtu', 1450, group='ml2')
444
+        cfg.CONF.set_override('global_physnet_mtu', 0)
445
+        cfg.CONF.set_override('path_mtu', 1450, group='ml2')
446 446
         self.driver.physnet_mtus = {'physnet1': 1425, 'physnet2': 1400}
447 447
         self.assertEqual(1450 - self.ENCAP_OVERHEAD - ip_header_length,
448 448
                          self.driver.get_mtu('physnet1'))
449 449
 
450
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
451
-        config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
450
+        cfg.CONF.set_override('global_physnet_mtu', 0)
451
+        cfg.CONF.set_override('path_mtu', 0, group='ml2')
452 452
         self.driver.physnet_mtus = {}
453 453
         self.assertEqual(0, self.driver.get_mtu('physnet1'))
454 454
 

+ 11
- 11
neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py View File

@@ -16,11 +16,11 @@
16 16
 from neutron_lib import context
17 17
 from neutron_lib import exceptions as exc
18 18
 from neutron_lib.plugins.ml2 import api
19
+from oslo_config import cfg
19 20
 
20 21
 from neutron.common import exceptions as n_exc
21 22
 from neutron.objects.plugins.ml2 import flatallocation as flat_obj
22 23
 from neutron.plugins.common import constants as p_const
23
-from neutron.plugins.ml2 import config
24 24
 from neutron.plugins.ml2.drivers import type_flat
25 25
 from neutron.tests import base
26 26
 from neutron.tests.unit import testlib_api
@@ -35,7 +35,7 @@ class FlatTypeTest(testlib_api.SqlTestCase):
35 35
     def setUp(self):
36 36
         super(FlatTypeTest, self).setUp()
37 37
         self.setup_coreplugin(CORE_PLUGIN)
38
-        config.cfg.CONF.set_override('flat_networks', FLAT_NETWORKS,
38
+        cfg.CONF.set_override('flat_networks', FLAT_NETWORKS,
39 39
                               group='ml2_type_flat')
40 40
         self.driver = type_flat.FlatTypeDriver()
41 41
         self.context = context.Context()
@@ -127,28 +127,28 @@ class FlatTypeTest(testlib_api.SqlTestCase):
127 127
         self.assertIsNone(observed)
128 128
 
129 129
     def test_get_mtu(self):
130
-        config.cfg.CONF.set_override('global_physnet_mtu', 1475)
131
-        config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
130
+        cfg.CONF.set_override('global_physnet_mtu', 1475)
131
+        cfg.CONF.set_override('path_mtu', 1400, group='ml2')
132 132
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
133 133
         self.assertEqual(1450, self.driver.get_mtu('physnet1'))
134 134
 
135
-        config.cfg.CONF.set_override('global_physnet_mtu', 1375)
136
-        config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
135
+        cfg.CONF.set_override('global_physnet_mtu', 1375)
136
+        cfg.CONF.set_override('path_mtu', 1400, group='ml2')
137 137
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
138 138
         self.assertEqual(1375, self.driver.get_mtu('physnet1'))
139 139
 
140
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
141
-        config.cfg.CONF.set_override('path_mtu', 1425, group='ml2')
140
+        cfg.CONF.set_override('global_physnet_mtu', 0)
141
+        cfg.CONF.set_override('path_mtu', 1425, group='ml2')
142 142
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
143 143
         self.assertEqual(1400, self.driver.get_mtu('physnet2'))
144 144
 
145
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
146
-        config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
145
+        cfg.CONF.set_override('global_physnet_mtu', 0)
146
+        cfg.CONF.set_override('path_mtu', 0, group='ml2')
147 147
         self.driver.physnet_mtus = {}
148 148
         self.assertEqual(0, self.driver.get_mtu('physnet1'))
149 149
 
150 150
     def test_parse_physical_network_mtus(self):
151
-        config.cfg.CONF.set_override(
151
+        cfg.CONF.set_override(
152 152
             'physical_network_mtus',
153 153
             ['physnet1:1500', 'physnet2:1500', 'physnet3:9000'],
154 154
             group='ml2')

+ 18
- 18
neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py View File

@@ -17,13 +17,13 @@ import mock
17 17
 from neutron_lib import context
18 18
 from neutron_lib import exceptions as exc
19 19
 from neutron_lib.plugins.ml2 import api
20
+from oslo_config import cfg
20 21
 from testtools import matchers
21 22
 
22 23
 from neutron.db import api as db_api
23 24
 from neutron.objects.plugins.ml2 import vlanallocation as vlan_alloc_obj
24 25
 from neutron.plugins.common import constants as p_const
25 26
 from neutron.plugins.common import utils as plugin_utils
26
-from neutron.plugins.ml2 import config
27 27
 from neutron.plugins.ml2.drivers import type_vlan
28 28
 from neutron.tests.unit import testlib_api
29 29
 
@@ -44,9 +44,9 @@ class VlanTypeTest(testlib_api.SqlTestCase):
44 44
 
45 45
     def setUp(self):
46 46
         super(VlanTypeTest, self).setUp()
47
-        config.cfg.CONF.set_override('network_vlan_ranges',
48
-                                     NETWORK_VLAN_RANGES,
49
-                                     group='ml2_type_vlan')
47
+        cfg.CONF.set_override('network_vlan_ranges',
48
+                              NETWORK_VLAN_RANGES,
49
+                              group='ml2_type_vlan')
50 50
         self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
51 51
             NETWORK_VLAN_RANGES)
52 52
         self.driver = type_vlan.VlanTypeDriver()
@@ -218,23 +218,23 @@ class VlanTypeTest(testlib_api.SqlTestCase):
218 218
                           segment)
219 219
 
220 220
     def test_get_mtu(self):
221
-        config.cfg.CONF.set_override('global_physnet_mtu', 1475)
222
-        config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
221
+        cfg.CONF.set_override('global_physnet_mtu', 1475)
222
+        cfg.CONF.set_override('path_mtu', 1400, group='ml2')
223 223
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
224 224
         self.assertEqual(1450, self.driver.get_mtu('physnet1'))
225 225
 
226
-        config.cfg.CONF.set_override('global_physnet_mtu', 1375)
227
-        config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
226
+        cfg.CONF.set_override('global_physnet_mtu', 1375)
227
+        cfg.CONF.set_override('path_mtu', 1400, group='ml2')
228 228
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
229 229
         self.assertEqual(1375, self.driver.get_mtu('physnet1'))
230 230
 
231
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
232
-        config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
231
+        cfg.CONF.set_override('global_physnet_mtu', 0)
232
+        cfg.CONF.set_override('path_mtu', 1400, group='ml2')
233 233
         self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
234 234
         self.assertEqual(1450, self.driver.get_mtu('physnet1'))
235 235
 
236
-        config.cfg.CONF.set_override('global_physnet_mtu', 0)
237
-        config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
236
+        cfg.CONF.set_override('global_physnet_mtu', 0)
237
+        cfg.CONF.set_override('path_mtu', 0, group='ml2')
238 238
         self.driver.physnet_mtus = {}
239 239
         self.assertEqual(0, self.driver.get_mtu('physnet1'))
240 240
 
@@ -276,17 +276,17 @@ class VlanTypeAllocationTest(testlib_api.SqlTestCase):
276 276
 
277 277
     def test_allocate_tenant_segment_in_order_of_config(self):
278 278
         ranges = NETWORK_VLAN_RANGES + ['phys_net3:20:30']
279
-        config.cfg.CONF.set_override('network_vlan_ranges',
280
-                                     ranges,
281
-                                     group='ml2_type_vlan')
279
+        cfg.CONF.set_override('network_vlan_ranges',
280
+                              ranges,
281
+                              group='ml2_type_vlan')
282 282
         driver = type_vlan.VlanTypeDriver()
283 283
         driver.physnet_mtus = []
284 284
         driver._sync_vlan_allocations()
285 285
         # swap config order from DB order after sync has happened to
286 286
         # ensure config order is followed and not DB order
287
-        config.cfg.CONF.set_override('network_vlan_ranges',
288
-                                     list(reversed(ranges)),
289
-                                     group='ml2_type_vlan')
287
+        cfg.CONF.set_override('network_vlan_ranges',
288
+                              list(reversed(ranges)),
289
+                              group='ml2_type_vlan')
290 290
         driver._parse_network_vlan_ranges()
291 291
         ctx = context.Context()
292 292
         for vlan in range(11):

+ 4
- 4
neutron/tests/unit/plugins/ml2/extensions/test_data_plane_status.py View File

@@ -19,8 +19,8 @@ from neutron_lib.api.definitions import port as port_def
19 19
 from neutron_lib import constants
20 20
 from neutron_lib import context
21 21
 from neutron_lib.plugins import directory
22
+from oslo_config import cfg
22 23
 
23
-from neutron.plugins.ml2 import config
24 24
 from neutron.plugins.ml2.extensions import data_plane_status
25 25
 from neutron.tests.unit.plugins.ml2 import test_plugin
26 26
 
@@ -30,9 +30,9 @@ class DataPlaneStatusSML2ExtDriverTestCase(test_plugin.Ml2PluginV2TestCase):
30 30
     _extension_drivers = ['data_plane_status']
31 31
 
32 32
     def setUp(self):
33
-        config.cfg.CONF.set_override('extension_drivers',
34
-                                     self._extension_drivers,
35
-                                     group='ml2')
33
+        cfg.CONF.set_override('extension_drivers',
34
+                              self._extension_drivers,
35
+                              group='ml2')
36 36
         super(DataPlaneStatusSML2ExtDriverTestCase, self).setUp()
37 37
         self.plugin = directory.get_plugin()
38 38
 

+ 74
- 75
neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py View File

@@ -21,12 +21,12 @@ from neutron_lib.api.definitions import provider_net as pnet
21 21
 from neutron_lib import constants
22 22
 from neutron_lib import context
23 23
 from neutron_lib.plugins import directory
24
+from oslo_config import cfg
24 25
 from oslo_utils import uuidutils
25 26
 import testtools
26 27
 
27 28
 from neutron.extensions import dns
28 29
 from neutron.objects import ports as port_obj
29
-from neutron.plugins.ml2 import config
30 30
 from neutron.plugins.ml2.extensions import dns_integration
31 31
 from neutron.services.externaldns.drivers.designate import driver
32 32
 from neutron.tests.unit.plugins.ml2 import test_plugin
@@ -52,17 +52,17 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
52 52
     _domain = DNSDOMAIN
53 53
 
54 54
     def setUp(self):
55
-        config.cfg.CONF.set_override('extension_drivers',
56
-                                     self._extension_drivers,
57
-                                     group='ml2')
58
-        config.cfg.CONF.set_override('external_dns_driver', 'designate')
55
+        cfg.CONF.set_override('extension_drivers',
56
+                              self._extension_drivers,
57
+                              group='ml2')
58
+        cfg.CONF.set_override('external_dns_driver', 'designate')
59 59
         mock_client.reset_mock()
60 60
         mock_admin_client.reset_mock()
61 61
         super(DNSIntegrationTestCase, self).setUp()
62 62
         dns_integration.DNS_DRIVER = None
63 63
         dns_integration.subscribe()
64 64
         self.plugin = directory.get_plugin()
65
-        config.cfg.CONF.set_override('dns_domain', self._domain)
65
+        cfg.CONF.set_override('dns_domain', self._domain)
66 66
 
67 67
     def _create_port_for_test(self, provider_net=True, dns_domain=True,
68 68
                               dns_name=True, ipv4=True, ipv6=True,
@@ -257,9 +257,9 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
257 257
         if 'in-addr.arpa' in in_addr_name:
258 258
             return ((
259 259
                 constants.IPv4_BITS -
260
-                config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
260
+                cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
261 261
         return (constants.IPv6_BITS -
262
-                config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
262
+                cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
263 263
 
264 264
     def test_create_port(self, *mocks):
265 265
         port, dns_data_db = self._create_port_for_test()
@@ -278,7 +278,7 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
278 278
         self._verify_port_dns(port, dns_data_db, dns_domain=False)
279 279
 
280 280
     def test_create_port_no_dns_driver(self, *mocks):
281
-        config.cfg.CONF.set_override('external_dns_driver', '')
281
+        cfg.CONF.set_override('external_dns_driver', '')
282 282
         port, dns_data_db = self._create_port_for_test()
283 283
         self._verify_port_dns(port, dns_data_db, dns_driver=False)
284 284
 
@@ -291,12 +291,12 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
291 291
         self._verify_port_dns(port, dns_data_db)
292 292
 
293 293
     def test_create_port_no_ptr_zones(self, *mocks):
294
-        config.cfg.CONF.set_override('allow_reverse_dns_lookup', False,
295
-                                     group='designate')
294
+        cfg.CONF.set_override(
295
+            'allow_reverse_dns_lookup', False, group='designate')
296 296
         port, dns_data_db = self._create_port_for_test()
297 297
         self._verify_port_dns(port, dns_data_db, ptr_zones=False)
298
-        config.cfg.CONF.set_override('allow_reverse_dns_lookup', True,
299
-                                     group='designate')
298
+        cfg.CONF.set_override('allow_reverse_dns_lookup', True,
299
+                              group='designate')
300 300
 
301 301
     def test_update_port(self, *mocks):
302 302
         port, dns_data_db = self._create_port_for_test()
@@ -772,24 +772,24 @@ class TestDesignateClientKeystoneV2(testtools.TestCase):
772 772
 
773 773
     def setUp(self):
774 774
         super(TestDesignateClientKeystoneV2, self).setUp()
775
-        config.cfg.CONF.set_override('url',
776
-                                     self.TEST_URL,
777
-                                     group='designate')
778
-        config.cfg.CONF.set_override('admin_username',
779
-                                     self.TEST_ADMIN_USERNAME,
780
-                                     group='designate')
781
-        config.cfg.CONF.set_override('admin_password',
782
-                                     self.TEST_ADMIN_PASSWORD,
783
-                                     group='designate')
784
-        config.cfg.CONF.set_override('admin_auth_url',
785
-                                     self.TEST_ADMIN_AUTH_URL,
786
-                                     group='designate')
787
-        config.cfg.CONF.set_override('admin_tenant_id',
788
-                                     self.TEST_ADMIN_TENANT_ID,
789
-                                     group='designate')
790
-        config.cfg.CONF.set_override('admin_tenant_name',
791
-                                     self.TEST_ADMIN_TENANT_NAME,
792
-                                     group='designate')
775
+        cfg.CONF.set_override('url',
776
+                              self.TEST_URL,
777
+                              group='designate')
778
+        cfg.CONF.set_override('admin_username',
779
+                              self.TEST_ADMIN_USERNAME,
780
+                              group='designate')
781
+        cfg.CONF.set_override('admin_password',
782
+                              self.TEST_ADMIN_PASSWORD,
783
+                              group='designate')
784
+        cfg.CONF.set_override('admin_auth_url',
785
+                              self.TEST_ADMIN_AUTH_URL,
786
+                              group='designate')
787
+        cfg.CONF.set_override('admin_tenant_id',
788
+                              self.TEST_ADMIN_TENANT_ID,
789
+                              group='designate')
790
+        cfg.CONF.set_override('admin_tenant_name',
791
+                              self.TEST_ADMIN_TENANT_NAME,
792
+                              group='designate')
793 793
 
794 794
         # enforce session recalculation
795 795
         mock.patch.object(driver, '_SESSION', new=None).start()
@@ -802,21 +802,21 @@ class TestDesignateClientKeystoneV2(testtools.TestCase):
802 802
             mock.patch.object(driver.password, 'Password').start())
803 803
 
804 804
     def test_insecure_client(self):
805
-        config.cfg.CONF.set_override('insecure',
806
-                                     True,
807
-                                     group='designate')
805
+        cfg.CONF.set_override('insecure',
806
+                              True,
807
+                              group='designate')
808 808
         driver.get_clients(self.TEST_CONTEXT)
809 809
         self.driver_session.assert_called_with(cert=None,
810 810
                                                timeout=None,
811 811
                                                verify=False)
812 812
 
813 813
     def test_secure_client(self):
814
-        config.cfg.CONF.set_override('insecure',
815
-                                     False,
816
-                                     group='designate')
817
-        config.cfg.CONF.set_override('cafile',
818
-                                     self.TEST_CA_CERT,
819
-                                     group='designate')
814
+        cfg.CONF.set_override('insecure',
815
+                              False,
816
+                              group='designate')
817
+        cfg.CONF.set_override('cafile',
818
+                              self.TEST_CA_CERT,
819
+                              group='designate')
820 820
         driver.get_clients(self.TEST_CONTEXT)
821 821
         self.driver_session.assert_called_with(cert=None,
822 822
                                                timeout=None,
@@ -853,32 +853,31 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
853 853
         # Register the Password auth plugin options,
854 854
         # so we can use CONF.set_override
855 855
         password_option = loading.get_auth_plugin_conf_options('password')
856
-        config.cfg.CONF.register_opts(password_option, group='designate')
856
+        cfg.CONF.register_opts(password_option, group='designate')
857 857
         self.addCleanup(
858
-            config.cfg.CONF.unregister_opts,
859
-            password_option, group='designate')
860
-
861
-        config.cfg.CONF.set_override('url',
862
-                                     self.TEST_URL,
863
-                                     group='designate')
864
-        config.cfg.CONF.set_override('auth_type',
865
-                                     'password',
866
-                                     group='designate')
867
-        config.cfg.CONF.set_override('username',
868
-                                     self.TEST_ADMIN_USERNAME,
869
-                                     group='designate')
870
-        config.cfg.CONF.set_override('password',
871
-                                     self.TEST_ADMIN_PASSWORD,
872
-                                     group='designate')
873
-        config.cfg.CONF.set_override('user_domain_id',
874
-                                     self.TEST_ADMIN_USER_DOMAIN_ID,
875
-                                     group='designate')
876
-        config.cfg.CONF.set_override('project_domain_id',
877
-                                     self.TEST_ADMIN_PROJECT_DOMAIN_ID,
878
-                                     group='designate')
879
-        config.cfg.CONF.set_override('auth_url',
880
-                                     self.TEST_ADMIN_AUTH_URL,
881
-                                     group='designate')
858
+            cfg.CONF.unregister_opts, password_option, group='designate')
859
+
860
+        cfg.CONF.set_override('url',
861
+                              self.TEST_URL,
862
+                              group='designate')
863
+        cfg.CONF.set_override('auth_type',
864
+                              'password',
865
+                              group='designate')
866
+        cfg.CONF.set_override('username',
867
+                              self.TEST_ADMIN_USERNAME,
868
+                              group='designate')
869
+        cfg.CONF.set_override('password',
870
+                              self.TEST_ADMIN_PASSWORD,
871
+                              group='designate')
872
+        cfg.CONF.set_override('user_domain_id',
873
+                              self.TEST_ADMIN_USER_DOMAIN_ID,
874
+                              group='designate')
875
+        cfg.CONF.set_override('project_domain_id',
876
+                              self.TEST_ADMIN_PROJECT_DOMAIN_ID,
877
+                              group='designate')
878
+        cfg.CONF.set_override('auth_url',
879
+                              self.TEST_ADMIN_AUTH_URL,
880
+                              group='designate')
882 881
 
883 882
         # enforce session recalculation
884 883
         mock.patch.object(driver, '_SESSION', new=None).start()
@@ -891,21 +890,21 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
891 890
             mock.patch.object(driver.password, 'Password').start())
892 891
 
893 892
     def test_insecure_client(self):
894
-        config.cfg.CONF.set_override('insecure',
895
-                                     True,
896
-                                     group='designate')
893
+        cfg.CONF.set_override('insecure',
894
+                              True,
895
+                              group='designate')
897 896
         driver.get_clients(self.TEST_CONTEXT)
898 897
         self.driver_session.assert_called_with(cert=None,
899 898
                                                timeout=None,
900 899
                                                verify=False)
901 900
 
902 901
     def test_secure_client(self):
903
-        config.cfg.CONF.set_override('insecure',
904
-                                     False,
905
-                                     group='designate')
906
-        config.cfg.CONF.set_override('cafile',
907
-                                     self.TEST_CA_CERT,
908
-                                     group='designate')
902
+        cfg.CONF.set_override('insecure',
903
+                              False,
904
+                              group='designate')
905
+        cfg.CONF.set_override('cafile',
906
+                              self.TEST_CA_CERT,
907
+                              group='designate')
909 908
         driver.get_clients(self.TEST_CONTEXT)
910 909
         self.driver_session.assert_called_with(cert=None,
911 910
                                                timeout=None,
@@ -913,5 +912,5 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
913 912
 
914 913
     def test_auth_type_password(self):
915 914
         driver.get_clients(self.TEST_CONTEXT)
916
-        self.load_auth.assert_called_with(config.cfg.CONF, 'designate')
915
+        self.load_auth.assert_called_with(cfg.CONF, 'designate')
917 916
         self.password.assert_not_called()

+ 4
- 4
neutron/tests/unit/plugins/ml2/test_ext_portsecurity.py View File

@@ -16,8 +16,8 @@
16 16
 from neutron_lib.api.definitions import port_security as psec
17 17
 from neutron_lib import context
18 18
 from neutron_lib.plugins import directory
19
+from oslo_config import cfg
19 20
 
20
-from neutron.plugins.ml2 import config
21 21
 from neutron.tests.unit.extensions import test_portsecurity as test_psec
22 22
 from neutron.tests.unit.plugins.ml2 import test_plugin
23 23
 
@@ -27,9 +27,9 @@ class PSExtDriverTestCase(test_plugin.Ml2PluginV2TestCase,
27 27
     _extension_drivers = ['port_security']
28 28
 
29 29
     def setUp(self):
30
-        config.cfg.CONF.set_override('extension_drivers',
31
-                                     self._extension_drivers,
32
-                                     group='ml2')
30
+        cfg.CONF.set_override('extension_drivers',
31
+                              self._extension_drivers,
32
+                              group='ml2')
33 33
         super(PSExtDriverTestCase, self).setUp()
34 34
 
35 35
     def test_create_net_port_security_default(self):

+ 7
- 7
neutron/tests/unit/plugins/ml2/test_extension_driver_api.py View File

@@ -13,9 +13,9 @@
13 13
 import mock
14 14
 from neutron_lib import context
15 15
 from neutron_lib.plugins import directory
16
+from oslo_config import cfg
16 17
 from oslo_utils import uuidutils
17 18
 
18
-from neutron.plugins.ml2 import config
19 19
 from neutron.tests.unit.plugins.ml2.drivers import ext_test
20 20
 from neutron.tests.unit.plugins.ml2 import test_plugin
21 21
 
@@ -25,9 +25,9 @@ class ExtensionDriverTestCase(test_plugin.Ml2PluginV2TestCase):
25 25
     _extension_drivers = ['test']
26 26
 
27 27
     def setUp(self):
28
-        config.cfg.CONF.set_override('extension_drivers',
29
-                                     self._extension_drivers,
30
-                                     group='ml2')
28
+        cfg.CONF.set_override('extension_drivers',
29
+                              self._extension_drivers,
30
+                              group='ml2')
31 31
         super(ExtensionDriverTestCase, self).setUp()
32 32
         self._plugin = directory.get_plugin()
33 33
         self._ctxt = context.get_admin_context()
@@ -178,9 +178,9 @@ class DBExtensionDriverTestCase(test_plugin.Ml2PluginV2TestCase):
178 178
     _extension_drivers = ['testdb']
179 179
 
180 180
     def setUp(self):
181
-        config.cfg.CONF.set_override('extension_drivers',
182
-                                     self._extension_drivers,
183
-                                     group='ml2')
181
+        cfg.CONF.set_override('extension_drivers',
182
+                              self._extension_drivers,
183
+                              group='ml2')
184 184
         super(DBExtensionDriverTestCase, self).setUp()
185 185
         self._plugin = directory.get_plugin()
186 186
         self._ctxt = context.get_admin_context()

+ 6
- 7
neutron/tests/unit/plugins/ml2/test_managers.py View File

@@ -17,10 +17,10 @@
17 17
 import mock
18 18
 
19 19
 from neutron_lib.plugins.ml2 import api
20
+from oslo_config import cfg
20 21
 from oslo_db import exception as db_exc
21 22
 
22 23
 from neutron.plugins.ml2.common import exceptions as ml2_exc
23
-from neutron.plugins.ml2 import config
24 24
 from neutron.plugins.ml2 import managers
25 25
 from neutron.tests import base
26 26
 from neutron.tests.unit.plugins.ml2.drivers import mechanism_test
@@ -45,8 +45,8 @@ class TestManagers(base.BaseTestCase):
45 45
     @mock.patch.object(managers.LOG, 'critical')
46 46
     @mock.patch.object(managers.MechanismManager, '_driver_not_loaded')
47 47
     def test__driver_not_found(self, mock_not_loaded, mock_log):
48
-        config.cfg.CONF.set_override('mechanism_drivers', ['invalidmech'],
49
-                                     group='ml2')
48
+        cfg.CONF.set_override('mechanism_drivers', ['invalidmech'],
49
+                              group='ml2')
50 50
         self.assertRaises(SystemExit, managers.MechanismManager)
51 51
         mock_not_loaded.assert_not_called()
52 52
         mock_log.assert_called_once_with("The following mechanism drivers "
@@ -56,8 +56,8 @@ class TestManagers(base.BaseTestCase):
56 56
     @mock.patch.object(managers.LOG, 'critical')
57 57
     @mock.patch.object(managers.MechanismManager, '_driver_not_found')
58 58
     def test__driver_not_loaded(self, mock_not_found, mock_log):
59
-        config.cfg.CONF.set_override('mechanism_drivers', ['faulty_agent'],
60
-                                     group='ml2')
59
+        cfg.CONF.set_override('mechanism_drivers', ['faulty_agent'],
60
+                              group='ml2')
61 61
         self.assertRaises(SystemExit, managers.MechanismManager)
62 62
         mock_log.assert_called_once_with(u"The '%(entrypoint)s' entrypoint "
63 63
                                          "could not be loaded for the "
@@ -68,8 +68,7 @@ class TestManagers(base.BaseTestCase):
68 68
 
69 69
 class TestMechManager(base.BaseTestCase):
70 70
     def setUp(self):
71
-        config.cfg.CONF.set_override('mechanism_drivers', ['test'],
72
-                                     group='ml2')
71
+        cfg.CONF.set_override('mechanism_drivers', ['test'], group='ml2')
73 72
         super(TestMechManager, self).setUp()
74 73
         self._manager = managers.MechanismManager()
75 74
 

+ 32
- 32
neutron/tests/unit/plugins/ml2/test_plugin.py View File

@@ -17,6 +17,7 @@ import functools
17 17
 
18 18
 import fixtures
19 19
 import mock
20
+from oslo_config import cfg
20 21
 import testtools
21 22
 import webob
22 23
 
@@ -49,7 +50,6 @@ from neutron.objects import base as base_obj
49 50
 from neutron.objects import router as l3_obj
50 51
 from neutron.plugins.common import constants as p_const
51 52
 from neutron.plugins.ml2.common import exceptions as ml2_exc
52
-from neutron.plugins.ml2 import config
53 53
 from neutron.plugins.ml2 import db as ml2_db
54 54
 from neutron.plugins.ml2 import driver_context
55 55
 from neutron.plugins.ml2.drivers import type_vlan
@@ -72,9 +72,9 @@ from neutron.tests.unit.plugins.ml2.drivers import mechanism_logger as \
72 72
 from neutron.tests.unit.plugins.ml2.drivers import mechanism_test as mech_test
73 73
 
74 74
 
75
-config.cfg.CONF.import_opt('network_vlan_ranges',
76
-                           'neutron.plugins.ml2.drivers.type_vlan',
77
-                           group='ml2_type_vlan')
75
+cfg.CONF.import_opt('network_vlan_ranges',
76
+                    'neutron.plugins.ml2.drivers.type_vlan',
77
+                    group='ml2_type_vlan')
78 78
 
79 79
 
80 80
 PLUGIN_NAME = 'ml2'
@@ -135,18 +135,18 @@ class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
135 135
         # Enable the test mechanism driver to ensure that
136 136
         # we can successfully call through to all mechanism
137 137
         # driver apis.
138
-        config.cfg.CONF.set_override('mechanism_drivers',
139
-                                     self._mechanism_drivers,
140
-                                     group='ml2')
138
+        cfg.CONF.set_override('mechanism_drivers',
139
+                              self._mechanism_drivers,
140
+                              group='ml2')
141 141
         self.physnet = 'physnet1'
142 142
         self.vlan_range = '1:100'
143 143
         self.vlan_range2 = '200:300'
144 144
         self.physnet2 = 'physnet2'
145 145
         self.phys_vrange = ':'.join([self.physnet, self.vlan_range])
146 146
         self.phys2_vrange = ':'.join([self.physnet2, self.vlan_range2])
147
-        config.cfg.CONF.set_override('network_vlan_ranges',
148
-                                     [self.phys_vrange, self.phys2_vrange],
149
-                                     group='ml2_type_vlan')
147
+        cfg.CONF.set_override('network_vlan_ranges',
148
+                              [self.phys_vrange, self.phys2_vrange],
149
+                              group='ml2_type_vlan')
150 150
         self.setup_parent()
151 151
         self.driver = directory.get_plugin()
152 152
         self.context = context.get_admin_context()
@@ -386,9 +386,9 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
386 386
         return network
387 387
 
388 388
     def test_external_network_type_none(self):
389
-        config.cfg.CONF.set_default('external_network_type',
390
-                                    None,
391
-                                    group='ml2')
389
+        cfg.CONF.set_default('external_network_type',
390
+                             None,
391
+                             group='ml2')
392 392
 
393 393
         network = self._create_external_network()
394 394
         # For external network, expected network type to be
@@ -403,9 +403,9 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
403 403
         self.assertNotIn(mpnet.SEGMENTS, network['network'])
404 404
 
405 405
     def test_external_network_type_vlan(self):
406
-        config.cfg.CONF.set_default('external_network_type',
407
-                                    p_const.TYPE_VLAN,
408
-                                    group='ml2')
406
+        cfg.CONF.set_default('external_network_type',
407
+                             p_const.TYPE_VLAN,
408
+                             group='ml2')
409 409
 
410 410
         network = self._create_external_network()
411 411
         # For external network, expected network type to be 'vlan'.
@@ -428,7 +428,7 @@ class TestMl2NetworksWithVlanTransparencyBase(TestMl2NetworksV2):
428 428
                         'vlan_transparent': 'True'}}
429 429
 
430 430
     def setUp(self, plugin=None):
431
-        config.cfg.CONF.set_override('vlan_transparent', True)
431
+        cfg.CONF.set_override('vlan_transparent', True)
432 432
         super(TestMl2NetworksWithVlanTransparencyBase, self).setUp(plugin)
433 433
 
434 434
 
@@ -466,8 +466,8 @@ class TestMl2NetworksWithVlanTransparencyAndMTU(
466 466
         with mock.patch.object(mech_test.TestMechanismDriver,
467 467
                                'check_vlan_transparency',
468 468
                                return_value=True):
469
-            config.cfg.CONF.set_override('path_mtu', 1000, group='ml2')
470
-            config.cfg.CONF.set_override('global_physnet_mtu', 1000)
469
+            cfg.CONF.set_override('path_mtu', 1000, group='ml2')
470
+            cfg.CONF.set_override('global_physnet_mtu', 1000)
471 471
             network_req = self.new_create_request('networks', self.data)
472 472
             res = network_req.get_response(self.api)
473 473
             self.assertEqual(201, res.status_int)
@@ -1555,7 +1555,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
1555 1555
 
1556 1556
     def setUp(self, firewall_driver=None):
1557 1557
         test_sg_rpc.set_firewall_driver(self.FIREWALL_DRIVER)
1558
-        config.cfg.CONF.set_override(
1558
+        cfg.CONF.set_override(
1559 1559
             'enable_security_group', self.ENABLE_SG,
1560 1560
             group='SECURITYGROUP')
1561 1561
         super(TestMl2PortBinding, self).setUp()
@@ -2150,9 +2150,9 @@ class TestMl2AllowedAddressPairs(Ml2PluginV2TestCase,
2150 2150
     _extension_drivers = ['port_security']
2151 2151
 
2152 2152
     def setUp(self, plugin=None):
2153
-        config.cfg.CONF.set_override('extension_drivers',
2154
-                                     self._extension_drivers,
2155
-                                     group='ml2')
2153
+        cfg.CONF.set_override('extension_drivers',
2154
+                              self._extension_drivers,
2155
+                              group='ml2')
2156 2156
         super(test_pair.TestAllowedAddressPairs, self).setUp(
2157 2157
             plugin=PLUGIN_NAME)
2158 2158
 
@@ -2160,12 +2160,12 @@ class TestMl2AllowedAddressPairs(Ml2PluginV2TestCase,
2160 2160
 class TestMl2PortSecurity(Ml2PluginV2TestCase):
2161 2161
 
2162 2162
     def setUp(self):
2163
-        config.cfg.CONF.set_override('extension_drivers',
2164
-                                     ['port_security'],
2165
-                                     group='ml2')
2166
-        config.cfg.CONF.set_override('enable_security_group',
2167
-                                     False,
2168
-                                     group='SECURITYGROUP')
2163
+        cfg.CONF.set_override('extension_drivers',
2164
+                              ['port_security'],
2165
+                              group='ml2')
2166
+        cfg.CONF.set_override('enable_security_group',
2167
+                              False,
2168
+                              group='SECURITYGROUP')
2169 2169
         super(TestMl2PortSecurity, self).setUp()
2170 2170
 
2171 2171
     def test_port_update_without_security_groups(self):
@@ -2250,9 +2250,9 @@ class Ml2PluginV2FaultyDriverTestCase(test_plugin.NeutronDbPluginV2TestCase):
2250 2250
         # Enable the test mechanism driver to ensure that
2251 2251
         # we can successfully call through to all mechanism
2252 2252
         # driver apis.
2253
-        config.cfg.CONF.set_override('mechanism_drivers',
2254
-                                     ['test', 'logger'],
2255
-                                     group='ml2')
2253
+        cfg.CONF.set_override('mechanism_drivers',
2254
+                              ['test', 'logger'],
2255
+                              group='ml2')
2256 2256
         super(Ml2PluginV2FaultyDriverTestCase, self).setUp(PLUGIN_NAME)
2257 2257
         self.port_create_status = 'DOWN'
2258 2258
 

+ 7
- 7
neutron/tests/unit/plugins/ml2/test_port_binding.py View File

@@ -18,10 +18,10 @@ from neutron_lib.api.definitions import portbindings
18 18
 from neutron_lib import constants as const
19 19
 from neutron_lib import context
20 20
 from neutron_lib.plugins import directory
21
+from oslo_config import cfg
21 22
 from oslo_serialization import jsonutils
22 23
 
23 24
 from neutron.conf.plugins.ml2.drivers import driver_type
24
-from neutron.plugins.ml2 import config
25 25
 from neutron.plugins.ml2 import driver_context
26 26
 from neutron.plugins.ml2 import models as ml2_models
27 27
 from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
@@ -33,18 +33,18 @@ class PortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
33 33
         # Enable the test mechanism driver to ensure that
34 34
         # we can successfully call through to all mechanism
35 35
         # driver apis.
36
-        config.cfg.CONF.set_override('mechanism_drivers',
37
-                                     ['logger', 'test'],
38
-                                     'ml2')
36
+        cfg.CONF.set_override('mechanism_drivers',
37
+                              ['logger', 'test'],
38
+                              'ml2')
39 39
 
40 40
         # NOTE(dasm): ml2_type_vlan requires to be registered before used.
41 41
         # This piece was refactored and removed from .config, so it causes
42 42
         # a problem, when tests are executed with pdb.
43 43
         # There is no problem when tests are running without debugger.
44 44
         driver_type.register_ml2_drivers_vlan_opts()
45
-        config.cfg.CONF.set_override('network_vlan_ranges',
46
-                                     ['physnet1:1000:1099'],
47
-                                     group='ml2_type_vlan')
45
+        cfg.CONF.set_override('network_vlan_ranges',
46
+                              ['physnet1:1000:1099'],
47
+                              group='ml2_type_vlan')
48 48
         super(PortBindingTestCase, self).setUp('ml2')
49 49
         self.port_create_status = 'DOWN'
50 50
         self.plugin = directory.get_plugin()

+ 1
- 1
neutron/tests/unit/plugins/ml2/test_rpc.py View File

@@ -38,7 +38,7 @@ from neutron.services.qos import qos_consts
38 38
 from neutron.tests import base
39 39
 
40 40
 
41
-cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config')
41
+cfg.CONF.import_group('ml2', 'neutron.conf.plugins.ml2.config')
42 42
 
43 43
 
44 44
 class RpcCallbacksTestCase(base.BaseTestCase):

+ 4
- 4
neutron/tests/unit/services/revisions/test_revision_plugin.py View File

@@ -17,6 +17,7 @@ import netaddr
17 17
 from neutron_lib import context as nctx
18 18
 from neutron_lib.plugins import constants
19 19
 from neutron_lib.plugins import directory
20
+from oslo_config import cfg
20 21
 from oslo_db import exception as db_exc
21 22
 from oslo_utils import uuidutils
22 23
 from sqlalchemy.orm import session as se
@@ -25,7 +26,6 @@ from webob import exc
25 26
 from neutron.db import api as db_api
26 27
 from neutron.db import models_v2
27 28
 from neutron.objects import ports as port_obj
28
-from neutron.plugins.ml2 import config
29 29
 from neutron.tests.unit.plugins.ml2 import test_plugin
30 30
 
31 31
 
@@ -44,9 +44,9 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase):
44 44
         return p
45 45
 
46 46
     def setUp(self):
47
-        config.cfg.CONF.set_override('extension_drivers',
48
-                                     self._extension_drivers,
49
-                                     group='ml2')
47
+        cfg.CONF.set_override('extension_drivers',
48
+                              self._extension_drivers,
49
+                              group='ml2')
50 50
         super(TestRevisionPlugin, self).setUp()
51 51
         self.cp = directory.get_plugin()
52 52
         self.l3p = directory.get_plugin(constants.L3)

Loading…
Cancel
Save