Values for [ml2]/physical_network_mtus should not be unique

Obviously there could be physical networks with same MTU.
The patch sets unique_values to False when parsing physical_network_mtus
Unit test added.

Closes-Bug: #1567502
Change-Id: I46e5b5d3f7033a974fca40342af6dff7c71a9a4a
This commit is contained in:
Oleg Bondarev 2016-04-07 19:27:38 +03:00
parent 444b3a5d9a
commit 5cdd7ae574
2 changed files with 14 additions and 2 deletions

View File

@ -19,6 +19,7 @@ from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log
from neutron._i18n import _LE
from neutron.common import exceptions as exc
from neutron.common import utils
from neutron.plugins.common import utils as p_utils
@ -36,9 +37,10 @@ class BaseTypeDriver(api.TypeDriver):
def __init__(self):
try:
self.physnet_mtus = utils.parse_mappings(
cfg.CONF.ml2.physical_network_mtus
cfg.CONF.ml2.physical_network_mtus, unique_values=False
)
except Exception:
except Exception as e:
LOG.error(_LE("Failed to parse physical_network_mtus: %s"), e)
self.physnet_mtus = []
def get_mtu(self, physical_network=None):

View File

@ -142,6 +142,16 @@ class FlatTypeTest(testlib_api.SqlTestCase):
self.driver.physnet_mtus = {}
self.assertEqual(0, self.driver.get_mtu('physnet1'))
def test_parse_physical_network_mtus(self):
config.cfg.CONF.set_override(
'physical_network_mtus',
['physnet1:1500', 'physnet2:1500', 'physnet3:9000'],
group='ml2')
driver = type_flat.FlatTypeDriver()
self.assertEqual('1500', driver.physnet_mtus['physnet1'])
self.assertEqual('1500', driver.physnet_mtus['physnet2'])
self.assertEqual('9000', driver.physnet_mtus['physnet3'])
class FlatTypeDefaultTest(base.BaseTestCase):