From 082258f5213948c0b74151fe1a74a1888e8dea67 Mon Sep 17 00:00:00 2001 From: Kyle Mestery Date: Thu, 22 Jan 2015 00:36:17 +0000 Subject: [PATCH] Use constants from networking_odl project Instead of redefining ODL_NETWORKS, ODL_SUBNETS, and ODL_PORTS, use these from the networking_odl project. Change-Id: I39a20dbae85b2fb671682e0cf94d67f06b9b8535 --- neutron/plugins/ml2/drivers/mechanism_odl.py | 23 ++++++++---------- neutron/tests/unit/ml2/test_mechanism_odl.py | 25 +++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/neutron/plugins/ml2/drivers/mechanism_odl.py b/neutron/plugins/ml2/drivers/mechanism_odl.py index b1d48c594..e7403c877 100644 --- a/neutron/plugins/ml2/drivers/mechanism_odl.py +++ b/neutron/plugins/ml2/drivers/mechanism_odl.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from networking_odl.common import constants as odl_const from networking_odl.ml2 import mech_driver from oslo.config import cfg @@ -24,10 +25,6 @@ from neutron.plugins.ml2 import driver_api as api LOG = log.getLogger(__name__) -ODL_NETWORKS = 'networks' -ODL_SUBNETS = 'subnets' -ODL_PORTS = 'ports' - odl_opts = [ cfg.StrOpt('url', help=_("HTTP URL of OpenDaylight REST interface.")), @@ -69,31 +66,31 @@ class OpenDaylightMechanismDriver(api.MechanismDriver): # Postcommit hooks are used to trigger synchronization. def create_network_postcommit(self, context): - self.odl_drv.synchronize('create', ODL_NETWORKS, context) + self.odl_drv.synchronize('create', odl_const.ODL_NETWORKS, context) def update_network_postcommit(self, context): - self.odl_drv.synchronize('update', ODL_NETWORKS, context) + self.odl_drv.synchronize('update', odl_const.ODL_NETWORKS, context) def delete_network_postcommit(self, context): - self.odl_drv.synchronize('delete', ODL_NETWORKS, context) + self.odl_drv.synchronize('delete', odl_const.ODL_NETWORKS, context) def create_subnet_postcommit(self, context): - self.odl_drv.synchronize('create', ODL_SUBNETS, context) + self.odl_drv.synchronize('create', odl_const.ODL_SUBNETS, context) def update_subnet_postcommit(self, context): - self.odl_drv.synchronize('update', ODL_SUBNETS, context) + self.odl_drv.synchronize('update', odl_const.ODL_SUBNETS, context) def delete_subnet_postcommit(self, context): - self.odl_drv.synchronize('delete', ODL_SUBNETS, context) + self.odl_drv.synchronize('delete', odl_const.ODL_SUBNETS, context) def create_port_postcommit(self, context): - self.odl_drv.synchronize('create', ODL_PORTS, context) + self.odl_drv.synchronize('create', odl_const.ODL_PORTS, context) def update_port_postcommit(self, context): - self.odl_drv.synchronize('update', ODL_PORTS, context) + self.odl_drv.synchronize('update', odl_const.ODL_PORTS, context) def delete_port_postcommit(self, context): - self.odl_drv.synchronize('delete', ODL_PORTS, context) + self.odl_drv.synchronize('delete', odl_const.ODL_PORTS, context) def bind_port(self, context): LOG.debug("Attempting to bind port %(port)s on " diff --git a/neutron/tests/unit/ml2/test_mechanism_odl.py b/neutron/tests/unit/ml2/test_mechanism_odl.py index bdf338d54..9e1fad5ea 100644 --- a/neutron/tests/unit/ml2/test_mechanism_odl.py +++ b/neutron/tests/unit/ml2/test_mechanism_odl.py @@ -20,14 +20,11 @@ from neutron import context from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin -ODL_NETWORKS = 'networks' -ODL_SUBNETS = 'subnets' -ODL_PORTS = 'ports' - - with mock.patch.dict(sys.modules, {'networking_odl': mock.Mock(), + 'networking_odl.common': mock.Mock(), 'networking_odl.ml2': mock.Mock()}): + from networking_odl.common import constants as const from neutron.plugins.ml2.drivers import mechanism_odl @@ -43,53 +40,53 @@ class TestODLShim(test_plugin.Ml2PluginV2TestCase): def test_create_network_postcommit(self): self.driver.create_network_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('create', - ODL_NETWORKS, + const.ODL_NETWORKS, self.context) def test_update_network_postcommit(self): self.driver.update_network_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('update', - ODL_NETWORKS, + const.ODL_NETWORKS, self.context) def test_delete_network_postcommit(self): self.driver.delete_network_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('delete', - ODL_NETWORKS, + const.ODL_NETWORKS, self.context) def test_create_subnet_postcommit(self): self.driver.create_subnet_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('create', - ODL_SUBNETS, + const.ODL_SUBNETS, self.context) def test_update_subnet_postcommit(self): self.driver.update_subnet_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('update', - ODL_SUBNETS, + const.ODL_SUBNETS, self.context) def test_delete_subnet_postcommit(self): self.driver.delete_subnet_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('delete', - ODL_SUBNETS, + const.ODL_SUBNETS, self.context) def test_create_port_postcommit(self): self.driver.create_port_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('create', - ODL_PORTS, + const.ODL_PORTS, self.context) def test_update_port_postcommit(self): self.driver.update_port_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('update', - ODL_PORTS, + const.ODL_PORTS, self.context) def test_delete_port_postcommit(self): self.driver.delete_port_postcommit(self.context) self.driver.odl_drv.synchronize.assert_called_with('delete', - ODL_PORTS, + const.ODL_PORTS, self.context) -- 2.45.2