From d91cd8dc1a59a3d53009e34f1e2f47ed352f5205 Mon Sep 17 00:00:00 2001 From: Sandhya Dasu Date: Mon, 17 Aug 2015 06:26:53 -0400 Subject: [PATCH] Final decomposition of ML2 Cisco UCSM driver The ML2 Cisco UCSM driver's entry point is being switched to the networking-cisco vendor repo. The definition of the driver's db file and all references to it in the neutron branch are removed. Change-Id: I75eb165f3bb78d31bece26762ca0ff47cab2b79b Implements: blueprint: core-vendor-decomposition Closes-bug: #1484165 --- etc/neutron/plugins/ml2/ml2_conf_cisco.ini | 157 ------------- .../migration/alembic_migrations/external.py | 1 + neutron/db/migration/models/head.py | 1 - .../ml2/drivers/cisco/ucsm/__init__.py | 0 .../ml2/drivers/cisco/ucsm/mech_cisco_ucsm.py | 218 ------------------ .../ml2/drivers/cisco/ucsm/ucsm_model.py | 29 --- setup.cfg | 2 - 7 files changed, 1 insertion(+), 407 deletions(-) delete mode 100644 etc/neutron/plugins/ml2/ml2_conf_cisco.ini delete mode 100644 neutron/plugins/ml2/drivers/cisco/ucsm/__init__.py delete mode 100644 neutron/plugins/ml2/drivers/cisco/ucsm/mech_cisco_ucsm.py delete mode 100644 neutron/plugins/ml2/drivers/cisco/ucsm/ucsm_model.py diff --git a/etc/neutron/plugins/ml2/ml2_conf_cisco.ini b/etc/neutron/plugins/ml2/ml2_conf_cisco.ini deleted file mode 100644 index 7900047ad..000000000 --- a/etc/neutron/plugins/ml2/ml2_conf_cisco.ini +++ /dev/null @@ -1,157 +0,0 @@ -[ml2_cisco] - -# (StrOpt) A short prefix to prepend to the VLAN number when creating a -# VLAN interface. For example, if an interface is being created for -# VLAN 2001 it will be named 'q-2001' using the default prefix. -# The total length allowed for the prefix name and VLAN is 32 characters, -# the prefix will be truncated if the total length is greater than 32. -# -# vlan_name_prefix = q- -# Example: vlan_name_prefix = vnet- - -# (BoolOpt) A flag to enable round robin scheduling of routers for SVI. -# svi_round_robin = False - -# -# (StrOpt) The name of the physical_network managed via the Cisco Nexus Switch. -# This string value must be present in the ml2_conf.ini network_vlan_ranges -# variable. -# -# managed_physical_network = -# Example: managed_physical_network = physnet1 - -# Cisco Nexus Switch configurations. -# Each switch to be managed by Openstack Neutron must be configured here. -# -# Cisco Nexus Switch Format. -# [ml2_mech_cisco_nexus:] -# = (1) -# ssh_port= (2) -# username= (3) -# password= (4) -# nve_src_intf= (5) -# physnet= (6) -# -# (1) For each host connected to a port on the switch, specify the hostname -# and the Nexus physical port (interface) it is connected to. -# Valid intf_type's are 'ethernet' and 'port-channel'. -# The default setting for is 'ethernet' and need not be -# added to this setting. -# (2) The TCP port for connecting via SSH to manage the switch. This is -# port number 22 unless the switch has been configured otherwise. -# (3) The username for logging into the switch to manage it. -# (4) The password for logging into the switch to manage it. -# (5) Only valid if VXLAN overlay is configured and vxlan_global_config is -# set to True. -# The NVE source interface is a loopback interface that is configured on -# the switch with valid /32 IP address. This /32 IP address must be known -# by the transient devices in the transport network and the remote VTEPs. -# This is accomplished by advertising it through a dynamic routing protocol -# in the transport network. (NB: If no nve_src_intf is defined then a -# default setting of 0 (creates "loopback0") will be used.) -# (6) Only valid if VXLAN overlay is configured. -# The physical network name defined in the network_vlan_ranges variable -# (defined under the ml2_type_vlan section) that this switch is controlling. -# The configured 'physnet' is the physical network domain that is connected -# to this switch. The vlan ranges defined in network_vlan_ranges for a -# a physical network are allocated dynamically and are unique per physical -# network. These dynamic vlans may be reused across physical networks. -# -# Example: -# [ml2_mech_cisco_nexus:1.1.1.1] -# compute1=1/1 -# compute2=ethernet:1/2 -# compute3=port-channel:1 -# ssh_port=22 -# username=admin -# password=mySecretPassword -# nve_src_intf=1 -# physnet=physnet1 - -# (StrOpt) A short prefix to prepend to the VLAN number when creating a -# provider VLAN interface. For example, if an interface is being created -# for provider VLAN 3003 it will be named 'p-3003' using the default prefix. -# The total length allowed for the prefix name and VLAN is 32 characters, -# the prefix will be truncated if the total length is greater than 32. -# -# provider_vlan_name_prefix = p- -# Example: provider_vlan_name_prefix = PV- - -# (BoolOpt) A flag indicating whether OpenStack networking should manage the -# creation and removal of VLANs for provider networks on the Nexus -# switches. If the flag is set to False then OpenStack will not create or -# remove VLANs for provider networks, and the administrator needs to -# manage these interfaces manually or by external orchestration. -# -# provider_vlan_auto_create = True - -# (BoolOpt) A flag indicating whether OpenStack networking should manage -# the adding and removing of provider VLANs from trunk ports on the Nexus -# switches. If the flag is set to False then OpenStack will not add or -# remove provider VLANs from trunk ports, and the administrator needs to -# manage these operations manually or by external orchestration. -# -# provider_vlan_auto_trunk = True - -# (BoolOpt) A flag indicating whether OpenStack networking should manage the -# creating and removing of the Nexus switch VXLAN global settings of 'feature -# nv overlay', 'feature vn-segment-vlan-based', 'interface nve 1' and the NVE -# subcommand 'source-interface loopback #'. If the flag is set to False -# (default) then OpenStack will not add or remove these VXLAN settings, and -# the administrator needs to manage these operations manually or by external -# orchestration. -# -# vxlan_global_config = True - -# (BoolOpt) To make Nexus device persistent by running the Nexus -# CLI 'copy run start' after applying successful configurations. -# (default) This flag defaults to False keep consistent with -# existing functionality. -# -# persistent_switch_config = False - -# (IntOpt) Time interval to check the state of the Nexus device. -# (default) This value defaults to 0 seconds which disables this -# functionality. When enabled, 30 seconds is suggested. -# -# switch_heartbeat_time = 0 - -# (IntOpt) Number of times to attempt config replay with switch. -# This variable depends on switch_heartbeat_time being enabled. -# (default) This value defaults to 3 -# -# switch_replay_count = 3 - -[ml2_type_nexus_vxlan] -# (ListOpt) Comma-separated list of : tuples enumerating -# ranges of VXLAN Network IDs that are available for tenant network allocation. -# -# vni_ranges = -# Example: 100:1000,2000:6000 -# -# (ListOpt) Multicast groups for the VXLAN interface. When configured, will -# enable sending all broadcast traffic to this multicast group. Comma separated -# list of min:max ranges of multicast IP's. -# NOTE: must be a valid multicast IP, invalid IP's will be discarded -# -# mcast_ranges = -# Example: mcast_ranges = 224.0.0.1:224.0.0.3,224.0.1.1:224.0.1. - -[ml2_cisco_ucsm] - -# Cisco UCS Manager IP address -# ucsm_ip=1.1.1.1 - -# Username to connect to UCS Manager -# ucsm_username=user - -# Password to connect to UCS Manager -# ucsm_password=password - -# SR-IOV and VM-FEX vendors supported by this plugin -# xxxx:yyyy represents vendor_id:product_id -# supported_pci_devs = ['2222:3333', '4444:5555'] - -# Hostname to Service profile mapping for UCS Manager -# controlled compute hosts -# ucsm_host_list=Hostname1:Serviceprofile1, Hostname2:Serviceprofile2 diff --git a/neutron/db/migration/alembic_migrations/external.py b/neutron/db/migration/alembic_migrations/external.py index 267db137c..5d9f0beed 100644 --- a/neutron/db/migration/alembic_migrations/external.py +++ b/neutron/db/migration/alembic_migrations/external.py @@ -44,6 +44,7 @@ DRIVER_TABLES = [ 'cisco_ml2_nexus_nve', 'ml2_nexus_vxlan_allocations', 'ml2_nexus_vxlan_mcast_groups', + 'ml2_ucsm_port_profiles', # VMware-NSX models moved to openstack/vmware-nsx 'tz_network_bindings', 'neutron_nsx_network_mappings', diff --git a/neutron/db/migration/models/head.py b/neutron/db/migration/models/head.py index 5eb02213c..8ea0df5b6 100644 --- a/neutron/db/migration/models/head.py +++ b/neutron/db/migration/models/head.py @@ -55,7 +55,6 @@ from neutron.plugins.cisco.db import n1kv_models_v2 # noqa from neutron.plugins.cisco.db import network_models_v2 # noqa from neutron.plugins.ml2.drivers.brocade.db import ( # noqa models as ml2_brocade_models) -from neutron.plugins.ml2.drivers.cisco.ucsm import ucsm_model # noqa from neutron.plugins.ml2.drivers import type_flat # noqa from neutron.plugins.ml2.drivers import type_gre # noqa from neutron.plugins.ml2.drivers import type_vlan # noqa diff --git a/neutron/plugins/ml2/drivers/cisco/ucsm/__init__.py b/neutron/plugins/ml2/drivers/cisco/ucsm/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/neutron/plugins/ml2/drivers/cisco/ucsm/mech_cisco_ucsm.py b/neutron/plugins/ml2/drivers/cisco/ucsm/mech_cisco_ucsm.py deleted file mode 100644 index 8f88966bd..000000000 --- a/neutron/plugins/ml2/drivers/cisco/ucsm/mech_cisco_ucsm.py +++ /dev/null @@ -1,218 +0,0 @@ -# Copyright 2015 Cisco Systems, Inc. -# 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. - -from networking_cisco.plugins.ml2.drivers.cisco.ucsm import constants as const -from networking_cisco.plugins.ml2.drivers.cisco.ucsm import ucsm_db -from networking_cisco.plugins.ml2.drivers.cisco.ucsm import ucsm_network_driver - -from oslo_log import log as logging - -from neutron.common import constants -from neutron.extensions import portbindings -from neutron.i18n import _LE, _LW -from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api - -LOG = logging.getLogger(__name__) - - -class CiscoUcsmMechanismDriver(api.MechanismDriver): - - """ML2 Mechanism Driver for Cisco UCS Manager.""" - - def initialize(self): - self.vif_type = portbindings.VIF_TYPE_802_QBH - self.vif_details = {portbindings.CAP_PORT_FILTER: False} - self.driver = ucsm_network_driver.CiscoUcsmDriver() - self.ucsm_db = ucsm_db.UcsmDbModel() - - def _get_vlanid(self, context): - """Returns vlan_id associated with a bound VLAN segment.""" - segment = context.bottom_bound_segment - if segment and self.check_segment(segment): - return segment.get(api.SEGMENTATION_ID) - - def update_port_precommit(self, context): - """Adds port profile and vlan information to the DB. - - Assign a port profile to this port. To do that: - 1. Get the vlan_id associated with the bound segment - 2. Check if a port profile already exists for this vlan_id - 3. If yes, associate that port profile with this port. - 4. If no, create a new port profile with this vlan_id and - associate with this port - """ - LOG.debug("Inside update_port_precommit") - vnic_type = context.current.get(portbindings.VNIC_TYPE, - portbindings.VNIC_NORMAL) - - profile = context.current.get(portbindings.PROFILE, {}) - - if not self.driver.check_vnic_type_and_vendor_info(vnic_type, - profile): - LOG.debug("update_port_precommit encountered a non-SR-IOV port") - return - - # If this is an Intel SR-IOV vnic, then no need to create port - # profile on the UCS manager. So no need to update the DB. - if not self.driver.is_vmfex_port(profile): - LOG.debug("update_port_precommit has nothing to do for this " - "sr-iov port") - return - - vlan_id = self._get_vlanid(context) - - if not vlan_id: - LOG.warn(_LW("update_port_precommit: vlan_id is None.")) - return - - p_profile_name = self.make_profile_name(vlan_id) - LOG.debug("update_port_precommit: Profile: %s, VLAN_id: %d", - p_profile_name, vlan_id) - - # Create a new port profile entry in the db - self.ucsm_db.add_port_profile(p_profile_name, vlan_id) - - def update_port_postcommit(self, context): - """Creates a port profile on UCS Manager. - - Creates a Port Profile for this VLAN if it does not already - exist. - """ - LOG.debug("Inside update_port_postcommit") - vlan_id = self._get_vlanid(context) - - if not vlan_id: - LOG.warn(_LW("update_port_postcommit: vlan_id is None.")) - return - - # Check if UCS Manager needs to create a Port Profile. - # 1. Make sure this is a vm_fex_port.(Port profiles are created - # only for VM-FEX ports.) - # 2. Make sure update_port_precommit added an entry in the DB - # for this port profile - # 3. Make sure that the Port Profile hasn't already been created. - - profile = context.current.get(portbindings.PROFILE, {}) - vnic_type = context.current.get(portbindings.VNIC_TYPE, - portbindings.VNIC_NORMAL) - - if (self.driver.check_vnic_type_and_vendor_info(vnic_type, profile) and - self.driver.is_vmfex_port(profile)): - - LOG.debug("update_port_postcommit: VM-FEX port updated for " - "vlan_id %d", vlan_id) - - profile_name = self.ucsm_db.get_port_profile_for_vlan(vlan_id) - if self.ucsm_db.is_port_profile_created(vlan_id): - LOG.debug("update_port_postcommit: Port Profile %s for " - "vlan_id %d already exists. Nothing to do.", - profile_name, vlan_id) - return - - # Ask the UCS Manager driver to create the above Port Profile. - # Connection to the UCS Manager is managed from within the driver. - if self.driver.create_portprofile(profile_name, vlan_id, - vnic_type): - # Port profile created on UCS, record that in the DB. - self.ucsm_db.set_port_profile_created(vlan_id, profile_name) - return - - else: - # Enable vlan-id for this regular Neutron virtual port. - host_id = context.current.get(portbindings.HOST_ID) - LOG.debug("update_port_postcommit: Host_id is %s", host_id) - self.driver.update_serviceprofile(host_id, vlan_id) - - def delete_network_precommit(self, context): - """Delete entry corresponding to Network's VLAN in the DB.""" - - segments = context.network_segments - vlan_id = segments[0]['segmentation_id'] - - if vlan_id: - self.ucsm_db.delete_vlan_entry(vlan_id) - - def delete_network_postcommit(self, context): - """Delete all configuration added to UCS Manager for the vlan_id.""" - - segments = context.network_segments - vlan_id = segments[0]['segmentation_id'] - port_profile = self.make_profile_name(vlan_id) - - if vlan_id: - self.driver.delete_all_config_for_vlan(vlan_id, port_profile) - - def bind_port(self, context): - """Binds port to current network segment. - - Binds port only if the vnic_type is direct or macvtap and - the port is from a supported vendor. While binding port set it - in ACTIVE state and provide the Port Profile or Vlan Id as part - vif_details. - """ - vnic_type = context.current.get(portbindings.VNIC_TYPE, - portbindings.VNIC_NORMAL) - - LOG.debug("Attempting to bind port %(port)s with vnic_type " - "%(vnic_type)s on network %(network)s", - {'port': context.current['id'], - 'vnic_type': vnic_type, - 'network': context.network.current['id']}) - - profile = context.current.get(portbindings.PROFILE, {}) - - if not self.driver.check_vnic_type_and_vendor_info(vnic_type, - profile): - return - - for segment in context.network.network_segments: - if self.check_segment(segment): - vlan_id = segment[api.SEGMENTATION_ID] - - if not vlan_id: - LOG.warn(_LW("Bind port: vlan_id is None.")) - return - - LOG.debug("Port binding to Vlan_id: %s", str(vlan_id)) - - # Check if this is a Cisco VM-FEX port or Intel SR_IOV port - if self.driver.is_vmfex_port(profile): - profile_name = self.make_profile_name(vlan_id) - self.vif_details[ - const.VIF_DETAILS_PROFILEID] = profile_name - else: - self.vif_details[ - portbindings.VIF_DETAILS_VLAN] = str(vlan_id) - - context.set_binding(segment[api.ID], - self.vif_type, - self.vif_details, - constants.PORT_STATUS_ACTIVE) - return - - LOG.error(_LE("UCS Mech Driver: Failed binding port ID %(id)s " - "on any segment of network %(network)s"), - {'id': context.current['id'], - 'network': context.network.current['id']}) - - @staticmethod - def check_segment(segment): - network_type = segment[api.NETWORK_TYPE] - return network_type == p_const.TYPE_VLAN - - @staticmethod - def make_profile_name(vlan_id): - return const.PORT_PROFILE_NAME_PREFIX + str(vlan_id) diff --git a/neutron/plugins/ml2/drivers/cisco/ucsm/ucsm_model.py b/neutron/plugins/ml2/drivers/cisco/ucsm/ucsm_model.py deleted file mode 100644 index 05b164805..000000000 --- a/neutron/plugins/ml2/drivers/cisco/ucsm/ucsm_model.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2015 Cisco Systems, Inc. -# 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. - -import sqlalchemy as sa - -from neutron.db import model_base - - -class PortProfile(model_base.BASEV2): - - """Port profiles created on the UCS Manager.""" - - __tablename__ = 'ml2_ucsm_port_profiles' - - vlan_id = sa.Column(sa.Integer(), nullable=False, primary_key=True) - profile_id = sa.Column(sa.String(64), nullable=False) - created_on_ucs = sa.Column(sa.Boolean(), nullable=False) diff --git a/setup.cfg b/setup.cfg index 7a0a1d29b..9e332f9f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -65,7 +65,6 @@ data_files = etc/neutron/plugins/ml2/ml2_conf.ini etc/neutron/plugins/ml2/ml2_conf_brocade.ini etc/neutron/plugins/ml2/ml2_conf_brocade_fi_ni.ini - etc/neutron/plugins/ml2/ml2_conf_cisco.ini etc/neutron/plugins/ml2/ml2_conf_ofa.ini etc/neutron/plugins/ml2/ml2_conf_fslsdn.ini etc/neutron/plugins/ml2/ml2_conf_sriov.ini @@ -166,7 +165,6 @@ neutron.ml2.mechanism_drivers = linuxbridge = neutron.plugins.ml2.drivers.linuxbridge.mech_driver.mech_linuxbridge:LinuxbridgeMechanismDriver openvswitch = neutron.plugins.ml2.drivers.openvswitch.mech_driver.mech_openvswitch:OpenvswitchMechanismDriver hyperv = neutron.plugins.ml2.drivers.hyperv.mech_hyperv:HypervMechanismDriver - cisco_ucsm = neutron.plugins.ml2.drivers.cisco.ucsm.mech_cisco_ucsm:CiscoUcsmMechanismDriver l2population = neutron.plugins.ml2.drivers.l2pop.mech_driver:L2populationMechanismDriver ofagent = neutron.plugins.ml2.drivers.ofagent.driver:OfagentMechanismDriver mlnx = neutron.plugins.ml2.drivers.mlnx.mech_mlnx:MlnxMechanismDriver -- 2.45.2