From 0e3766ced4bc089bcd706089c249e1e68f5ea942 Mon Sep 17 00:00:00 2001 From: Henry Gessau Date: Thu, 6 Feb 2014 20:56:00 -0500 Subject: [PATCH] Prepare for multiple cisco ML2 mech drivers 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 --- neutron/plugins/ml2/drivers/cisco/README | 19 --------------- .../plugins/ml2/drivers/cisco/nexus/README | 19 +++++++++++++++ .../ml2/drivers/cisco/nexus/__init__.py | 0 .../ml2/drivers/cisco/{ => nexus}/config.py | 0 .../drivers/cisco/{ => nexus}/constants.py | 24 ------------------- .../cisco/{ => nexus}/credentials_v2.py | 8 +++---- .../drivers/cisco/{ => nexus}/exceptions.py | 2 +- .../cisco/{ => nexus}/mech_cisco_nexus.py | 13 +++++----- .../cisco/{ => nexus}/network_db_v2.py | 11 +++++---- .../cisco/{ => nexus}/network_models_v2.py | 0 .../drivers/cisco/{ => nexus}/nexus_db_v2.py | 4 ++-- .../cisco/{ => nexus}/nexus_models_v2.py | 0 .../cisco/{ => nexus}/nexus_network_driver.py | 12 +++++----- .../cisco/{ => nexus}/nexus_snippets.py | 0 .../tests/unit/ml2/drivers/cisco/__init__.py | 0 .../unit/ml2/drivers/cisco/nexus/__init__.py | 0 .../{ => cisco/nexus}/test_cisco_mech.py | 8 +++---- .../nexus}/test_cisco_network_db.py | 4 ++-- .../{ => cisco/nexus}/test_cisco_nexus.py | 12 +++++----- .../{ => cisco/nexus}/test_cisco_nexus_db.py | 4 ++-- setup.cfg | 2 +- 21 files changed, 60 insertions(+), 82 deletions(-) delete mode 100644 neutron/plugins/ml2/drivers/cisco/README create mode 100644 neutron/plugins/ml2/drivers/cisco/nexus/README create mode 100644 neutron/plugins/ml2/drivers/cisco/nexus/__init__.py rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/config.py (100%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/constants.py (63%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/credentials_v2.py (90%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/exceptions.py (98%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/mech_cisco_nexus.py (93%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/network_db_v2.py (90%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/network_models_v2.py (100%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/nexus_db_v2.py (97%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/nexus_models_v2.py (100%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/nexus_network_driver.py (95%) rename neutron/plugins/ml2/drivers/cisco/{ => nexus}/nexus_snippets.py (100%) create mode 100644 neutron/tests/unit/ml2/drivers/cisco/__init__.py create mode 100644 neutron/tests/unit/ml2/drivers/cisco/nexus/__init__.py rename neutron/tests/unit/ml2/drivers/{ => cisco/nexus}/test_cisco_mech.py (98%) rename neutron/tests/unit/ml2/drivers/{ => cisco/nexus}/test_cisco_network_db.py (98%) rename neutron/tests/unit/ml2/drivers/{ => cisco/nexus}/test_cisco_nexus.py (94%) rename neutron/tests/unit/ml2/drivers/{ => cisco/nexus}/test_cisco_nexus_db.py (98%) diff --git a/neutron/plugins/ml2/drivers/cisco/README b/neutron/plugins/ml2/drivers/cisco/README deleted file mode 100644 index 5960e951da..0000000000 --- a/neutron/plugins/ml2/drivers/cisco/README +++ /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 index 0000000000..21905b0369 --- /dev/null +++ b/neutron/plugins/ml2/drivers/cisco/nexus/README @@ -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 index 0000000000..e69de29bb2 diff --git a/neutron/plugins/ml2/drivers/cisco/config.py b/neutron/plugins/ml2/drivers/cisco/nexus/config.py similarity index 100% rename from neutron/plugins/ml2/drivers/cisco/config.py rename to neutron/plugins/ml2/drivers/cisco/nexus/config.py diff --git a/neutron/plugins/ml2/drivers/cisco/constants.py b/neutron/plugins/ml2/drivers/cisco/nexus/constants.py similarity index 63% rename from neutron/plugins/ml2/drivers/cisco/constants.py rename to neutron/plugins/ml2/drivers/cisco/nexus/constants.py index df78eee9ea..f3191b0b2d 100644 --- a/neutron/plugins/ml2/drivers/cisco/constants.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/constants.py @@ -15,25 +15,6 @@ # -# 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' diff --git a/neutron/plugins/ml2/drivers/cisco/credentials_v2.py b/neutron/plugins/ml2/drivers/cisco/nexus/credentials_v2.py 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 ea172aabc5..87d5ce59d0 100644 --- a/neutron/plugins/ml2/drivers/cisco/credentials_v2.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/credentials_v2.py @@ -14,10 +14,10 @@ # 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 diff --git a/neutron/plugins/ml2/drivers/cisco/exceptions.py b/neutron/plugins/ml2/drivers/cisco/nexus/exceptions.py similarity index 98% rename from neutron/plugins/ml2/drivers/cisco/exceptions.py rename to neutron/plugins/ml2/drivers/cisco/nexus/exceptions.py index 0cf2964674..9302f30de2 100644 --- a/neutron/plugins/ml2/drivers/cisco/exceptions.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/exceptions.py @@ -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 diff --git a/neutron/plugins/ml2/drivers/cisco/mech_cisco_nexus.py b/neutron/plugins/ml2/drivers/cisco/nexus/mech_cisco_nexus.py 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 83972ef07f..a5153f7aa3 100644 --- a/neutron/plugins/ml2/drivers/cisco/mech_cisco_nexus.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/mech_cisco_nexus.py @@ -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) diff --git a/neutron/plugins/ml2/drivers/cisco/network_db_v2.py b/neutron/plugins/ml2/drivers/cisco/nexus/network_db_v2.py 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 46ed79c8cf..0020ebd3e1 100644 --- a/neutron/plugins/ml2/drivers/cisco/network_db_v2.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/network_db_v2.py @@ -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 diff --git a/neutron/plugins/ml2/drivers/cisco/network_models_v2.py b/neutron/plugins/ml2/drivers/cisco/nexus/network_models_v2.py similarity index 100% rename from neutron/plugins/ml2/drivers/cisco/network_models_v2.py rename to neutron/plugins/ml2/drivers/cisco/nexus/network_models_v2.py diff --git a/neutron/plugins/ml2/drivers/cisco/nexus_db_v2.py b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_db_v2.py 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 1fac6b610f..a9194379d0 100644 --- a/neutron/plugins/ml2/drivers/cisco/nexus_db_v2.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_db_v2.py @@ -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__) diff --git a/neutron/plugins/ml2/drivers/cisco/nexus_models_v2.py b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_models_v2.py similarity index 100% rename from neutron/plugins/ml2/drivers/cisco/nexus_models_v2.py rename to neutron/plugins/ml2/drivers/cisco/nexus/nexus_models_v2.py diff --git a/neutron/plugins/ml2/drivers/cisco/nexus_network_driver.py b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_network_driver.py 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 68f9019b90..4be4ab88fb 100644 --- a/neutron/plugins/ml2/drivers/cisco/nexus_network_driver.py +++ b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_network_driver.py @@ -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/plugins/ml2/drivers/cisco/nexus_snippets.py b/neutron/plugins/ml2/drivers/cisco/nexus/nexus_snippets.py similarity index 100% rename from neutron/plugins/ml2/drivers/cisco/nexus_snippets.py rename to neutron/plugins/ml2/drivers/cisco/nexus/nexus_snippets.py diff --git a/neutron/tests/unit/ml2/drivers/cisco/__init__.py b/neutron/tests/unit/ml2/drivers/cisco/__init__.py new file mode 100644 index 0000000000..e69de29bb2 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 index 0000000000..e69de29bb2 diff --git a/neutron/tests/unit/ml2/drivers/test_cisco_mech.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py 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 b57154a70d..e90333634a 100644 --- a/neutron/tests/unit/ml2/drivers/test_cisco_mech.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py @@ -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 diff --git a/neutron/tests/unit/ml2/drivers/test_cisco_network_db.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_network_db.py 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 849e7fe63f..9b52902b88 100644 --- a/neutron/tests/unit/ml2/drivers/test_cisco_network_db.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_network_db.py @@ -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 diff --git a/neutron/tests/unit/ml2/drivers/test_cisco_nexus.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py 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 69e13b716b..675daed7a8 100644 --- a/neutron/tests/unit/ml2/drivers/test_cisco_nexus.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py @@ -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') diff --git a/neutron/tests/unit/ml2/drivers/test_cisco_nexus_db.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus_db.py 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 079951b65e..b66514c541 100644 --- a/neutron/tests/unit/ml2/drivers/test_cisco_nexus_db.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus_db.py @@ -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 diff --git a/setup.cfg b/setup.cfg index d8c21da15c..31804c37b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -156,7 +156,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 [build_sphinx]