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
changes/28/340228/43
Aradhana Singh 6 years ago committed by Brian Haley
parent 51ca683797
commit d00a50aad1
  1. 2
      neutron/cmd/sanity_check.py
  2. 3
      neutron/conf/plugins/ml2/config.py
  3. 4
      neutron/opts.py
  4. 2
      neutron/plugins/ml2/managers.py
  5. 1
      neutron/plugins/ml2/plugin.py
  6. 7
      neutron/tests/unit/extensions/test_dns.py
  7. 31
      neutron/tests/unit/extensions/test_l3.py
  8. 29
      neutron/tests/unit/extensions/test_segment.py
  9. 28
      neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py
  10. 22
      neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py
  11. 36
      neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
  12. 8
      neutron/tests/unit/plugins/ml2/extensions/test_data_plane_status.py
  13. 149
      neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py
  14. 8
      neutron/tests/unit/plugins/ml2/test_ext_portsecurity.py
  15. 14
      neutron/tests/unit/plugins/ml2/test_extension_driver_api.py
  16. 13
      neutron/tests/unit/plugins/ml2/test_managers.py
  17. 64
      neutron/tests/unit/plugins/ml2/test_plugin.py
  18. 14
      neutron/tests/unit/plugins/ml2/test_port_binding.py
  19. 2
      neutron/tests/unit/plugins/ml2/test_rpc.py
  20. 8
      neutron/tests/unit/services/revisions/test_revision_plugin.py

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

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

@ -33,6 +33,7 @@ import neutron.conf.agent.xenapi_conf
import neutron.conf.cache_utils
import neutron.conf.common
import neutron.conf.extensions.allowedaddresspairs
import neutron.conf.plugins.ml2.config
import neutron.conf.plugins.ml2.drivers.agent
import neutron.conf.plugins.ml2.drivers.driver_type
import neutron.conf.plugins.ml2.drivers.linuxbridge
@ -54,7 +55,6 @@ import neutron.db.l3_hamode_db
import neutron.db.migration.cli
import neutron.extensions.l3
import neutron.extensions.securitygroup
import neutron.plugins.ml2.config
import neutron.plugins.ml2.drivers.mech_sriov.agent.common.config
import neutron.wsgi
@ -235,7 +235,7 @@ def list_metering_agent_opts():
def list_ml2_conf_opts():
return [
('ml2',
neutron.plugins.ml2.config.ml2_opts),
neutron.conf.plugins.ml2.config.ml2_opts),
('ml2_type_flat',
neutron.conf.plugins.ml2.drivers.driver_type.flat_opts),
('ml2_type_vlan',

@ -25,6 +25,7 @@ from oslo_utils import excutils
import stevedore
from neutron._i18n import _
from neutron.conf.plugins.ml2 import config
from neutron.db import api as db_api
from neutron.db import segments_db
from neutron.extensions import external_net
@ -37,6 +38,7 @@ from neutron.plugins.ml2 import models
LOG = log.getLogger(__name__)
MAX_BINDING_LEVELS = 10
config.register_ml2_plugin_opts()
class TypeManager(stevedore.named.NamedExtensionManager):

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

@ -23,7 +23,6 @@ from oslo_config import cfg
from neutron.common import utils
from neutron.db import db_base_plugin_v2
from neutron.extensions import dns
from neutron.plugins.ml2 import config
from neutron.tests.unit.db import test_db_base_plugin_v2
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -57,9 +56,9 @@ class DnsExtensionTestCase(test_plugin.Ml2PluginV2TestCase):
_extension_drivers = ['dns']
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(DnsExtensionTestCase, self).setUp()
def _create_network(self, fmt, name, admin_state_up,

@ -55,7 +55,6 @@ from neutron.db import models_v2
from neutron.extensions import dns
from neutron.extensions import external_net
from neutron.extensions import l3
from neutron.plugins.ml2 import config
from neutron.services.revisions import revision_plugin
from neutron.tests import base
from neutron.tests.common import helpers
@ -4004,12 +4003,12 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
def setUp(self):
ext_mgr = L3TestExtensionManagerWithDNS()
plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(L3NatDBFloatingIpTestCaseWithDNS, self).setUp(plugin=plugin,
ext_mgr=ext_mgr)
config.cfg.CONF.set_override('external_dns_driver', 'designate')
cfg.CONF.set_override('external_dns_driver', 'designate')
self.mock_client.reset_mock()
self.mock_admin_client.reset_mock()
@ -4096,8 +4095,8 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
def _get_bytes_or_nybles_to_skip(self, in_addr_name):
if 'in-addr.arpa' in in_addr_name:
return ((
32 - config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return (128 - config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
32 - cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return (128 - cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
def _get_in_addr(self, record):
in_addr_name = netaddr.IPAddress(record).reverse_dns
@ -4133,7 +4132,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
@mock.patch(MOCK_PATH, **mock_config)
def test_floatingip_create_with_net_port_dns(self, mock_args):
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns(net_dns_domain=self.DNS_DOMAIN,
port_dns_name=self.DNS_NAME, assoc_port=True) as flip:
floatingip = flip
@ -4143,7 +4142,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
def test_floatingip_create_with_flip_and_net_port_dns(self, mock_args):
# If both network+port and the floating ip have dns domain and
# dns name, floating ip's information should take priority
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns(net_dns_domain='junkdomain.org.',
port_dns_name='junk', flip_dns_domain=self.DNS_DOMAIN,
flip_dns_name=self.DNS_NAME, assoc_port=True) as flip:
@ -4173,7 +4172,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
@mock.patch(MOCK_PATH, **mock_config)
def test_floatingip_associate_port_with_net_port_dns(self, mock_args):
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns_on_update(
net_dns_domain=self.DNS_DOMAIN,
port_dns_name=self.DNS_NAME) as flip:
@ -4185,7 +4184,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
mock_args):
# If both network+port and the floating ip have dns domain and
# dns name, floating ip's information should take priority
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns_on_update(
net_dns_domain='junkdomain.org.',
port_dns_name='junk',
@ -4198,7 +4197,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
@mock.patch(MOCK_PATH, **mock_config)
def test_floatingip_disassociate_port(self, mock_args):
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns(net_dns_domain=self.DNS_DOMAIN,
port_dns_name=self.DNS_NAME, assoc_port=True) as flip:
fake_recordset = {'id': '',
@ -4224,7 +4223,7 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
@mock.patch(MOCK_PATH, **mock_config)
def test_floatingip_delete(self, mock_args):
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
with self._create_floatingip_with_dns(flip_dns_domain=self.DNS_DOMAIN,
flip_dns_name=self.DNS_NAME) as flip:
floatingip = flip
@ -4243,13 +4242,13 @@ class L3NatDBFloatingIpTestCaseWithDNS(L3BaseForSepTests, L3NatTestCaseMixin):
@mock.patch(MOCK_PATH, **mock_config)
def test_floatingip_no_PTR_record(self, mock_args):
config.cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
cfg.CONF.set_override('dns_domain', self.DNS_DOMAIN)
# Disabling this option should stop the admin client from creating
# PTR records. So set this option and make sure the admin client
# wasn't called to create any records
config.cfg.CONF.set_override('allow_reverse_dns_lookup', False,
group='designate')
cfg.CONF.set_override('allow_reverse_dns_lookup', False,
group='designate')
with self._create_floatingip_with_dns(flip_dns_domain=self.DNS_DOMAIN,
flip_dns_name=self.DNS_NAME) as flip:

@ -44,7 +44,6 @@ from neutron.extensions import l2_adjacency
from neutron.extensions import segment as ext_segment
from neutron.objects import network
from neutron.plugins.common import constants as p_constants
from neutron.plugins.ml2 import config
from neutron.services.segments import db
from neutron.services.segments import exceptions as segment_exc
from neutron.services.segments import placement_client
@ -472,9 +471,9 @@ class HostSegmentMappingTestCase(SegmentTestCase):
_mechanism_drivers = ['logger']
def setUp(self, plugin=None):
config.cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
# NOTE(dasm): ml2_type_vlan requires to be registered before used.
# This piece was refactored and removed from .config, so it causes
@ -482,9 +481,9 @@ class HostSegmentMappingTestCase(SegmentTestCase):
# There is no problem when tests are running without debugger.
driver_type.register_ml2_drivers_vlan_opts()
config.cfg.CONF.set_override('network_vlan_ranges',
['phys_net1', 'phys_net2'],
group='ml2_type_vlan')
cfg.CONF.set_override('network_vlan_ranges',
['phys_net1', 'phys_net2'],
group='ml2_type_vlan')
if not plugin:
plugin = 'ml2'
super(HostSegmentMappingTestCase, self).setUp(plugin=plugin)
@ -1434,7 +1433,7 @@ class TestSegmentAwareIpamML2(TestSegmentAwareIpam):
# a problem, when tests are executed with pdb.
# There is no problem when tests are running without debugger.
driver_type.register_ml2_drivers_vlan_opts()
config.cfg.CONF.set_override(
cfg.CONF.set_override(
'network_vlan_ranges',
['physnet:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
'physnet0:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
@ -1456,13 +1455,13 @@ class TestNovaSegmentNotifier(SegmentAwareIpamTestCase):
_mechanism_drivers = ['openvswitch', 'logger']
def setUp(self):
config.cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
config.cfg.CONF.set_override('network_vlan_ranges',
['physnet:200:209', 'physnet0:200:209',
'physnet1:200:209', 'physnet2:200:209'],
group='ml2_type_vlan')
cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
cfg.CONF.set_override('network_vlan_ranges',
['physnet:200:209', 'physnet0:200:209',
'physnet1:200:209', 'physnet2:200:209'],
group='ml2_type_vlan')
super(TestNovaSegmentNotifier, self).setUp(plugin='ml2')
# Need notifier here
self.patch_notifier.stop()

@ -17,12 +17,12 @@ import mock
from neutron_lib import context
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
from six import moves
import testtools
from testtools import matchers
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_tunnel
TUNNEL_IP_ONE = "10.10.10.10"
@ -359,7 +359,7 @@ class TunnelRpcCallbackTestMixin(object):
self._test_tunnel_sync(kwargs)
def test_tunnel_sync_called_with_host_passed_ipv6(self):
config.cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
kwargs = {'tunnel_ip': TUNNEL_IPV6_ONE, 'tunnel_type': self.TYPE,
'host': HOST_ONE}
self._test_tunnel_sync(kwargs)
@ -402,13 +402,13 @@ class TunnelRpcCallbackTestMixin(object):
self._test_tunnel_sync_raises(kwargs)
def test_tunnel_sync_called_with_tunnel_overlay_mismatch(self):
config.cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
cfg.CONF.set_override('overlay_ip_version', 6, group='ml2')
kwargs = {'tunnel_ip': TUNNEL_IP_ONE, 'tunnel_type': self.TYPE,
'host': HOST_ONE}
self._test_tunnel_sync_raises(kwargs)
def test_tunnel_sync_called_with_tunnel_overlay_mismatch_ipv6(self):
config.cfg.CONF.set_override('overlay_ip_version', 4, group='ml2')
cfg.CONF.set_override('overlay_ip_version', 4, group='ml2')
kwargs = {'tunnel_ip': TUNNEL_IPV6_ONE, 'tunnel_type': self.TYPE,
'host': HOST_ONE}
self._test_tunnel_sync_raises(kwargs)
@ -425,30 +425,30 @@ class TunnelTypeMTUTestMixin(object):
self.driver = self.DRIVER_CLASS()
def _test_get_mtu(self, ip_version):
config.cfg.CONF.set_override('overlay_ip_version', ip_version,
group='ml2')
cfg.CONF.set_override('overlay_ip_version', ip_version,
group='ml2')
ip_header_length = p_const.IP_HEADER_LENGTH[ip_version]
config.cfg.CONF.set_override('global_physnet_mtu', 1500)
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1500)
cfg.CONF.set_override('path_mtu', 1475, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1475 - self.ENCAP_OVERHEAD - ip_header_length,
self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 1450)
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1450)
cfg.CONF.set_override('path_mtu', 1475, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1400, 'physnet2': 1425}
self.assertEqual(1450 - self.ENCAP_OVERHEAD - ip_header_length,
self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 1450, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 1450, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1425, 'physnet2': 1400}
self.assertEqual(1450 - self.ENCAP_OVERHEAD - ip_header_length,
self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 0, group='ml2')
self.driver.physnet_mtus = {}
self.assertEqual(0, self.driver.get_mtu('physnet1'))

@ -16,11 +16,11 @@
from neutron_lib import context
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
from neutron.common import exceptions as n_exc
from neutron.objects.plugins.ml2 import flatallocation as flat_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_flat
from neutron.tests import base
from neutron.tests.unit import testlib_api
@ -35,7 +35,7 @@ class FlatTypeTest(testlib_api.SqlTestCase):
def setUp(self):
super(FlatTypeTest, self).setUp()
self.setup_coreplugin(CORE_PLUGIN)
config.cfg.CONF.set_override('flat_networks', FLAT_NETWORKS,
cfg.CONF.set_override('flat_networks', FLAT_NETWORKS,
group='ml2_type_flat')
self.driver = type_flat.FlatTypeDriver()
self.context = context.Context()
@ -127,28 +127,28 @@ class FlatTypeTest(testlib_api.SqlTestCase):
self.assertIsNone(observed)
def test_get_mtu(self):
config.cfg.CONF.set_override('global_physnet_mtu', 1475)
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1475)
cfg.CONF.set_override('path_mtu', 1400, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 1375)
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1375)
cfg.CONF.set_override('path_mtu', 1400, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1375, self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 1425, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 1425, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1400, self.driver.get_mtu('physnet2'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 0, group='ml2')
self.driver.physnet_mtus = {}
self.assertEqual(0, self.driver.get_mtu('physnet1'))
def test_parse_physical_network_mtus(self):
config.cfg.CONF.set_override(
cfg.CONF.set_override(
'physical_network_mtus',
['physnet1:1500', 'physnet2:1500', 'physnet3:9000'],
group='ml2')

@ -17,13 +17,13 @@ import mock
from neutron_lib import context
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
from testtools import matchers
from neutron.db import api as db_api
from neutron.objects.plugins.ml2 import vlanallocation as vlan_alloc_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_vlan
from neutron.tests.unit import testlib_api
@ -44,9 +44,9 @@ class VlanTypeTest(testlib_api.SqlTestCase):
def setUp(self):
super(VlanTypeTest, self).setUp()
config.cfg.CONF.set_override('network_vlan_ranges',
NETWORK_VLAN_RANGES,
group='ml2_type_vlan')
cfg.CONF.set_override('network_vlan_ranges',
NETWORK_VLAN_RANGES,
group='ml2_type_vlan')
self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
NETWORK_VLAN_RANGES)
self.driver = type_vlan.VlanTypeDriver()
@ -218,23 +218,23 @@ class VlanTypeTest(testlib_api.SqlTestCase):
segment)
def test_get_mtu(self):
config.cfg.CONF.set_override('global_physnet_mtu', 1475)
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1475)
cfg.CONF.set_override('path_mtu', 1400, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 1375)
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1375)
cfg.CONF.set_override('path_mtu', 1400, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1375, self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 1400, group='ml2')
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
config.cfg.CONF.set_override('global_physnet_mtu', 0)
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 0)
cfg.CONF.set_override('path_mtu', 0, group='ml2')
self.driver.physnet_mtus = {}
self.assertEqual(0, self.driver.get_mtu('physnet1'))
@ -276,17 +276,17 @@ class VlanTypeAllocationTest(testlib_api.SqlTestCase):
def test_allocate_tenant_segment_in_order_of_config(self):
ranges = NETWORK_VLAN_RANGES + ['phys_net3:20:30']
config.cfg.CONF.set_override('network_vlan_ranges',
ranges,
group='ml2_type_vlan')
cfg.CONF.set_override('network_vlan_ranges',
ranges,
group='ml2_type_vlan')
driver = type_vlan.VlanTypeDriver()
driver.physnet_mtus = []
driver._sync_vlan_allocations()
# swap config order from DB order after sync has happened to
# ensure config order is followed and not DB order
config.cfg.CONF.set_override('network_vlan_ranges',
list(reversed(ranges)),
group='ml2_type_vlan')
cfg.CONF.set_override('network_vlan_ranges',
list(reversed(ranges)),
group='ml2_type_vlan')
driver._parse_network_vlan_ranges()
ctx = context.Context()
for vlan in range(11):

@ -19,8 +19,8 @@ from neutron_lib.api.definitions import port as port_def
from neutron_lib import constants
from neutron_lib import context
from neutron_lib.plugins import directory
from oslo_config import cfg
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.extensions import data_plane_status
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -30,9 +30,9 @@ class DataPlaneStatusSML2ExtDriverTestCase(test_plugin.Ml2PluginV2TestCase):
_extension_drivers = ['data_plane_status']
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(DataPlaneStatusSML2ExtDriverTestCase, self).setUp()
self.plugin = directory.get_plugin()

@ -21,12 +21,12 @@ from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib import constants
from neutron_lib import context
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_utils import uuidutils
import testtools
from neutron.extensions import dns
from neutron.objects import ports as port_obj
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.extensions import dns_integration
from neutron.services.externaldns.drivers.designate import driver
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -52,17 +52,17 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
_domain = DNSDOMAIN
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
config.cfg.CONF.set_override('external_dns_driver', 'designate')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('external_dns_driver', 'designate')
mock_client.reset_mock()
mock_admin_client.reset_mock()
super(DNSIntegrationTestCase, self).setUp()
dns_integration.DNS_DRIVER = None
dns_integration.subscribe()
self.plugin = directory.get_plugin()
config.cfg.CONF.set_override('dns_domain', self._domain)
cfg.CONF.set_override('dns_domain', self._domain)
def _create_port_for_test(self, provider_net=True, dns_domain=True,
dns_name=True, ipv4=True, ipv6=True,
@ -257,9 +257,9 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
if 'in-addr.arpa' in in_addr_name:
return ((
constants.IPv4_BITS -
config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return (constants.IPv6_BITS -
config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
def test_create_port(self, *mocks):
port, dns_data_db = self._create_port_for_test()
@ -278,7 +278,7 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
self._verify_port_dns(port, dns_data_db, dns_domain=False)
def test_create_port_no_dns_driver(self, *mocks):
config.cfg.CONF.set_override('external_dns_driver', '')
cfg.CONF.set_override('external_dns_driver', '')
port, dns_data_db = self._create_port_for_test()
self._verify_port_dns(port, dns_data_db, dns_driver=False)
@ -291,12 +291,12 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
self._verify_port_dns(port, dns_data_db)
def test_create_port_no_ptr_zones(self, *mocks):
config.cfg.CONF.set_override('allow_reverse_dns_lookup', False,
group='designate')
cfg.CONF.set_override(
'allow_reverse_dns_lookup', False, group='designate')
port, dns_data_db = self._create_port_for_test()
self._verify_port_dns(port, dns_data_db, ptr_zones=False)
config.cfg.CONF.set_override('allow_reverse_dns_lookup', True,
group='designate')
cfg.CONF.set_override('allow_reverse_dns_lookup', True,
group='designate')
def test_update_port(self, *mocks):
port, dns_data_db = self._create_port_for_test()
@ -772,24 +772,24 @@ class TestDesignateClientKeystoneV2(testtools.TestCase):
def setUp(self):
super(TestDesignateClientKeystoneV2, self).setUp()
config.cfg.CONF.set_override('url',
self.TEST_URL,
group='designate')
config.cfg.CONF.set_override('admin_username',
self.TEST_ADMIN_USERNAME,
group='designate')
config.cfg.CONF.set_override('admin_password',
self.TEST_ADMIN_PASSWORD,
group='designate')
config.cfg.CONF.set_override('admin_auth_url',
self.TEST_ADMIN_AUTH_URL,
group='designate')
config.cfg.CONF.set_override('admin_tenant_id',
self.TEST_ADMIN_TENANT_ID,
group='designate')
config.cfg.CONF.set_override('admin_tenant_name',
self.TEST_ADMIN_TENANT_NAME,
group='designate')
cfg.CONF.set_override('url',
self.TEST_URL,
group='designate')
cfg.CONF.set_override('admin_username',
self.TEST_ADMIN_USERNAME,
group='designate')
cfg.CONF.set_override('admin_password',
self.TEST_ADMIN_PASSWORD,
group='designate')
cfg.CONF.set_override('admin_auth_url',
self.TEST_ADMIN_AUTH_URL,
group='designate')
cfg.CONF.set_override('admin_tenant_id',
self.TEST_ADMIN_TENANT_ID,
group='designate')
cfg.CONF.set_override('admin_tenant_name',
self.TEST_ADMIN_TENANT_NAME,
group='designate')
# enforce session recalculation
mock.patch.object(driver, '_SESSION', new=None).start()
@ -802,21 +802,21 @@ class TestDesignateClientKeystoneV2(testtools.TestCase):
mock.patch.object(driver.password, 'Password').start())
def test_insecure_client(self):
config.cfg.CONF.set_override('insecure',
True,
group='designate')
cfg.CONF.set_override('insecure',
True,
group='designate')
driver.get_clients(self.TEST_CONTEXT)
self.driver_session.assert_called_with(cert=None,
timeout=None,
verify=False)
def test_secure_client(self):
config.cfg.CONF.set_override('insecure',
False,
group='designate')
config.cfg.CONF.set_override('cafile',
self.TEST_CA_CERT,
group='designate')
cfg.CONF.set_override('insecure',
False,
group='designate')
cfg.CONF.set_override('cafile',
self.TEST_CA_CERT,
group='designate')
driver.get_clients(self.TEST_CONTEXT)
self.driver_session.assert_called_with(cert=None,
timeout=None,
@ -853,32 +853,31 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
# Register the Password auth plugin options,
# so we can use CONF.set_override
password_option = loading.get_auth_plugin_conf_options('password')
config.cfg.CONF.register_opts(password_option, group='designate')
cfg.CONF.register_opts(password_option, group='designate')
self.addCleanup(
config.cfg.CONF.unregister_opts,
password_option, group='designate')
config.cfg.CONF.set_override('url',
self.TEST_URL,
group='designate')
config.cfg.CONF.set_override('auth_type',
'password',
group='designate')
config.cfg.CONF.set_override('username',
self.TEST_ADMIN_USERNAME,
group='designate')
config.cfg.CONF.set_override('password',
self.TEST_ADMIN_PASSWORD,
group='designate')
config.cfg.CONF.set_override('user_domain_id',
self.TEST_ADMIN_USER_DOMAIN_ID,
group='designate')
config.cfg.CONF.set_override('project_domain_id',
self.TEST_ADMIN_PROJECT_DOMAIN_ID,
group='designate')
config.cfg.CONF.set_override('auth_url',
self.TEST_ADMIN_AUTH_URL,
group='designate')
cfg.CONF.unregister_opts, password_option, group='designate')
cfg.CONF.set_override('url',
self.TEST_URL,
group='designate')
cfg.CONF.set_override('auth_type',
'password',
group='designate')
cfg.CONF.set_override('username',
self.TEST_ADMIN_USERNAME,
group='designate')
cfg.CONF.set_override('password',
self.TEST_ADMIN_PASSWORD,
group='designate')
cfg.CONF.set_override('user_domain_id',
self.TEST_ADMIN_USER_DOMAIN_ID,
group='designate')
cfg.CONF.set_override('project_domain_id',
self.TEST_ADMIN_PROJECT_DOMAIN_ID,
group='designate')
cfg.CONF.set_override('auth_url',
self.TEST_ADMIN_AUTH_URL,
group='designate')
# enforce session recalculation
mock.patch.object(driver, '_SESSION', new=None).start()
@ -891,21 +890,21 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
mock.patch.object(driver.password, 'Password').start())
def test_insecure_client(self):
config.cfg.CONF.set_override('insecure',
True,
group='designate')
cfg.CONF.set_override('insecure',
True,
group='designate')
driver.get_clients(self.TEST_CONTEXT)
self.driver_session.assert_called_with(cert=None,
timeout=None,
verify=False)
def test_secure_client(self):
config.cfg.CONF.set_override('insecure',
False,
group='designate')
config.cfg.CONF.set_override('cafile',
self.TEST_CA_CERT,
group='designate')
cfg.CONF.set_override('insecure',
False,
group='designate')
cfg.CONF.set_override('cafile',
self.TEST_CA_CERT,
group='designate')
driver.get_clients(self.TEST_CONTEXT)
self.driver_session.assert_called_with(cert=None,
timeout=None,
@ -913,5 +912,5 @@ class TestDesignateClientKeystoneV3(testtools.TestCase):
def test_auth_type_password(self):
driver.get_clients(self.TEST_CONTEXT)
self.load_auth.assert_called_with(config.cfg.CONF, 'designate')
self.load_auth.assert_called_with(cfg.CONF, 'designate')
self.password.assert_not_called()

@ -16,8 +16,8 @@
from neutron_lib.api.definitions import port_security as psec
from neutron_lib import context
from neutron_lib.plugins import directory
from oslo_config import cfg
from neutron.plugins.ml2 import config
from neutron.tests.unit.extensions import test_portsecurity as test_psec
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -27,9 +27,9 @@ class PSExtDriverTestCase(test_plugin.Ml2PluginV2TestCase,
_extension_drivers = ['port_security']
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(PSExtDriverTestCase, self).setUp()
def test_create_net_port_security_default(self):

@ -13,9 +13,9 @@
import mock
from neutron_lib import context
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_utils import uuidutils
from neutron.plugins.ml2 import config
from neutron.tests.unit.plugins.ml2.drivers import ext_test
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -25,9 +25,9 @@ class ExtensionDriverTestCase(test_plugin.Ml2PluginV2TestCase):
_extension_drivers = ['test']
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(ExtensionDriverTestCase, self).setUp()
self._plugin = directory.get_plugin()
self._ctxt = context.get_admin_context()
@ -178,9 +178,9 @@ class DBExtensionDriverTestCase(test_plugin.Ml2PluginV2TestCase):
_extension_drivers = ['testdb']
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(DBExtensionDriverTestCase, self).setUp()
self._plugin = directory.get_plugin()
self._ctxt = context.get_admin_context()

@ -17,10 +17,10 @@
import mock
from neutron_lib.plugins.ml2 import api
from oslo_config import cfg
from oslo_db import exception as db_exc
from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import config
from neutron.plugins.ml2 import managers
from neutron.tests import base
from neutron.tests.unit.plugins.ml2.drivers import mechanism_test
@ -45,8 +45,8 @@ class TestManagers(base.BaseTestCase):
@mock.patch.object(managers.LOG, 'critical')
@mock.patch.object(managers.MechanismManager, '_driver_not_loaded')
def test__driver_not_found(self, mock_not_loaded, mock_log):
config.cfg.CONF.set_override('mechanism_drivers', ['invalidmech'],
group='ml2')
cfg.CONF.set_override('mechanism_drivers', ['invalidmech'],
group='ml2')
self.assertRaises(SystemExit, managers.MechanismManager)
mock_not_loaded.assert_not_called()
mock_log.assert_called_once_with("The following mechanism drivers "
@ -56,8 +56,8 @@ class TestManagers(base.BaseTestCase):
@mock.patch.object(managers.LOG, 'critical')
@mock.patch.object(managers.MechanismManager, '_driver_not_found')
def test__driver_not_loaded(self, mock_not_found, mock_log):
config.cfg.CONF.set_override('mechanism_drivers', ['faulty_agent'],
group='ml2')
cfg.CONF.set_override('mechanism_drivers', ['faulty_agent'],
group='ml2')
self.assertRaises(SystemExit, managers.MechanismManager)
mock_log.assert_called_once_with(u"The '%(entrypoint)s' entrypoint "
"could not be loaded for the "
@ -68,8 +68,7 @@ class TestManagers(base.BaseTestCase):
class TestMechManager(base.BaseTestCase):
def setUp(self):
config.cfg.CONF.set_override('mechanism_drivers', ['test'],
group='ml2')
cfg.CONF.set_override('mechanism_drivers', ['test'], group='ml2')
super(TestMechManager, self).setUp()
self._manager = managers.MechanismManager()

@ -17,6 +17,7 @@ import functools
import fixtures
import mock
from oslo_config import cfg
import testtools
import webob
@ -49,7 +50,6 @@ from neutron.objects import base as base_obj
from neutron.objects import router as l3_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import config
from neutron.plugins.ml2 import db as ml2_db
from neutron.plugins.ml2 import driver_context
from neutron.plugins.ml2.drivers import type_vlan
@ -72,9 +72,9 @@ from neutron.tests.unit.plugins.ml2.drivers import mechanism_logger as \
from neutron.tests.unit.plugins.ml2.drivers import mechanism_test as mech_test
config.cfg.CONF.import_opt('network_vlan_ranges',
'neutron.plugins.ml2.drivers.type_vlan',
group='ml2_type_vlan')
cfg.CONF.import_opt('network_vlan_ranges',
'neutron.plugins.ml2.drivers.type_vlan',
group='ml2_type_vlan')
PLUGIN_NAME = 'ml2'
@ -135,18 +135,18 @@ class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
# Enable the test mechanism driver to ensure that
# we can successfully call through to all mechanism
# driver apis.
config.cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
cfg.CONF.set_override('mechanism_drivers',
self._mechanism_drivers,
group='ml2')
self.physnet = 'physnet1'
self.vlan_range = '1:100'
self.vlan_range2 = '200:300'
self.physnet2 = 'physnet2'
self.phys_vrange = ':'.join([self.physnet, self.vlan_range])
self.phys2_vrange = ':'.join([self.physnet2, self.vlan_range2])
config.cfg.CONF.set_override('network_vlan_ranges',
[self.phys_vrange, self.phys2_vrange],
group='ml2_type_vlan')
cfg.CONF.set_override('network_vlan_ranges',
[self.phys_vrange, self.phys2_vrange],
group='ml2_type_vlan')
self.setup_parent()
self.driver = directory.get_plugin()
self.context = context.get_admin_context()
@ -386,9 +386,9 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
return network
def test_external_network_type_none(self):
config.cfg.CONF.set_default('external_network_type',
None,
group='ml2')
cfg.CONF.set_default('external_network_type',
None,
group='ml2')
network = self._create_external_network()
# For external network, expected network type to be
@ -403,9 +403,9 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
self.assertNotIn(mpnet.SEGMENTS, network['network'])
def test_external_network_type_vlan(self):
config.cfg.CONF.set_default('external_network_type',
p_const.TYPE_VLAN,
group='ml2')
cfg.CONF.set_default('external_network_type',
p_const.TYPE_VLAN,
group='ml2')
network = self._create_external_network()
# For external network, expected network type to be 'vlan'.
@ -428,7 +428,7 @@ class TestMl2NetworksWithVlanTransparencyBase(TestMl2NetworksV2):
'vlan_transparent': 'True'}}
def setUp(self, plugin=None):
config.cfg.CONF.set_override('vlan_transparent', True)
cfg.CONF.set_override('vlan_transparent', True)
super(TestMl2NetworksWithVlanTransparencyBase, self).setUp(plugin)
@ -466,8 +466,8 @@ class TestMl2NetworksWithVlanTransparencyAndMTU(
with mock.patch.object(mech_test.TestMechanismDriver,
'check_vlan_transparency',
return_value=True):
config.cfg.CONF.set_override('path_mtu', 1000, group='ml2')
config.cfg.CONF.set_override('global_physnet_mtu', 1000)
cfg.CONF.set_override('path_mtu', 1000, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1000)
network_req = self.new_create_request('networks', self.data)
res = network_req.get_response(self.api)
self.assertEqual(201, res.status_int)
@ -1555,7 +1555,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
def setUp(self, firewall_driver=None):
test_sg_rpc.set_firewall_driver(self.FIREWALL_DRIVER)
config.cfg.CONF.set_override(
cfg.CONF.set_override(
'enable_security_group', self.ENABLE_SG,
group='SECURITYGROUP')
super(TestMl2PortBinding, self).setUp()
@ -2150,9 +2150,9 @@ class TestMl2AllowedAddressPairs(Ml2PluginV2TestCase,
_extension_drivers = ['port_security']
def setUp(self, plugin=None):
config.cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
cfg.CONF.set_override('extension_drivers',
self._extension_drivers,
group='ml2')
super(test_pair.TestAllowedAddressPairs, self).setUp(
plugin=PLUGIN_NAME)
@ -2160,12 +2160,12 @@ class TestMl2AllowedAddressPairs(Ml2PluginV2TestCase,
class TestMl2PortSecurity(Ml2PluginV2TestCase):
def setUp(self):
config.cfg.CONF.set_override('extension_drivers',
['port_security'],
group='ml2')
config.cfg.CONF.set_override('enable_security_group',
False,
group='SECURITYGROUP')
cfg.CONF.set_override('extension_drivers',
['port_security'],
group='ml2')
cfg.CONF.set_override('enable_security_group',
False,
group='SECURITYGROUP')
super(TestMl2PortSecurity, self).setUp()
def test_port_update_without_security_groups(self):
@ -2250,9 +2250,9 @@ class Ml2PluginV2FaultyDriverTestCase(test_plugin.NeutronDbPluginV2TestCase):
# Enable the test mechanism driver to ensure that
# we can successfully call through to all mechanism
# driver apis.
config.cfg.CONF.set_override('mechanism_drivers',
['test', 'logger'],
group='ml2')
cfg.CONF.set_override('mechanism_drivers',
['test', 'logger'],
group='ml2')
super(Ml2PluginV2FaultyDriverTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN'

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

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

@ -17,6 +17,7 @@ import netaddr
from neutron_lib import context as nctx
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from oslo_config import cfg