]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Prepare for multiple cisco ML2 mech drivers
authorHenry Gessau <gessau@cisco.com>
Fri, 7 Feb 2014 01:56:00 +0000 (20:56 -0500)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:17 +0000 (15:20 +0800)
Code tree reorganization in preparation for ML2 mechanism drivers for
other cisco products. The cisco nexus ML2 mechanism driver and its
test cases need to move down into their own subdirectory.

Closes-bug: #1277222

Change-Id: I2ba366332276069545b3deb0bbd39016a893327b

21 files changed:
neutron/plugins/ml2/drivers/cisco/README [deleted file]
neutron/plugins/ml2/drivers/cisco/nexus/README [new file with mode: 0644]
neutron/plugins/ml2/drivers/cisco/nexus/__init__.py [new file with mode: 0644]
neutron/plugins/ml2/drivers/cisco/nexus/config.py [moved from neutron/plugins/ml2/drivers/cisco/config.py with 100% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/constants.py [moved from neutron/plugins/ml2/drivers/cisco/constants.py with 63% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/credentials_v2.py [moved from neutron/plugins/ml2/drivers/cisco/credentials_v2.py with 90% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/exceptions.py [moved from neutron/plugins/ml2/drivers/cisco/exceptions.py with 98% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/mech_cisco_nexus.py [moved from neutron/plugins/ml2/drivers/cisco/mech_cisco_nexus.py with 93% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/network_db_v2.py [moved from neutron/plugins/ml2/drivers/cisco/network_db_v2.py with 90% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/network_models_v2.py [moved from neutron/plugins/ml2/drivers/cisco/network_models_v2.py with 100% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/nexus_db_v2.py [moved from neutron/plugins/ml2/drivers/cisco/nexus_db_v2.py with 97% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/nexus_models_v2.py [moved from neutron/plugins/ml2/drivers/cisco/nexus_models_v2.py with 100% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/nexus_network_driver.py [moved from neutron/plugins/ml2/drivers/cisco/nexus_network_driver.py with 95% similarity]
neutron/plugins/ml2/drivers/cisco/nexus/nexus_snippets.py [moved from neutron/plugins/ml2/drivers/cisco/nexus_snippets.py with 100% similarity]
neutron/tests/unit/ml2/drivers/cisco/__init__.py [new file with mode: 0644]
neutron/tests/unit/ml2/drivers/cisco/nexus/__init__.py [new file with mode: 0644]
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py [moved from neutron/tests/unit/ml2/drivers/test_cisco_mech.py with 98% similarity]
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_network_db.py [moved from neutron/tests/unit/ml2/drivers/test_cisco_network_db.py with 98% similarity]
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py [moved from neutron/tests/unit/ml2/drivers/test_cisco_nexus.py with 94% similarity]
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus_db.py [moved from neutron/tests/unit/ml2/drivers/test_cisco_nexus_db.py with 98% similarity]
setup.cfg

diff --git a/neutron/plugins/ml2/drivers/cisco/README b/neutron/plugins/ml2/drivers/cisco/README
deleted file mode 100644 (file)
index 5960e95..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Neutron ML2 Cisco Mechanism Drivers README
-
-Cisco mechanism drivers implement the ML2 driver APIs for managing
-Cisco devices.
-
-Notes:
-The initial version of the Cisco Nexus driver supports only the
-VLAN network type on a single physical network.
-
-Provider networks are not currently supported.
-
-The Cisco Nexus mechanism driver's database may have duplicate entries also
-found in the core ML2 database. Since the Cisco Nexus DB code is a port from
-the plugins/cisco implementation this duplication will remain until the
-plugins/cisco code is deprecated.
-
-
-For more details on using Cisco Nexus switches under ML2 please refer to:
-http://wiki.openstack.org/wiki/Neutron/ML2/MechCiscoNexus
diff --git a/neutron/plugins/ml2/drivers/cisco/nexus/README b/neutron/plugins/ml2/drivers/cisco/nexus/README
new file mode 100644 (file)
index 0000000..21905b0
--- /dev/null
@@ -0,0 +1,19 @@
+Neutron ML2 Cisco Nexus Mechanism Driver README
+
+
+Notes:
+
+The initial version of this driver supports only a single physical
+network.
+
+For provider networks, extended configuration options are not
+currently supported.
+
+This driver's database may have duplicate entries also found in the
+core ML2 database. Since the Cisco Nexus DB code is a port from the
+plugins/cisco implementation this duplication will remain until the
+plugins/cisco code is deprecated.
+
+
+For more details on using Cisco Nexus switches under ML2 please refer to:
+http://wiki.openstack.org/wiki/Neutron/ML2/MechCiscoNexus
diff --git a/neutron/plugins/ml2/drivers/cisco/nexus/__init__.py b/neutron/plugins/ml2/drivers/cisco/nexus/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 63%
rename from neutron/plugins/ml2/drivers/cisco/constants.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/constants.py
index df78eee9eae5189b90d8faba4a979646ceafb44a..f3191b0b2d422aa69f84ad2defd58bc391586977 100644 (file)
 #
 
 
-# Attachment attributes
-INSTANCE_ID = 'instance_id'
-TENANT_ID = 'tenant_id'
-TENANT_NAME = 'tenant_name'
-HOST_NAME = 'host_name'
-
-# Network attributes
-NET_ID = 'id'
-NET_NAME = 'name'
-NET_VLAN_ID = 'vlan_id'
-NET_VLAN_NAME = 'vlan_name'
-NET_PORTS = 'ports'
-
-# Network types
-NETWORK_TYPE_FLAT = 'flat'
-NETWORK_TYPE_LOCAL = 'local'
-NETWORK_TYPE_VLAN = 'vlan'
-NETWORK_TYPE_NONE = 'none'
-
 CREDENTIAL_USERNAME = 'user_name'
 CREDENTIAL_PASSWORD = 'password'
 
@@ -41,8 +22,3 @@ USERNAME = 'username'
 PASSWORD = 'password'
 
 NETWORK_ADMIN = 'network_admin'
-
-NETWORK = 'network'
-PORT = 'port'
-CONTEXT = 'context'
-SUBNET = 'subnet'
similarity index 90%
rename from neutron/plugins/ml2/drivers/cisco/credentials_v2.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/credentials_v2.py
index ea172aabc5c4c8f5ad6f9f5b5822f4409da6c7a1..87d5ce59d0770f22070d1635c1e2eaf0a621e25f 100644 (file)
 #    under the License.
 #
 
-from neutron.plugins.ml2.drivers.cisco import config as config
-from neutron.plugins.ml2.drivers.cisco import constants as const
-from neutron.plugins.ml2.drivers.cisco import exceptions as cexc
-from neutron.plugins.ml2.drivers.cisco import network_db_v2 as cdb
+from neutron.plugins.ml2.drivers.cisco.nexus import config
+from neutron.plugins.ml2.drivers.cisco.nexus import constants as const
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as cexc
+from neutron.plugins.ml2.drivers.cisco.nexus import network_db_v2 as cdb
 
 
 TENANT = const.NETWORK_ADMIN
similarity index 98%
rename from neutron/plugins/ml2/drivers/cisco/exceptions.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/exceptions.py
index 0cf296467471f1eb12b1dd75c691b895fb55798a..9302f30de282c8a811d0b0f6370627e77d8c0b8d 100644 (file)
@@ -13,7 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-"""Exceptions used by Cisco ML2 mechanism drivers."""
+"""Exceptions used by Cisco Nexus ML2 mechanism driver."""
 
 from neutron.common import exceptions
 
similarity index 93%
rename from neutron/plugins/ml2/drivers/cisco/mech_cisco_nexus.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/mech_cisco_nexus.py
index 83972ef07fd5988fb6bb6ca67ff6f21180c3918c..a5153f7aa350f23d1d5763d68dedd40275712582 100644 (file)
@@ -22,12 +22,13 @@ from oslo.config import cfg
 from neutron.common import constants as n_const
 from neutron.extensions import portbindings
 from neutron.openstack.common import log as logging
+from neutron.plugins.common import constants as p_const
 from neutron.plugins.ml2 import driver_api as api
-from neutron.plugins.ml2.drivers.cisco import config as conf
-from neutron.plugins.ml2.drivers.cisco import credentials_v2 as cred
-from neutron.plugins.ml2.drivers.cisco import exceptions as excep
-from neutron.plugins.ml2.drivers.cisco import nexus_db_v2 as nxos_db
-from neutron.plugins.ml2.drivers.cisco import nexus_network_driver
+from neutron.plugins.ml2.drivers.cisco.nexus import config as conf
+from neutron.plugins.ml2.drivers.cisco.nexus import credentials_v2 as cred
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as excep
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2 as nxos_db
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_network_driver
 
 LOG = logging.getLogger(__name__)
 
@@ -57,7 +58,7 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
 
     def _get_vlanid(self, context):
         segment = context.bound_segment
-        if (segment and segment[api.NETWORK_TYPE] == 'vlan' and
+        if (segment and segment[api.NETWORK_TYPE] == p_const.TYPE_VLAN and
             self._valid_network_segment(segment)):
             return context.bound_segment.get(api.SEGMENTATION_ID)
 
similarity index 90%
rename from neutron/plugins/ml2/drivers/cisco/network_db_v2.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/network_db_v2.py
index 46ed79c8cf87d5eed9781c1979ba3d7e1d411001..0020ebd3e16de53a7beb81c3bf63839d4a0864fb 100644 (file)
@@ -19,9 +19,10 @@ from sqlalchemy.orm import exc
 from neutron.db import api as db
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import uuidutils
-from neutron.plugins.ml2.drivers.cisco import exceptions as c_exc
-from neutron.plugins.ml2.drivers.cisco import network_models_v2
-from neutron.plugins.ml2.drivers.cisco import nexus_models_v2  # noqa
+from neutron.plugins.ml2.drivers.cisco.nexus import constants as const
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc
+from neutron.plugins.ml2.drivers.cisco.nexus import network_models_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_models_v2  # noqa
 
 
 LOG = logging.getLogger(__name__)
@@ -104,9 +105,9 @@ def update_credential(tenant_id, credential_id,
                 filter_by(tenant_id=tenant_id).
                 filter_by(credential_id=credential_id).one())
         if new_user_name:
-            cred["user_name"] = new_user_name
+            cred[const.CREDENTIAL_USERNAME] = new_user_name
         if new_password:
-            cred["password"] = new_password
+            cred[const.CREDENTIAL_PASSWORD] = new_password
         session.merge(cred)
         session.flush()
         return cred
similarity index 97%
rename from neutron/plugins/ml2/drivers/cisco/nexus_db_v2.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/nexus_db_v2.py
index 1fac6b610fab20f6565780e3331ca3fe1f7f3ca2..a9194379d0f5bc980af5eea47cedc07dc10c4d93 100644 (file)
@@ -18,8 +18,8 @@ import sqlalchemy.orm.exc as sa_exc
 
 import neutron.db.api as db
 from neutron.openstack.common import log as logging
-from neutron.plugins.ml2.drivers.cisco import exceptions as c_exc
-from neutron.plugins.ml2.drivers.cisco import nexus_models_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_models_v2
 
 
 LOG = logging.getLogger(__name__)
similarity index 95%
rename from neutron/plugins/ml2/drivers/cisco/nexus_network_driver.py
rename to neutron/plugins/ml2/drivers/cisco/nexus/nexus_network_driver.py
index 68f9019b90b0861e25d1a38d36049cef83daf62e..4be4ab88fb7e00247b96764dd7cfc0e9c6fbd874 100644 (file)
@@ -20,12 +20,12 @@ Implements a Nexus-OS NETCONF over SSHv2 API Client
 from neutron.openstack.common import excutils
 from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
-from neutron.plugins.ml2.drivers.cisco import config as conf
-from neutron.plugins.ml2.drivers.cisco import constants as const
-from neutron.plugins.ml2.drivers.cisco import credentials_v2 as cred
-from neutron.plugins.ml2.drivers.cisco import exceptions as cexc
-from neutron.plugins.ml2.drivers.cisco import nexus_db_v2
-from neutron.plugins.ml2.drivers.cisco import nexus_snippets as snipp
+from neutron.plugins.ml2.drivers.cisco.nexus import config as conf
+from neutron.plugins.ml2.drivers.cisco.nexus import constants as const
+from neutron.plugins.ml2.drivers.cisco.nexus import credentials_v2 as cred
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as cexc
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_snippets as snipp
 
 LOG = logging.getLogger(__name__)
 
diff --git a/neutron/tests/unit/ml2/drivers/cisco/__init__.py b/neutron/tests/unit/ml2/drivers/cisco/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/neutron/tests/unit/ml2/drivers/cisco/nexus/__init__.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 98%
rename from neutron/tests/unit/ml2/drivers/test_cisco_mech.py
rename to neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py
index b57154a70daa0f4e9f4866357f3c6bced5720697..e90333634aad783b83ac1bc1296470e78f485015 100644 (file)
@@ -25,10 +25,10 @@ from neutron.extensions import portbindings
 from neutron.manager import NeutronManager
 from neutron.openstack.common import log as logging
 from neutron.plugins.ml2 import config as ml2_config
-from neutron.plugins.ml2.drivers.cisco import config as cisco_config
-from neutron.plugins.ml2.drivers.cisco import exceptions as c_exc
-from neutron.plugins.ml2.drivers.cisco import mech_cisco_nexus
-from neutron.plugins.ml2.drivers.cisco import nexus_network_driver
+from neutron.plugins.ml2.drivers.cisco.nexus import config as cisco_config
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc
+from neutron.plugins.ml2.drivers.cisco.nexus import mech_cisco_nexus
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_network_driver
 from neutron.plugins.ml2.drivers import type_vlan as vlan_config
 from neutron.tests.unit import test_db_plugin
 
similarity index 98%
rename from neutron/tests/unit/ml2/drivers/test_cisco_network_db.py
rename to neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_network_db.py
index 849e7fe63f59d65a28cdde195a52c49c11d755a6..9b52902b880e6a1f4bfd5c30ade410b9ccd72883 100644 (file)
@@ -17,8 +17,8 @@ import collections
 import testtools
 
 from neutron.db import api as db
-from neutron.plugins.ml2.drivers.cisco import exceptions
-from neutron.plugins.ml2.drivers.cisco import network_db_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions
+from neutron.plugins.ml2.drivers.cisco.nexus import network_db_v2
 from neutron.tests import base
 
 
similarity index 94%
rename from neutron/tests/unit/ml2/drivers/test_cisco_nexus.py
rename to neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py
index 69e13b716b2e8e98c975938af746c5b4282e3fdc..675daed7a85da1d958afe304d468726b9e9de6dc 100644 (file)
@@ -22,11 +22,11 @@ from neutron.db import api as db
 from neutron.extensions import portbindings
 from neutron.openstack.common import importutils
 from neutron.plugins.ml2 import driver_api as api
-from neutron.plugins.ml2.drivers.cisco import constants
-from neutron.plugins.ml2.drivers.cisco import exceptions
-from neutron.plugins.ml2.drivers.cisco import mech_cisco_nexus
-from neutron.plugins.ml2.drivers.cisco import nexus_db_v2
-from neutron.plugins.ml2.drivers.cisco import nexus_network_driver
+from neutron.plugins.ml2.drivers.cisco.nexus import constants
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions
+from neutron.plugins.ml2.drivers.cisco.nexus import mech_cisco_nexus
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_network_driver
 from neutron.tests import base
 
 
@@ -48,7 +48,7 @@ DEVICE_OWNER = 'compute:test'
 NEXUS_SSH_PORT = '22'
 PORT_STATE = n_const.PORT_STATUS_ACTIVE
 NETWORK_TYPE = 'vlan'
-NEXUS_DRIVER = ('neutron.plugins.ml2.drivers.cisco.'
+NEXUS_DRIVER = ('neutron.plugins.ml2.drivers.cisco.nexus.'
                 'nexus_network_driver.CiscoNexusDriver')
 
 
similarity index 98%
rename from neutron/tests/unit/ml2/drivers/test_cisco_nexus_db.py
rename to neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus_db.py
index 079951b65edf5ba69529bc2415b82ae951b17b0a..b66514c541a7aa8cf5aa1938124be15ba0ccddf4 100644 (file)
@@ -17,8 +17,8 @@ import collections
 import testtools
 
 from neutron.db import api as db
-from neutron.plugins.ml2.drivers.cisco import exceptions
-from neutron.plugins.ml2.drivers.cisco import nexus_db_v2
+from neutron.plugins.ml2.drivers.cisco.nexus import exceptions
+from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2
 from neutron.tests import base
 
 
index df29454d1d59d9d388800e732a3e2ec0a37a86e7..8c83cfa14a3f3dede875b78e4614a3b17217ac2d 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -157,7 +157,7 @@ neutron.ml2.mechanism_drivers =
     hyperv = neutron.plugins.ml2.drivers.mech_hyperv:HypervMechanismDriver
     ncs = neutron.plugins.ml2.drivers.mechanism_ncs:NCSMechanismDriver
     arista = neutron.plugins.ml2.drivers.mech_arista.mechanism_arista:AristaDriver
-    cisco_nexus = neutron.plugins.ml2.drivers.cisco.mech_cisco_nexus:CiscoNexusMechanismDriver
+    cisco_nexus = neutron.plugins.ml2.drivers.cisco.nexus.mech_cisco_nexus:CiscoNexusMechanismDriver
     l2population = neutron.plugins.ml2.drivers.l2pop.mech_driver:L2populationMechanismDriver
     bigswitch = neutron.plugins.ml2.drivers.mech_bigswitch.driver:BigSwitchMechanismDriver