From 3c461229f83fc03064c074939b91f38b012fc528 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Fri, 5 Aug 2011 02:59:54 -0700 Subject: [PATCH] Loading of device-specific plugins and drivers is done dynamically by setting configuration. All configuration is driven through configuration files place in the conf directory. Each .ini conf file contains info on the configuration. README file updated to reflect all the changes. Fixed issue with delete_network deleting the network even when attachments were present. Fixed issue with port id generation. --- etc/quantum.conf | 5 - quantum/plugins/cisco/README | 78 +++------------ .../cisco/common/cisco_configparser.py | 49 ++++++++++ .../cisco/common/cisco_configuration.py | 97 ------------------- .../plugins/cisco/common/cisco_constants.py | 51 ++++++++++ .../plugins/cisco/common/cisco_credentials.py | 49 +++++----- .../cisco/common/cisco_nova_configuration.py | 42 ++++++++ quantum/plugins/cisco/common/cisco_utils.py | 6 +- quantum/plugins/cisco/conf/credentials.ini | 15 +++ .../plugins/cisco/conf/l2network_plugin.ini | 11 +++ quantum/plugins/cisco/conf/nexus.ini | 8 ++ quantum/plugins/cisco/conf/nova.ini | 8 ++ quantum/plugins/cisco/conf/plugins.ini | 4 + quantum/plugins/cisco/conf/ucs.ini | 10 ++ quantum/plugins/cisco/l2network_plugin.py | 82 ++++++++-------- .../cisco/l2network_plugin_configuration.py | 51 ++++++++++ .../cisco/nexus/cisco_nexus_configuration.py | 42 ++++++++ .../cisco/nexus/cisco_nexus_network_driver.py | 1 - .../plugins/cisco/nexus/cisco_nexus_plugin.py | 8 +- .../cisco/ucs/{get-vif.py => cisco_getvif.py} | 23 ++++- .../cisco/ucs/cisco_ucs_configuration.py | 44 +++++++++ .../cisco/ucs/cisco_ucs_network_driver.py | 19 ++-- quantum/plugins/cisco/ucs/cisco_ucs_plugin.py | 7 +- quantum/plugins/cisco/ucs/get-vif.sh | 15 --- 24 files changed, 449 insertions(+), 276 deletions(-) create mode 100644 quantum/plugins/cisco/common/cisco_configparser.py delete mode 100644 quantum/plugins/cisco/common/cisco_configuration.py create mode 100644 quantum/plugins/cisco/common/cisco_nova_configuration.py create mode 100644 quantum/plugins/cisco/conf/credentials.ini create mode 100644 quantum/plugins/cisco/conf/l2network_plugin.ini create mode 100644 quantum/plugins/cisco/conf/nexus.ini create mode 100644 quantum/plugins/cisco/conf/nova.ini create mode 100644 quantum/plugins/cisco/conf/plugins.ini create mode 100644 quantum/plugins/cisco/conf/ucs.ini create mode 100644 quantum/plugins/cisco/l2network_plugin_configuration.py create mode 100644 quantum/plugins/cisco/nexus/cisco_nexus_configuration.py rename quantum/plugins/cisco/ucs/{get-vif.py => cisco_getvif.py} (60%) create mode 100644 quantum/plugins/cisco/ucs/cisco_ucs_configuration.py delete mode 100755 quantum/plugins/cisco/ucs/get-vif.sh diff --git a/etc/quantum.conf b/etc/quantum.conf index 6bd962790..2580913c3 100644 --- a/etc/quantum.conf +++ b/etc/quantum.conf @@ -15,14 +15,9 @@ bind_port = 9696 use = egg:Paste#urlmap /: quantumversions /v0.1: quantumapi -/v0.1/extensions:cisco_extensions [app:quantumversions] paste.app_factory = quantum.api.versions:Versions.factory [app:quantumapi] paste.app_factory = quantum.api:APIRouterV01.factory - -[app:cisco_extensions] -paste.app_factory = cisco_extensions:ExtRouterV01.factory - diff --git a/quantum/plugins/cisco/README b/quantum/plugins/cisco/README index b77ce22ca..f8711193a 100644 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@ -7,9 +7,13 @@ * UCS B200 series blades with M81KR VIC installed. * UCSM 2.0 (Capitola) Build 230 * RHEL 6.1 -* ncclcient v0.3.1 - Python library for NETCONF clients (http://schmizz.net/ncclient/) * UCS & VIC installation (support for KVM) - please consult the accompanying installation guide available at: http://wikicentral.cisco.com/display/GROUP/SAVBU+Palo+VM-FEX+for+Linux+KVM + +* If you have a Nexus switch in your topology and decide to turn on Nexus support, you will need: + - ncclcient v0.3.1 - Python library for NETCONF clients (http://schmizz.net/ncclient/). + - paramiko library (do: yum install python-paramiko.noarch) + * To run Quantum on RHEL, you will need to have the correct version of python-routes (version 1.12.3 or later). The RHEL 6.1 package contains an older version. Do the following and check your python-routes version: rpm -qav | grep "python-routes" @@ -26,64 +30,12 @@ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-OPENSTACK ** Plugin Installation Instructions: * Make a backup copy of quantum/quantum/plugins.ini, and edit the file to remove all exisiting entries and add the following entry: provider = quantum.plugins.cisco.l2network_plugin.L2Network -* You should have the following files in quantum/quantum/plugins/cisco directory (if you have pulled the Cisco Quantum branch, you will already have them): -l2network_plugin.py -common/cisco_configuration.py -common/cisco_constants.py -common/cisco_credentials.py -common/cisco_exceptions.py -nexus/cisco_nexus_plugin.py -ucs/cisco_ucs_network_driver.py -ucs/cisco_ucs_plugin.py -common/cisco_utils.py -__init__.py -ucs/get-vif.sh -* Configure the L2 Network Plugin: - + In cisco_configuration.py, - - change the UCSM IP in the following statement to your UCSM IP - flags.DEFINE_string('ucsm_ip_address', "172.20.231.27", 'IP address of UCSM') - - change the Nova MySQL DB IP if you are running Quantum on a different host than the OpenStack Cloud Controller (in other words you do not need to change the IP if Quantum is running on the same host on which the Nova DB is running). DB IP is changed in the following statement: - flags.DEFINE_string('db_server_ip', "127.0.0.1", 'IP address of nova DB server') - - change the hostname of the OpenStack Cloud Controller below - flags.DEFINE_string('nova_host_name', "openstack-0203", 'nova cloud controller hostname') - - change the name of the OpenStack project - flags.DEFINE_string('nova_proj_name', "demo", 'project created in nova') - - change the start range of the VLAN (if you are not sure about this number, leave this unchanged) - flags.DEFINE_string('vlan_start', "100", 'This is the start value of the allowable VLANs') - - change the end range of the VLAN (if you are not sure about this number, leave this unchanged) - flags.DEFINE_string('vlan_end', "3000", 'This is the end value of the allowable VLANs') - - unless you have VLANs created in UCSM which start with the name "q-", you do not need to change the following property. If you do need to change it, change "q-" to some other string. Do not use more than 6 characters. - flags.DEFINE_string('vlan_name_prefix', "q-", 'Prefix of the name given to the VLAN') - - unless you have Port Profiles created in UCSM which start with the name "q-", you do not need to change the following property. If you do need to change it, change "q-" to some other string. Do not use more than 6 characters. - flags.DEFINE_string('profile_name_prefix', "q-", 'Prefix of the name given to the port profile') - - Change the path to reflect the location of the get-vif.sh script, if you have followed the instructions in this README, this location should be the same as that of your other plugin modules - flags.DEFINE_string('get_next_vif', "/root/sumit/quantum/quantum/plugins/cisco/get-vif.sh", 'This is the location of the script to get the next available dynamic nic') - - + In cisco_credentials.py, - - Change the following structure to reflect the correct UCS, N7K and Nova DB details. Your UCSM_IP_ADDRESS has to match the ucsmm_ip_addresss which you provided in the cisco_configuration file earlier. Similarly, your NOVA_DATABSE_IP has to match the db_server_ip which you provided earlier. DB_USERNAME and DB_PASSWORD are those which you provided for the Nova MySQL DB when you setup OpenStack - N7K_IP_ADDRESS has to match with your Nexus 7k switch IP Address, N7K_USERNAME is the administrator user-name and N7K_PASSWORD is the password. - _creds_dictionary = { - 'UCSM_IP_ADDRESS':["UCSM_USERNAME", "UCSM_PASSWORD"], - 'NOVA_DATABASE_IP':["DB_USERNAME", "DB_PASSWORD"] - } - -* Configure the L2 Network Plugin with Nexus OS Driver for testing VLANs CRUD on Nexus 7k Switch. Making these changes requires one Nexus 7K Switch connected to the UCSM and the ncclient patch not just the regular library, otherwise the system will fail. - + In cisco_configuration.py, - - change the NEXUS 7K IP in the following statement to your N7K Switch IP - flags.DEFINE_string('nexus_ip_address', "172.20.231.61", 'IP address of N7K') - - change the NEXUS Interface in the following statement to the interface number in your N7K which is connected to your UCSM UpLink port - flags.DEFINE_string('nexus_port', "3/23", 'Port number of the Interface connected from the Nexus 7K Switch to UCSM 6120') - - change NEXUS Driver Flag to "on" in the following statement - flags.DEFINE_string('nexus_driver_active', "off", 'Flag to activate Nexus OS Driver') - - + In cisco_credentials.py, - - Change the following structure to reflect the correct UCS, N7K and Nova DB details. Your UCSM_IP_ADDRESS has to match the ucsmm_ip_addresss which you provided in the cisco_configuration file earlier. Similarly, your NOVA_DATABSE_IP has to match the db_server_ip which you provided earlier. DB_USERNAME and DB_PASSWORD are those which you provided for the Nova MySQL DB when you setup OpenStack - N7K_IP_ADDRESS has to match with your Nexus 7k switch IP Address, N7K_USERNAME is the administrator user-name and N7K_PASSWORD is the password. - _creds_dictionary = { - 'UCSM_IP_ADDRESS':["UCSM_USERNAME", "UCSM_PASSWORD"], - 'N7K_IP_ADDRESS':["N7K_USERNAME", "N7K_PASSWORD"], - 'NOVA_DATABASE_IP':["DB_USERNAME", "DB_PASSWORD"] - } + +* All configuration files are located under quantum/plugins/cisco/conf. Where you find kind of placeholder, please replace it entirely with the relevant values (don't forget to remove the angle brackets as well) + +* If you are not running Quantum on the same host as the OpenStack Cloud Controller, you will need to change the db_ip_address configuration in nova.ini + +* If you want to turn on Nexus support, please uncomment the nexus_plugin property in the nexus.ini file. You will also require a patch to the ncclient in addition to the library mentioned in the prerequisities. * Start the Quantum service @@ -98,11 +50,3 @@ mysql -uroot -p nova -e 'create table ports (port_id VARCHA /usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py * Restart nova-compute service - -**L2network database usage requirements - -* mysql database "quantum_l2network" is required for persistence of the l2network plugin data. - + The database can be created as follows - - - # mysql -uroot -pnova; (username/password here is root/nova) - - mysql> create database quantum_l2network; - - mysql> use quantum_l2network; - + The database and login details must be specified in quantum/plugins/cisco/db/db_conn.ini. diff --git a/quantum/plugins/cisco/common/cisco_configparser.py b/quantum/plugins/cisco/common/cisco_configparser.py new file mode 100644 index 000000000..312c230ac --- /dev/null +++ b/quantum/plugins/cisco/common/cisco_configparser.py @@ -0,0 +1,49 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# + +import logging as LOG +import os + +from configobj import ConfigObj +from validate import Validator + +from quantum.plugins.cisco.common import cisco_constants as const +from quantum.plugins.cisco.common import cisco_exceptions as cexc + +LOG.basicConfig(level=LOG.WARN) +LOG.getLogger(const.LOGGER_COMPONENT_NAME) + + +class CiscoConfigParser(ConfigObj): + + def __init__(self, filename): + super(CiscoConfigParser, self).__init__(filename, raise_errors=True, + file_error=True) + + def dummy(self, section, key): + return section[key] + + +def main(): + cp = CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + "test.ini") + print ("%s\n") % cp['PLUGIN']['provider'] + +if __name__ == '__main__': + main() diff --git a/quantum/plugins/cisco/common/cisco_configuration.py b/quantum/plugins/cisco/common/cisco_configuration.py deleted file mode 100644 index 01762e5fa..000000000 --- a/quantum/plugins/cisco/common/cisco_configuration.py +++ /dev/null @@ -1,97 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright 2011 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. -# -# @author: Sumit Naiksatam, Cisco Systems, Inc. -# @author: Edgar Magana, Cisco Systems, Inc. -# -from quantum.common import flags - -# Note: All configuration values defined here are strings -FLAGS = flags.FLAGS -# -# TODO (Sumit): The following are defaults, but we also need to add to config -# file -# -flags.DEFINE_string('ucsm_ip_address', "172.20.231.27", 'IP address of \ - UCSM') -flags.DEFINE_string('nexus_ip_address', "172.20.231.61", 'IP address of \ - Nexus Switch') -flags.DEFINE_string('nexus_port', "3/23", 'Port number of the Interface \ - connected from the Nexus Switch to UCSM 6120') -flags.DEFINE_string('nexus_driver_active', "off", 'Flag to activate Nexus OS\ - Driver') -flags.DEFINE_string('db_server_ip', "127.0.0.1", 'IP address of nova DB \ - server') -flags.DEFINE_string('nova_host_name', "openstack-0203", 'nova cloud \ - controller hostname') - -flags.DEFINE_string('db_name', "nova", 'DB name') -flags.DEFINE_string('vlan_name_prefix', "q-", 'Prefix of the name given \ - to the VLAN') -flags.DEFINE_string('profile_name_prefix', "q-", 'Prefix of the name \ - given to the port profile') -flags.DEFINE_string('vlan_start', "100", 'This is the start value of the \ - allowable VLANs') -flags.DEFINE_string('vlan_end', "3000", 'This is the end value of the \ - allowable VLANs') -flags.DEFINE_string('default_vlan_name', "default", 'This is the name of \ - the VLAN which will be associated with the port profile \ - when it is created, by default the VMs will be on this \ - VLAN, until attach is called') -flags.DEFINE_string('default_vlan_id', "1", 'This is the name of the VLAN \ - which will be associated with the port profile when it \ - is created, by default the VMs will be on this VLAN, \ - until attach is called') -flags.DEFINE_string('nova_proj_name', "demo", 'project created in nova') -# -# TODO (Sumit): SAVBU to provide the accurate number below -# -flags.DEFINE_string('max_ucsm_port_profiles', "1024", 'This is the maximum \ - number port profiles that can be handled by one UCSM.') -flags.DEFINE_string('max_port_profiles', "65568", 'This is the maximum \ - number port profiles that can be handled by Cisco \ - plugin. Currently this is just an arbitrary number.') -flags.DEFINE_string('max_networks', "65568", 'This is the maximum number \ - of networks that can be handled by Cisco plugin. \ - Currently this is just an arbitrary number.') - -flags.DEFINE_string('get_next_vif', - "/root/sumit/quantum/quantum/plugins/cisco/get-vif.sh", - 'This is the location of the script to get the next \ - next available dynamic nic') - -# Inventory items -UCSM_IP_ADDRESS = FLAGS.ucsm_ip_address -NEXUS_IP_ADDRESS = FLAGS.nexus_ip_address -NEXUS_DRIVER_ACTIVE = FLAGS.nexus_driver_active -NEXUS_PORT = FLAGS.nexus_port -DB_SERVER_IP = FLAGS.db_server_ip -NOVA_HOST_NAME = FLAGS.nova_host_name - -# General configuration items -DB_NAME = FLAGS.db_name -VLAN_NAME_PREFIX = FLAGS.vlan_name_prefix -PROFILE_NAME_PREFIX = FLAGS.profile_name_prefix -VLAN_START = FLAGS.vlan_start -VLAN_END = FLAGS.vlan_end -DEFAULT_VLAN_NAME = FLAGS.default_vlan_name -DEFAULT_VLAN_ID = FLAGS.default_vlan_id -NOVA_PROJ_NAME = FLAGS.nova_proj_name -MAX_UCSM_PORT_PROFILES = FLAGS.max_ucsm_port_profiles -MAX_PORT_PROFILES = FLAGS.max_port_profiles -MAX_NETWORKS = FLAGS.max_networks - -GET_NEXT_VIF_SCRIPT = FLAGS.get_next_vif diff --git a/quantum/plugins/cisco/common/cisco_constants.py b/quantum/plugins/cisco/common/cisco_constants.py index 7f2367d79..b14ce0934 100644 --- a/quantum/plugins/cisco/common/cisco_constants.py +++ b/quantum/plugins/cisco/common/cisco_constants.py @@ -17,6 +17,8 @@ # @author: Sumit Naiksatam, Cisco Systems, Inc. # +PLUGINS = 'PLUGINS' + PORT_STATE = 'port-state' PORT_UP = "UP" PORT_DOWN = "DOWN" @@ -35,6 +37,8 @@ TENANT_ID = 'tenant-id' TENANT_NETWORKS = 'tenant-networks' TENANT_NAME = 'tenant-name' TENANT_PORTPROFILES = 'tenant-portprofiles' +TENANT_QOS_LEVELS = 'tenant-qos-levels' +TENANT_CREDENTIALS = 'tenant-credentials' PORT_PROFILE = 'port-profile' PROFILE_ID = 'profile-id' @@ -44,4 +48,51 @@ PROFILE_VLAN_ID = 'vlan-id' PROFILE_QOS = 'profile-qos' PROFILE_ASSOCIATIONS = 'assignment' +QOS_LEVEL_ID = 'qos-id' +QOS_LEVEL_NAME = 'qos-name' +QOS_LEVEL_ASSOCIATIONS = 'qos-level-associations' +QOS_LEVEL_DESCRIPTION = 'qos-desc' + +CREDENTIAL_ID = 'credential-id' +CREDENTIAL_NAME = 'credential-name' +CREDENTIAL_USERNAME = 'credential-username' +CREDENTIAL_PASSWORD = 'credential-password' +MASKED_PASSWORD = '********' + +USERNAME = 'username' +PASSWORD = 'password' + LOGGER_COMPONENT_NAME = "cisco_plugin" + +BLADE_INTF_DN = "blade-intf-distinguished-name" +BLADE_INTF_ORDER = "blade-intf-order" +BLADE_INTF_LINK_STATE = "blade-intf-link-state" +BLADE_INTF_OPER_STATE = "blade-intf-operational-state" +BLADE_INTF_INST_TYPE = "blade-intf-inst-type" +BLADE_INTF_RHEL_DEVICE_NAME = "blade-intf-rhel-device-name" +BLADE_INTF_DYNAMIC = "dynamic" +BLADE_INTF_STATE_UNKNOWN = "unknown" +BLADE_INTF_STATE_UNALLOCATED = "unallocated" +BLADE_INTF_RESERVED = "blade-intf-reserved" +BLADE_INTF_UNRESERVED = "blade-intf-unreserved" +BLADE_INTF_RESERVATION = "blade-intf-reservation-status" +BLADE_UNRESERVED_INTF_COUNT = "blade-unreserved-interfaces-count" +BLADE_INTF_DATA = "blade-intf-data" + +LEAST_RSVD_BLADE_UCSM = "least-reserved-blade-ucsm" +LEAST_RSVD_BLADE_CHASSIS = "least-reserved-blade-chassis" +LEAST_RSVD_BLADE_ID = "least-reserved-blade-id" +LEAST_RSVD_BLADE_DATA = "least-reserved-blade-data" + +RESERVED_NIC_HOSTNAME = "reserved-dynamic-nic-hostname" +RESERVED_NIC_NAME = "reserved-dynamic-nic-device-name" + +RESERVED_INTERFACE_UCSM = "reserved-interface-ucsm-ip" +RESERVED_INTERFACE_CHASSIS = "reserved-interface-chassis" +RESERVED_INTERFACE_BLADE = "reserved-interface-blade" +RESERVED_INTERFACE_DN = "reserved-interface-dn" + +RHEL_DEVICE_NAME_REPFIX = "eth" + +UCS_PLUGIN = 'ucs_plugin' +NEXUS_PLUGIN = 'nexus_plugin' diff --git a/quantum/plugins/cisco/common/cisco_credentials.py b/quantum/plugins/cisco/common/cisco_credentials.py index cdbb6c379..edc2288cd 100644 --- a/quantum/plugins/cisco/common/cisco_credentials.py +++ b/quantum/plugins/cisco/common/cisco_credentials.py @@ -18,54 +18,51 @@ # import logging as LOG +import os from quantum.plugins.cisco.common import cisco_constants as const +from quantum.plugins.cisco.common import cisco_configparser as confp LOG.basicConfig(level=LOG.WARN) LOG.getLogger(const.LOGGER_COMPONENT_NAME) -_creds_dictionary = {'10.10.10.10': ["username", "password"], - '127.0.0.1': ["root", "nova"]} +CREDENTIALS_FILE = "../conf/credentials.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CREDENTIALS_FILE) +_creds_dictionary = cp.walk(cp.dummy) class Store(object): - # The format for this store is {"ip-address" :{"username", "password"}} - def __init__(self): - pass + @staticmethod + def putCredential(id, username, password): + _creds_dictionary[id] = {const.USERNAME: username, + const.PASSWORD: password} @staticmethod - def putId(id): - _creds_dictionary[id] = [] + def getUsername(id): + return _creds_dictionary[id][const.USERNAME] @staticmethod - def putUsername(id, username): - creds = _creds_dictionary.get(id) - creds.insert(0, username) + def getPassword(id): + return _creds_dictionary[id][const.PASSWORD] @staticmethod - def putPassword(id, password): - creds = _creds_dictionary.get(id) - creds.insert(1, password) + def getCredential(id): + return _creds_dictionary[id] @staticmethod - def getUsername(id): - creds = _creds_dictionary.get(id) - return creds[0] + def getCredentials(): + return _creds_dictionary @staticmethod - def getPassword(id): - creds = _creds_dictionary.get(id) - return creds[1] + def deleteCredential(id): + return _creds_dictionary.pop(id) def main(): - LOG.debug("username %s\n" % Store.getUsername("172.20.231.27")) - LOG.debug("password %s\n" % Store.getPassword("172.20.231.27")) - Store.putId("192.168.1.1") - Store.putUsername("192.168.1.1", "guest-username") - Store.putPassword("192.168.1.1", "guest-password") - LOG.debug("username %s\n" % Store.getUsername("192.168.1.1")) - LOG.debug("password %s\n" % Store.getPassword("192.168.1.1")) + Store.putCredential("10.10.10.10", "foo", "bar") + print ("%s\n") % Store.getCredentials() if __name__ == '__main__': main() diff --git a/quantum/plugins/cisco/common/cisco_nova_configuration.py b/quantum/plugins/cisco/common/cisco_nova_configuration.py new file mode 100644 index 000000000..f1cbf2a1e --- /dev/null +++ b/quantum/plugins/cisco/common/cisco_nova_configuration.py @@ -0,0 +1,42 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# + +import os + +from quantum.plugins.cisco.common import cisco_configparser as confp + +CONF_FILE = "../conf/nova.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CONF_FILE) + +section = cp['NOVA'] +DB_SERVER_IP = section['db_server_ip'] +DB_NAME = section['db_name'] +DB_USERNAME = section['db_username'] +DB_PASSWORD = section['db_password'] +NOVA_HOST_NAME = section['nova_host_name'] +NOVA_PROJ_NAME = section['nova_proj_name'] + + +def main(): + print NOVA_PROJ_NAME + +if __name__ == '__main__': + main() diff --git a/quantum/plugins/cisco/common/cisco_utils.py b/quantum/plugins/cisco/common/cisco_utils.py index 8d0d803b3..695136db8 100644 --- a/quantum/plugins/cisco/common/cisco_utils.py +++ b/quantum/plugins/cisco/common/cisco_utils.py @@ -23,9 +23,9 @@ import sys import traceback from quantum.common import exceptions as exc -from quantum.plugins.cisco.common import cisco_configuration as conf from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred +from quantum.plugins.cisco.common import cisco_nova_configuration as conf LOG.basicConfig(level=LOG.WARN) LOG.getLogger(const.LOGGER_COMPONENT_NAME) @@ -38,8 +38,8 @@ class DBUtils(object): def _get_db_connection(self): db_ip = conf.DB_SERVER_IP - db_username = cred.Store.getUsername(db_ip) - db_password = cred.Store.getPassword(db_ip) + db_username = conf.DB_USERNAME + db_password = conf.DB_PASSWORD self.db = MySQLdb.connect(db_ip, db_username, db_password, conf.DB_NAME) return self.db diff --git a/quantum/plugins/cisco/conf/credentials.ini b/quantum/plugins/cisco/conf/credentials.ini new file mode 100644 index 000000000..96e912cc7 --- /dev/null +++ b/quantum/plugins/cisco/conf/credentials.ini @@ -0,0 +1,15 @@ +#Provide the UCSM credentials +[] +username= +password= + +#Provide the Nova DB credentials, the IP address should be the same as in nova.ini +[] +username= +password= + +#Provide the Nexus credentials, if you are using Nexus +[] +username= +password= + diff --git a/quantum/plugins/cisco/conf/l2network_plugin.ini b/quantum/plugins/cisco/conf/l2network_plugin.ini new file mode 100644 index 000000000..f6ac8613b --- /dev/null +++ b/quantum/plugins/cisco/conf/l2network_plugin.ini @@ -0,0 +1,11 @@ +[VLANS] +#Change the following to reflect the VLAN range in your system +vlan_start=100 +vlan_end=3000 +vlan_name_prefix=q- + +[PORTS] +max_ports=100 + +[NETWORKS] +max_networks=65568 diff --git a/quantum/plugins/cisco/conf/nexus.ini b/quantum/plugins/cisco/conf/nexus.ini new file mode 100644 index 000000000..fede46eb8 --- /dev/null +++ b/quantum/plugins/cisco/conf/nexus.ini @@ -0,0 +1,8 @@ +[SWITCH] +# Change the following to reflect the Nexus switch details +nexus_ip_address= +#Port number of the Interface connected from the Nexus 7K Switch to UCSM 6120, e.g.: 3/23 +nexus_port= + +[DRIVER] +name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver.CiscoNEXUSDriver diff --git a/quantum/plugins/cisco/conf/nova.ini b/quantum/plugins/cisco/conf/nova.ini new file mode 100644 index 000000000..357a58643 --- /dev/null +++ b/quantum/plugins/cisco/conf/nova.ini @@ -0,0 +1,8 @@ +[NOVA] +#Change the following details to reflect your OpenStack Nova configuration. If you are running this service on the same machine as the Nova DB, you do not have to change the IP address. +db_server_ip=127.0.0.1 +db_name=nova +db_username=root +db_password=nova +nova_host_name=openstack0203 +nova_proj_name=demo diff --git a/quantum/plugins/cisco/conf/plugins.ini b/quantum/plugins/cisco/conf/plugins.ini new file mode 100644 index 000000000..15f6e5412 --- /dev/null +++ b/quantum/plugins/cisco/conf/plugins.ini @@ -0,0 +1,4 @@ +[PLUGINS] +ucs_plugin=quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin +#Uncomment the following line if you want to enable Nexus support +#nexus_plugin=quantum.plugins.cisco.ucs.cisco_nexus_plugin.NexusPlugin diff --git a/quantum/plugins/cisco/conf/ucs.ini b/quantum/plugins/cisco/conf/ucs.ini new file mode 100644 index 000000000..431025313 --- /dev/null +++ b/quantum/plugins/cisco/conf/ucs.ini @@ -0,0 +1,10 @@ +[UCSM] +#change the following to the appropriate UCSM IP address +ip_address= +default_vlan_name=default +default_vlan_id=1 +max_ucsm_port_profiles=1024 +profile_name_prefix=q- + +[DRIVER] +name=quantum.plugins.cisco.ucs.cisco_ucs_network_driver.CiscoUCSMDriver diff --git a/quantum/plugins/cisco/l2network_plugin.py b/quantum/plugins/cisco/l2network_plugin.py index 9a8c4a4f0..e34a1c491 100644 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@ -15,18 +15,16 @@ # under the License. # # @author: Sumit Naiksatam, Cisco Systems, Inc. -# @author: Edgar Magana, Cisco Systems, Inc. # import logging as LOG from quantum.common import exceptions as exc -from quantum.plugins.cisco.common import cisco_configuration as conf +from quantum.common import utils +from quantum.plugins.cisco import l2network_plugin_configuration as conf from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred from quantum.plugins.cisco.common import cisco_exceptions as cexc -from quantum.plugins.cisco.nexus import cisco_nexus_plugin -from quantum.plugins.cisco.ucs import cisco_ucs_plugin from quantum.plugins.cisco.common import cisco_utils as cutil LOG.basicConfig(level=LOG.WARN) @@ -37,13 +35,18 @@ class L2Network(object): _networks = {} _tenants = {} _portprofiles = {} + _plugins = {} def __init__(self): self._net_counter = 0 self._portprofile_counter = 0 + self._port_counter = 0 self._vlan_counter = int(conf.VLAN_START) - 1 - self._ucs_plugin = cisco_ucs_plugin.UCSVICPlugin() - self._nexus_plugin = cisco_nexus_plugin.NexusPlugin() + for key in conf.plugins[const.PLUGINS].keys(): + self._plugins[key] = utils.import_object( + conf.plugins[const.PLUGINS][key]) + LOG.debug("Loaded device plugin %s\n" % \ + conf.plugins[const.PLUGINS][key]) """ Core API implementation @@ -66,15 +69,9 @@ class L2Network(object): new_net_id = self._get_unique_net_id(tenant_id) vlan_id = self._get_vlan_for_tenant(tenant_id, net_name) vlan_name = self._get_vlan_name(new_net_id, str(vlan_id)) - nexus_driver_flag = conf.NEXUS_DRIVER_ACTIVE - if nexus_driver_flag == 'on': - LOG.debug("Nexus OS Driver called\n") - self._nexus_plugin.create_network(tenant_id, net_name, new_net_id, - vlan_name, vlan_id) - else: - LOG.debug("No Nexus OS Driver available\n") - self._ucs_plugin.create_network(tenant_id, net_name, new_net_id, - vlan_name, vlan_id) + for pluginClass in self._plugins.values(): + pluginClass.create_network(tenant_id, net_name, + new_net_id, vlan_name, vlan_id) new_net_dict = {const.NET_ID: new_net_id, const.NET_NAME: net_name, const.NET_PORTS: {}, @@ -94,18 +91,20 @@ class L2Network(object): """ LOG.debug("delete_network() called\n") net = self._networks.get(net_id) - nexus_driver_flag = conf.NEXUS_DRIVER_ACTIVE # TODO (Sumit) : Verify that no attachments are plugged into the # network if net: + if len(net[const.NET_PORTS].values()) > 0: + ports_on_net = net[const.NET_PORTS].values() + for port in ports_on_net: + if port[const.ATTACHMENT]: + raise exc.NetworkInUse(net_id=net_id) + for port in ports_on_net: + self.delete_port(tenant_id, net_id, port[const.PORT_ID]) # TODO (Sumit) : Before deleting the network, make sure all the # ports associated with this network are also deleted - if nexus_driver_flag == 'on': - LOG.debug("Nexus OS Driver called\n") - self._nexus_plugin.delete_network(tenant_id, net_id) - else: - LOG.debug("No Nexus OS Driver available\n") - self._ucs_plugin.delete_network(tenant_id, net_id) + for pluginClass in self._plugins.values(): + pluginClass.delete_network(tenant_id, net_id) self._networks.pop(net_id) tenant = self._get_tenant(tenant_id) tenant_networks = tenant[const.TENANT_NETWORKS] @@ -129,13 +128,8 @@ class L2Network(object): Virtual Network. """ LOG.debug("rename_network() called\n") - nexus_driver_flag = conf.NEXUS_DRIVER_ACTIVE - if nexus_driver_flag == 'on': - LOG.debug("Nexus OS Driver called\n") - self._nexus_plugin.rename_network(tenant_id, net_id) - else: - LOG.debug("No Nexus OS Driver available\n") - self._ucs_plugin.rename_network(tenant_id, net_id) + for pluginClass in self._plugins.values(): + pluginClas.rename_network(tenant_id, net_id) network = self._get_network(tenant_id, net_id) network[const.NET_NAME] = new_name return network @@ -158,8 +152,9 @@ class L2Network(object): net = self._get_network(tenant_id, net_id) ports = net[const.NET_PORTS] unique_port_id_string = self._get_unique_port_id(tenant_id, net_id) - self._ucs_plugin.create_port(tenant_id, net_id, port_state, - unique_port_id_string) + self._plugins[const.UCS_PLUGIN].create_port(tenant_id, net_id, + port_state, + unique_port_id_string) new_port_dict = {const.PORT_ID: unique_port_id_string, const.PORT_STATE: const.PORT_UP, const.ATTACHMENT: None} @@ -181,7 +176,8 @@ class L2Network(object): try: #TODO (Sumit): Before deleting port profile make sure that there # is no VM using this port profile - self._ucs_plugin.delete_port(tenant_id, net_id, port_id) + self._plugins[const.UCS_PLUGIN].delete_port(tenant_id, net_id, + port_id) net = self._get_network(tenant_id, net_id) net[const.NET_PORTS].pop(port_id) except KeyError: @@ -218,8 +214,9 @@ class L2Network(object): if port[const.ATTACHMENT]: raise exc.PortInUse(net_id=net_id, port_id=port_id, att_id=port[const.ATTACHMENT]) - self._ucs_plugin.plug_interface(tenant_id, net_id, port_id, - remote_interface_id) + self._plugins[const.UCS_PLUGIN].plug_interface(tenant_id, + net_id, port_id, + remote_interface_id) port[const.ATTACHMENT] = remote_interface_id def unplug_interface(self, tenant_id, net_id, port_id): @@ -229,8 +226,8 @@ class L2Network(object): """ LOG.debug("unplug_interface() called\n") port = self._get_port(tenant_id, net_id, port_id) - self._ucs_plugin.unplug_interface(tenant_id, net_id, - port_id) + self._plugins[const.UCS_PLUGIN].unplug_interface(tenant_id, net_id, + port_id) port[const.ATTACHMENT] = None """ @@ -361,17 +358,15 @@ class L2Network(object): "-n-" + ("0" * (6 - len(str(self._net_counter)))) + \ str(self._net_counter) # TODO (Sumit): Need to check if the ID has already been allocated + # ID will be generated by DB return id def _get_unique_port_id(self, tenant_id, net_id): - net = self._get_network(tenant_id, net_id) - ports = net[const.NET_PORTS] - if len(ports) == 0: - new_port_id = 1 - else: - new_port_id = max(ports.keys()) + 1 - id = net_id + "-p-" + str(new_port_id) + self._port_counter += 1 + self._port_counter %= int(conf.MAX_PORTS) + id = net_id + "-p-" + str(self._port_counter) # TODO (Sumit): Need to check if the ID has already been allocated + # ID will be generated by DB return id def _get_unique_profile_id(self, tenant_id): @@ -380,6 +375,7 @@ class L2Network(object): id = tenant_id[:3] + "-pp-" + \ ("0" * (6 - len(str(self._net_counter)))) + str(self._net_counter) # TODO (Sumit): Need to check if the ID has already been allocated + # ID will be generated by DB return id # TODO (Sumit): diff --git a/quantum/plugins/cisco/l2network_plugin_configuration.py b/quantum/plugins/cisco/l2network_plugin_configuration.py new file mode 100644 index 000000000..e0fe786a5 --- /dev/null +++ b/quantum/plugins/cisco/l2network_plugin_configuration.py @@ -0,0 +1,51 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# + +import os + +from quantum.plugins.cisco.common import cisco_configparser as confp + +CONF_FILE = "conf/l2network_plugin.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CONF_FILE) + +section = cp['VLANS'] +VLAN_NAME_PREFIX = section['vlan_name_prefix'] +VLAN_START = section['vlan_start'] +VLAN_END = section['vlan_end'] + +section = cp['PORTS'] +MAX_PORTS = section['max_ports'] + +section = cp['NETWORKS'] +MAX_NETWORKS = section['max_networks'] + +CONF_FILE = "conf/plugins.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CONF_FILE) +plugins = cp.walk(cp.dummy) + + +def main(): + print plugins['PLUGINS'] + +if __name__ == '__main__': + main() diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py b/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py new file mode 100644 index 000000000..f1ad14902 --- /dev/null +++ b/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py @@ -0,0 +1,42 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# @author: Edgar Magana, Cisco Systems, Inc. +# + +import os + +from quantum.plugins.cisco.common import cisco_configparser as confp + +CONF_FILE = "../conf/nexus.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CONF_FILE) + +section = cp['SWITCH'] +NEXUS_IP_ADDRESS = section['nexus_ip_address'] +NEXUS_PORT = section['nexus_port'] + +section = cp['DRIVER'] +NEXUS_DRIVER = section['name'] + + +def main(): + print NEXUS_PORT + +if __name__ == '__main__': + main() diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py b/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py index 27e63ce4c..78090d5f9 100644 --- a/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py +++ b/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py @@ -25,7 +25,6 @@ import logging as LOG import string import subprocess -from quantum.plugins.cisco.common import cisco_configuration as conf from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_exceptions as cexc diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_plugin.py b/quantum/plugins/cisco/nexus/cisco_nexus_plugin.py index 31baac472..8fa6424f9 100644 --- a/quantum/plugins/cisco/nexus/cisco_nexus_plugin.py +++ b/quantum/plugins/cisco/nexus/cisco_nexus_plugin.py @@ -20,13 +20,12 @@ import logging as LOG from quantum.common import exceptions as exc -from quantum.plugins.cisco.common import cisco_configuration as conf +from quantum.common import utils from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco.common import cisco_utils as cutil - -from quantum.plugins.cisco.nexus import cisco_nexus_network_driver +from quantum.plugins.cisco.nexus import cisco_nexus_configuration as conf LOG.basicConfig(level=LOG.WARN) LOG.getLogger(const.LOGGER_COMPONENT_NAME) @@ -36,7 +35,8 @@ class NexusPlugin(object): _networks = {} def __init__(self): - self._client = cisco_nexus_network_driver.CiscoNEXUSDriver() + self._client = utils.import_object(conf.NEXUS_DRIVER) + LOG.debug("Loaded driver %s\n" % conf.NEXUS_DRIVER) #TODO (Edgar) Using just one Nexus 7K Switch and Port self._nexus_ip = conf.NEXUS_IP_ADDRESS self._nexus_username = cred.Store.getUsername(conf.NEXUS_IP_ADDRESS) diff --git a/quantum/plugins/cisco/ucs/get-vif.py b/quantum/plugins/cisco/ucs/cisco_getvif.py similarity index 60% rename from quantum/plugins/cisco/ucs/get-vif.py rename to quantum/plugins/cisco/ucs/cisco_getvif.py index 0512ecb0d..f00116ee1 100644 --- a/quantum/plugins/cisco/ucs/get-vif.py +++ b/quantum/plugins/cisco/ucs/cisco_getvif.py @@ -1,3 +1,21 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Rohit Agarwalla, Cisco Systems Inc. +# import sys import subprocess @@ -23,7 +41,7 @@ def get_next_dynic(argv=[]): for lines in f_cmd_output.splitlines()] #print deviceid if deviceid[0] == "0044": - cmd = ["/usr/sbin/ip", "link", "show", eth] + cmd = ["/sbin/ip", "link", "show", eth] f_cmd_output = subprocess.Popen(cmd, stdout=subprocess.PIPE).\ communicate()[0] used = [lines for lines in f_cmd_output.splitlines() \ @@ -33,5 +51,6 @@ def get_next_dynic(argv=[]): return eth if __name__ == '__main__': - nic = get_next_dynic(sys.argv) + #nic = get_next_dynic(sys.argv) + nic = get_next_dynic() print nic diff --git a/quantum/plugins/cisco/ucs/cisco_ucs_configuration.py b/quantum/plugins/cisco/ucs/cisco_ucs_configuration.py new file mode 100644 index 000000000..305374171 --- /dev/null +++ b/quantum/plugins/cisco/ucs/cisco_ucs_configuration.py @@ -0,0 +1,44 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 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. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# + +import os + +from quantum.plugins.cisco.common import cisco_configparser as confp + +CONF_FILE = "../conf/ucs.ini" + +cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \ + + "/" + CONF_FILE) + +section = cp['UCSM'] +UCSM_IP_ADDRESS = section['ip_address'] +DEFAULT_VLAN_NAME = section['default_vlan_name'] +DEFAULT_VLAN_ID = section['default_vlan_id'] +MAX_UCSM_PORT_PROFILES = section['max_ucsm_port_profiles'] +PROFILE_NAME_PREFIX = section['profile_name_prefix'] + +section = cp['DRIVER'] +UCSM_DRIVER = section['name'] + + +def main(): + print MAX_UCSM_PORT_PROFILES + +if __name__ == '__main__': + main() diff --git a/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py b/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py index 2d994ddec..acf0df100 100644 --- a/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py +++ b/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py @@ -27,9 +27,10 @@ import subprocess from xml.etree import ElementTree as et import urllib -from quantum.plugins.cisco.common import cisco_configuration as conf from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_exceptions as cexc +from quantum.plugins.cisco.ucs import cisco_getvif as gvif + LOG.basicConfig(level=LOG.WARN) LOG.getLogger(const.LOGGER_COMPONENT_NAME) @@ -180,11 +181,7 @@ class CiscoUCSMDriver(): return data def _get_next_dynamic_nic(self): - # TODO (Sumit): following should be a call to a python module - # (which will in turn eliminate the reference to the path and script) - dynamic_nic_id = string.strip(subprocess.Popen( - conf.GET_NEXT_VIF_SCRIPT, - stdout=subprocess.PIPE).communicate()[0]) + dynamic_nic_id = gvif.get_next_dynic() if len(dynamic_nic_id) > 0: return dynamic_nic_id else: @@ -247,12 +244,14 @@ def main(): #client.get_dynamic_nic("dummy") #client.get_dynamic_nic("dummy") #client.release_dynamic_nic("dummy") - #client.get_dynamic_nic("dummy") - #client.change_vlan_in_profile("br100", "default", "test-2", - # "172.20.231.27","admin", - # "c3l12345") + print client.get_dynamic_nic("dummy") + """ + client.change_vlan_in_profile("br100", "default", "test-2", + "172.20.231.27","admin", + "c3l12345") client.change_vlan_in_profile("br100", "test-2", "default", "172.20.231.27", "admin", "c3l12345") + """ if __name__ == '__main__': main() diff --git a/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py b/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py index 264d14f78..f7969cab1 100644 --- a/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py +++ b/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py @@ -20,11 +20,11 @@ import logging as LOG from quantum.common import exceptions as exc -from quantum.plugins.cisco.common import cisco_configuration as conf +from quantum.common import utils from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred from quantum.plugins.cisco.common import cisco_exceptions as cexc -from quantum.plugins.cisco.ucs import cisco_ucs_network_driver +from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf from quantum.plugins.cisco.common import cisco_utils as cutil LOG.basicConfig(level=LOG.WARN) @@ -35,7 +35,8 @@ class UCSVICPlugin(object): _networks = {} def __init__(self): - self._client = cisco_ucs_network_driver.CiscoUCSMDriver() + self._client = utils.import_object(conf.UCSM_DRIVER) + LOG.debug("Loaded driver %s\n" % conf.UCSM_DRIVER) self._utils = cutil.DBUtils() # TODO (Sumit) This is for now, when using only one chassis self._ucsm_ip = conf.UCSM_IP_ADDRESS diff --git a/quantum/plugins/cisco/ucs/get-vif.sh b/quantum/plugins/cisco/ucs/get-vif.sh deleted file mode 100755 index d424b5fea..000000000 --- a/quantum/plugins/cisco/ucs/get-vif.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -eths=`ifconfig -a | grep eth | cut -f1 -d " "` -for eth in $eths; do - bdf=`ethtool -i $eth | grep bus-info | cut -f2 -d " "` - deviceid=`lspci -n -s $bdf | cut -f4 -d ":" | cut -f1 -d " "` - if [ $deviceid = "0044" ]; then - used=`/sbin/ip link show $eth | grep "UP"` - avail=$? - if [ $avail -eq 1 ]; then - echo $eth - exit - fi - fi -done - -- 2.45.2