]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use constants from networking_odl project
authorKyle Mestery <mestery@mestery.com>
Thu, 22 Jan 2015 00:36:17 +0000 (00:36 +0000)
committerKyle Mestery <mestery@mestery.com>
Thu, 22 Jan 2015 05:21:04 +0000 (05:21 +0000)
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
neutron/tests/unit/ml2/test_mechanism_odl.py

index b1d48c5944893de770e770dd9f65e4499b7268fd..e7403c8779b699b1779b76a7dbc78f3f0b461352 100644 (file)
@@ -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 "
index bdf338d54c403ee34d5625de8b465df580701b31..9e1fad5ea8bfbbcf76e7bbdddc33f564de6ec17f 100644 (file)
@@ -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)