Make '*' the default ml2 flat_networks configuration
Update the ml2 flat_networks configuration to set '*' as the default because that has been effectively the default behavior due to a bug with the empty list. Also, fix the empty list configuration for disabling flat networks. DocImpact UpgradeImpact Change-Id: I13eb22afd7c0d011154b58a1bd218fd4fa82a8d9 Closes-bug: #1437745 Co-Authored-By: Martin Hickey <martin.hickey@ie.ibm.com>
This commit is contained in:
parent
00f5fedab0
commit
cb712c5a9e
@ -61,12 +61,12 @@
|
||||
|
||||
[ml2_type_flat]
|
||||
# (ListOpt) List of physical_network names with which flat networks
|
||||
# can be created. Use * to allow flat networks with arbitrary
|
||||
# physical_network names.
|
||||
# can be created. Use default '*' to allow flat networks with arbitrary
|
||||
# physical_network names. Use an empty list to disable flat networks.
|
||||
#
|
||||
# flat_networks =
|
||||
# flat_networks = *
|
||||
# Example:flat_networks = physnet1,physnet2
|
||||
# Example:flat_networks = *
|
||||
# Example:flat_networks =
|
||||
|
||||
[ml2_type_vlan]
|
||||
# (ListOpt) List of <physical_network>[:<vlan_min>:<vlan_max>] tuples
|
||||
|
@ -30,10 +30,11 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
flat_opts = [
|
||||
cfg.ListOpt('flat_networks',
|
||||
default=[],
|
||||
default='*',
|
||||
help=_("List of physical_network names with which flat "
|
||||
"networks can be created. Use * to allow flat "
|
||||
"networks with arbitrary physical_network names."))
|
||||
"networks can be created. Use default '*' to allow "
|
||||
"flat networks with arbitrary physical_network names. "
|
||||
"Use an empty list to disable flat networks."))
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(flat_opts, "ml2_type_flat")
|
||||
@ -72,9 +73,8 @@ class FlatTypeDriver(helpers.BaseTypeDriver):
|
||||
if '*' in self.flat_networks:
|
||||
LOG.info(_LI("Arbitrary flat physical_network names allowed"))
|
||||
self.flat_networks = None
|
||||
elif not all(self.flat_networks):
|
||||
msg = _("physical network name is empty")
|
||||
raise exc.InvalidInput(error_message=msg)
|
||||
elif not self.flat_networks:
|
||||
LOG.info(_LI("Flat networks are disabled"))
|
||||
else:
|
||||
LOG.info(_LI("Allowable flat physical_network names: %s"),
|
||||
self.flat_networks)
|
||||
@ -93,6 +93,9 @@ class FlatTypeDriver(helpers.BaseTypeDriver):
|
||||
if not physical_network:
|
||||
msg = _("physical_network required for flat provider network")
|
||||
raise exc.InvalidInput(error_message=msg)
|
||||
if self.flat_networks is not None and not self.flat_networks:
|
||||
msg = _("Flat provider networks are disabled")
|
||||
raise exc.InvalidInput(error_message=msg)
|
||||
if self.flat_networks and physical_network not in self.flat_networks:
|
||||
msg = (_("physical_network '%s' unknown for flat provider network")
|
||||
% physical_network)
|
||||
|
@ -19,6 +19,7 @@ from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.ml2 import config
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
from neutron.plugins.ml2.drivers import type_flat
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
@ -50,14 +51,21 @@ class FlatTypeTest(testlib_api.SqlTestCase):
|
||||
self.driver.validate_provider_segment(segment)
|
||||
|
||||
def test_validate_provider_phynet_name(self):
|
||||
self.driver._parse_networks([])
|
||||
segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT,
|
||||
api.PHYSICAL_NETWORK: 'flat_net1'}
|
||||
self.assertRaises(exc.InvalidInput,
|
||||
self.driver._parse_networks,
|
||||
entries=[''])
|
||||
self.driver.validate_provider_segment,
|
||||
segment=segment)
|
||||
|
||||
def test_validate_provider_phynet_name_multiple(self):
|
||||
self.assertRaises(exc.InvalidInput,
|
||||
self.driver._parse_networks,
|
||||
entries=['flat_net1', ''])
|
||||
self.driver._parse_networks(['flat_net1', 'flat_net2'])
|
||||
segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT,
|
||||
api.PHYSICAL_NETWORK: 'flat_net1'}
|
||||
self.driver.validate_provider_segment(segment)
|
||||
segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT,
|
||||
api.PHYSICAL_NETWORK: 'flat_net2'}
|
||||
self.driver.validate_provider_segment(segment)
|
||||
|
||||
def test_validate_provider_segment_without_physnet_restriction(self):
|
||||
self.driver._parse_networks('*')
|
||||
@ -133,3 +141,16 @@ class FlatTypeTest(testlib_api.SqlTestCase):
|
||||
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
|
||||
self.driver.physnet_mtus = {}
|
||||
self.assertEqual(0, self.driver.get_mtu('physnet1'))
|
||||
|
||||
|
||||
class FlatTypeDefaultTest(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FlatTypeDefaultTest, self).setUp()
|
||||
self.driver = type_flat.FlatTypeDriver()
|
||||
self.driver.physnet_mtus = []
|
||||
|
||||
def test_validate_provider_segment_default(self):
|
||||
segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT,
|
||||
api.PHYSICAL_NETWORK: 'other_flat_net'}
|
||||
self.driver.validate_provider_segment(segment)
|
||||
|
Loading…
x
Reference in New Issue
Block a user