
The initial OpenDaylight integration with Openstack did not support vlan isolation so it was not included as a valid type. This change adds the vlan type as allowed. Also modified tests to include vlan as supported in the check_segment(). DocImpact: Use of VLANs with ML2 and the OpenDaylight mechanism driver requires OpenDaylight Helium or newer to be installed. Closes-Bug: #1315475 Change-Id: I52e3c9bfdc93b8786c58954beca105e7498e3f40
118 lines
4.7 KiB
Python
118 lines
4.7 KiB
Python
# Copyright (c) 2013-2014 OpenStack Foundation
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
# @author: Kyle Mestery, Cisco Systems, Inc.
|
|
|
|
from neutron.plugins.common import constants
|
|
from neutron.plugins.ml2 import config as config
|
|
from neutron.plugins.ml2 import driver_api as api
|
|
from neutron.plugins.ml2.drivers import mechanism_odl
|
|
from neutron.plugins.ml2 import plugin
|
|
from neutron.tests import base
|
|
from neutron.tests.unit import test_db_plugin as test_plugin
|
|
|
|
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
|
|
|
|
|
|
class OpenDaylightTestCase(test_plugin.NeutronDbPluginV2TestCase):
|
|
|
|
def setUp(self):
|
|
# 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', 'opendaylight'],
|
|
'ml2')
|
|
# Set URL/user/pass so init doesn't throw a cfg required error.
|
|
# They are not used in these tests since sendjson is overwritten.
|
|
config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
|
|
config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
|
|
config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')
|
|
|
|
super(OpenDaylightTestCase, self).setUp(PLUGIN_NAME)
|
|
self.port_create_status = 'DOWN'
|
|
self.segment = {'api.NETWORK_TYPE': ""}
|
|
self.mech = mechanism_odl.OpenDaylightMechanismDriver()
|
|
mechanism_odl.OpenDaylightMechanismDriver.sendjson = (
|
|
self.check_sendjson)
|
|
|
|
def check_sendjson(self, method, urlpath, obj, ignorecodes=[]):
|
|
self.assertFalse(urlpath.startswith("http://"))
|
|
|
|
def test_check_segment(self):
|
|
"""Validate the check_segment call."""
|
|
self.segment[api.NETWORK_TYPE] = constants.TYPE_LOCAL
|
|
self.assertTrue(self.mech.check_segment(self.segment))
|
|
self.segment[api.NETWORK_TYPE] = constants.TYPE_FLAT
|
|
self.assertFalse(self.mech.check_segment(self.segment))
|
|
self.segment[api.NETWORK_TYPE] = constants.TYPE_VLAN
|
|
self.assertTrue(self.mech.check_segment(self.segment))
|
|
self.segment[api.NETWORK_TYPE] = constants.TYPE_GRE
|
|
self.assertTrue(self.mech.check_segment(self.segment))
|
|
self.segment[api.NETWORK_TYPE] = constants.TYPE_VXLAN
|
|
self.assertTrue(self.mech.check_segment(self.segment))
|
|
# Validate a network type not currently supported
|
|
self.segment[api.NETWORK_TYPE] = 'mpls'
|
|
self.assertFalse(self.mech.check_segment(self.segment))
|
|
|
|
|
|
class OpenDayLightMechanismConfigTests(base.BaseTestCase):
|
|
|
|
def _set_config(self, url='http://127.0.0.1:9999', username='someuser',
|
|
password='somepass'):
|
|
config.cfg.CONF.set_override('mechanism_drivers',
|
|
['logger', 'opendaylight'],
|
|
'ml2')
|
|
config.cfg.CONF.set_override('url', url, 'ml2_odl')
|
|
config.cfg.CONF.set_override('username', username, 'ml2_odl')
|
|
config.cfg.CONF.set_override('password', password, 'ml2_odl')
|
|
|
|
def _test_missing_config(self, **kwargs):
|
|
self._set_config(**kwargs)
|
|
self.assertRaises(config.cfg.RequiredOptError,
|
|
plugin.Ml2Plugin)
|
|
|
|
def test_valid_config(self):
|
|
self._set_config()
|
|
plugin.Ml2Plugin()
|
|
|
|
def test_missing_url_raises_exception(self):
|
|
self._test_missing_config(url=None)
|
|
|
|
def test_missing_username_raises_exception(self):
|
|
self._test_missing_config(username=None)
|
|
|
|
def test_missing_password_raises_exception(self):
|
|
self._test_missing_config(password=None)
|
|
|
|
|
|
class OpenDaylightMechanismTestBasicGet(test_plugin.TestBasicGet,
|
|
OpenDaylightTestCase):
|
|
pass
|
|
|
|
|
|
class OpenDaylightMechanismTestNetworksV2(test_plugin.TestNetworksV2,
|
|
OpenDaylightTestCase):
|
|
pass
|
|
|
|
|
|
class OpenDaylightMechanismTestSubnetsV2(test_plugin.TestSubnetsV2,
|
|
OpenDaylightTestCase):
|
|
pass
|
|
|
|
|
|
class OpenDaylightMechanismTestPortsV2(test_plugin.TestPortsV2,
|
|
OpenDaylightTestCase):
|
|
pass
|