summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Curran <rcurran@cisco.com>2013-02-05 15:55:28 -0500
committerRich Curran <rcurran@cisco.com>2013-04-02 12:06:38 -0400
commitf164a60f15ea042b04b250ffc2001beda4f3e4bc (patch)
tree735d3968e754b7bbcac10295c3f1c763e0bbddf7
parent0deaadd145ed75ca531d5cc48e74b1ab85764903 (diff)
downloadneutron-f164a60f15ea042b04b250ffc2001beda4f3e4bc.tar.gz
blueprint cisco-single-config
Scope: Unification of all the various plugin files for the Cisco plugin into a single file. Use Cases: Quantum with the Cisco plugin. Implementation Overview: All the config values contained in the various files in etc/quantum/plugins/cisco will be unified into a single file etc/quantum/plugins/cisco/cisco_plugin.ini. The plugins needs to be modified to read from a single file instead of multiple. Added quantum.openstack.common.cfg support. Change-Id: I9ef356eccfe330c3733f441b96400d03c3d7d1df
-rw-r--r--etc/quantum/plugins/cisco/cisco_plugins.ini46
-rw-r--r--etc/quantum/plugins/cisco/credentials.ini11
-rw-r--r--etc/quantum/plugins/cisco/db_conn.ini5
-rw-r--r--etc/quantum/plugins/cisco/l2network_plugin.ini23
-rw-r--r--etc/quantum/plugins/cisco/nexus.ini14
-rw-r--r--quantum/plugins/cisco/common/cisco_configparser.py31
-rw-r--r--quantum/plugins/cisco/common/cisco_credentials_v2.py31
-rw-r--r--quantum/plugins/cisco/common/config.py108
-rw-r--r--quantum/plugins/cisco/db/l2network_db.py6
-rw-r--r--quantum/plugins/cisco/db/network_db_v2.py6
-rw-r--r--quantum/plugins/cisco/l2network_plugin_configuration.py67
-rw-r--r--quantum/plugins/cisco/models/virt_phy_sw_v2.py82
-rw-r--r--quantum/plugins/cisco/network_plugin.py6
-rw-r--r--quantum/plugins/cisco/nexus/cisco_nexus_configuration.py36
-rw-r--r--quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py22
-rw-r--r--quantum/tests/unit/cisco/test_nexus_plugin.py10
-rw-r--r--setup.py6
17 files changed, 213 insertions, 297 deletions
diff --git a/etc/quantum/plugins/cisco/cisco_plugins.ini b/etc/quantum/plugins/cisco/cisco_plugins.ini
index 5fc7052f35..2fbf99cd9c 100644
--- a/etc/quantum/plugins/cisco/cisco_plugins.ini
+++ b/etc/quantum/plugins/cisco/cisco_plugins.ini
@@ -1,6 +1,44 @@
-[PLUGINS]
+[CISCO_PLUGINS]
#nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin
-vswitch_plugin=quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2
+#vswitch_plugin=quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2
-[INVENTORY]
-#nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_inventory.NexusInventory
+[CISCO]
+#vlan_start=100
+#vlan_end=3000
+#vlan_name_prefix=q-
+#max_ports=100
+#max_port_profiles=65568
+#max_networks=65568
+#model_class=quantum.plugins.cisco.models.virt_phy_sw_v2.VirtualPhysicalSwitchModelV2
+#manager_class=quantum.plugins.cisco.segmentation.l2network_vlan_mgr_v2.L2NetworkVLANMgr
+#nexus_driver=quantum.plugins.cisco.tests.unit.v2.nexus.fake_nexus_driver.CiscoNEXUSFakeDriver
+
+# IMPORTANT: Comment out the following two lines for production deployments
+[CISCO_TEST]
+host=testhost
+
+#
+# Nexus Switch Format.
+# [NEXUS_SWITCH:<IP address of switch>]
+# <hostname>=<port>
+# ssh_port=<ssh port>
+# username=<credential username>
+# password=<credential password>
+#
+# Example:
+# [NEXUS_SWITCH:1.1.1.1]
+# compute1=1/1
+# compute2=1/2
+# ssh_port=22
+# username=admin
+# password=mySecretPassword
+
+[DATABASE]
+#
+# This line MUST be changed to actually run the plugin.
+# Example:
+# sql_connection = mysql://quantum:password@127.0.0.1:3306/cisco_quantum
+# Replace 127.0.0.1 above with the IP address of the database used by the
+# main quantum server. (Leave it as is if the database runs on this host.)
+#
+#sql_connection=engine://user:pass@host/db_name
diff --git a/etc/quantum/plugins/cisco/credentials.ini b/etc/quantum/plugins/cisco/credentials.ini
deleted file mode 100644
index 31750dd6f6..0000000000
--- a/etc/quantum/plugins/cisco/credentials.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-#Provide the Nexus credentials, if you are using Nexus
-[<put_nexus_switch_ip_address_here>]
-username=<put_user_name_here>
-password=<put_password_here>
-
-# Provide credentials and endpoint
-# for keystone here
-[keystone]
-auth_url=<put_keystone_endpoint_here>
-username=<put_user_name_here>
-password=<put_password_here>
diff --git a/etc/quantum/plugins/cisco/db_conn.ini b/etc/quantum/plugins/cisco/db_conn.ini
deleted file mode 100644
index 4a5d7e3713..0000000000
--- a/etc/quantum/plugins/cisco/db_conn.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[DATABASE]
-name = quantum_l2network
-user = <put_db_user_name_here>
-pass = <put_db_password_here>
-host = <put_quantum_mysql_host_here>
diff --git a/etc/quantum/plugins/cisco/l2network_plugin.ini b/etc/quantum/plugins/cisco/l2network_plugin.ini
deleted file mode 100644
index 84093df6f5..0000000000
--- a/etc/quantum/plugins/cisco/l2network_plugin.ini
+++ /dev/null
@@ -1,23 +0,0 @@
-[VLANS]
-vlan_start=100
-vlan_end=3000
-vlan_name_prefix=q-
-
-[PORTS]
-max_ports=100
-
-[PORTPROFILES]
-max_port_profiles=65568
-
-[NETWORKS]
-max_networks=65568
-
-[MODEL]
-model_class=quantum.plugins.cisco.models.virt_phy_sw_v2.VirtualPhysicalSwitchModelV2
-
-[SEGMENTATION]
-manager_class=quantum.plugins.cisco.segmentation.l2network_vlan_mgr_v2.L2NetworkVLANMgr
-
-# IMPORTANT: Comment the following lines for production deployments
-[TEST]
-host=testhost
diff --git a/etc/quantum/plugins/cisco/nexus.ini b/etc/quantum/plugins/cisco/nexus.ini
deleted file mode 100644
index b01cd0aa81..0000000000
--- a/etc/quantum/plugins/cisco/nexus.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[SWITCH]
-# Ip address of the switch
-[[<put_nexus_switch_ip_address_here>]]
-# Hostname of the node
-[[[<put_hostname_here>]]]
-# Port this node is connected to on the nexus switch
-ports=<put_port_id_here>
-# Port number where the SSH will be running at the Nexus Switch, e.g.: 22 (Default)
-[[[ssh_port]]]
-ssh_port=<put_port_number_here>
-
-[DRIVER]
-#name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver_v2.CiscoNEXUSDriver
-name=quantum.plugins.cisco.tests.unit.v2.nexus.fake_nexus_driver.CiscoNEXUSFakeDriver
diff --git a/quantum/plugins/cisco/common/cisco_configparser.py b/quantum/plugins/cisco/common/cisco_configparser.py
deleted file mode 100644
index bfbc2bd6c3..0000000000
--- a/quantum/plugins/cisco/common/cisco_configparser.py
+++ /dev/null
@@ -1,31 +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.
-
-from configobj import ConfigObj
-
-
-class CiscoConfigParser(ConfigObj):
- """Config Parser based on the ConfigObj module"""
-
- def __init__(self, filename):
- super(CiscoConfigParser, self).__init__(filename, raise_errors=True,
- file_error=True)
-
- def dummy(self, section, key):
- """Dummy function to return the same key, used in walk"""
- return section[key]
diff --git a/quantum/plugins/cisco/common/cisco_credentials_v2.py b/quantum/plugins/cisco/common/cisco_credentials_v2.py
index 0ba356cb88..7fa1a35f37 100644
--- a/quantum/plugins/cisco/common/cisco_credentials_v2.py
+++ b/quantum/plugins/cisco/common/cisco_credentials_v2.py
@@ -18,8 +18,9 @@
import logging as LOG
-from quantum.common.utils import find_config_file
-from quantum.plugins.cisco.common import cisco_configparser as confp
+from oslo.config import cfg
+
+from quantum.plugins.cisco.common import config
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_exceptions as cexc
from quantum.plugins.cisco.db import network_db_v2 as cdb
@@ -28,12 +29,9 @@ from quantum.plugins.cisco.db import network_db_v2 as cdb
LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)
-CREDENTIALS_FILE = find_config_file({'plugin': 'cisco'},
- "credentials.ini")
TENANT = const.NETWORK_ADMIN
-cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
-_creds_dictionary = cp.walk(cp.dummy)
+_nexus_dict = config.get_nexus_dictionary()
class Store(object):
@@ -41,16 +39,17 @@ class Store(object):
@staticmethod
def initialize():
- for id in _creds_dictionary.keys():
- try:
- cdb.add_credential(TENANT, id,
- _creds_dictionary[id][const.USERNAME],
- _creds_dictionary[id][const.PASSWORD])
- except cexc.CredentialAlreadyExists:
- # We are quietly ignoring this, since it only happens
- # if this class module is loaded more than once, in which
- # case, the credentials are already populated
- pass
+ for keys in _nexus_dict.keys():
+ if keys[1] == const.USERNAME:
+ try:
+ cdb.add_credential(TENANT, keys[0],
+ _nexus_dict[keys[0], const.USERNAME],
+ _nexus_dict[keys[0], const.PASSWORD])
+ except cexc.CredentialAlreadyExists:
+ # We are quietly ignoring this, since it only happens
+ # if this class module is loaded more than once, in which
+ # case, the credentials are already populated
+ pass
@staticmethod
def put_credential(cred_name, username, password):
diff --git a/quantum/plugins/cisco/common/config.py b/quantum/plugins/cisco/common/config.py
new file mode 100644
index 0000000000..ba6bbc554a
--- /dev/null
+++ b/quantum/plugins/cisco/common/config.py
@@ -0,0 +1,108 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Cisco Systems, Inc.
+#
+# 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 oslo.config import cfg
+
+from quantum.agent.common import config
+
+
+cisco_test_opts = [
+ cfg.StrOpt('host',
+ default=None,
+ help=_("Cisco test host option.")),
+]
+
+cisco_plugins_opts = [
+ cfg.StrOpt('vswitch_plugin',
+ default='quantum.plugins.openvswitch.ovs_quantum_plugin.'
+ 'OVSQuantumPluginV2',
+ help=_("Virtual Switch to use")),
+ cfg.StrOpt('nexus_plugin',
+ default='quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.'
+ 'NexusPlugin',
+ help=_("Nexus Switch to use")),
+]
+
+
+cisco_opts = [
+ cfg.StrOpt('vlan_start', default='100',
+ help=_("VLAN start value")),
+ cfg.StrOpt('vlan_end', default='3000',
+ help=_("VLAN end value")),
+ cfg.StrOpt('vlan_name_prefix', default='q-',
+ help=_("VLAN Name prefix")),
+ cfg.StrOpt('max_ports', default='100',
+ help=_("Maximum Port value")),
+ cfg.StrOpt('max_port_profiles', default='65568',
+ help=_("Maximum Port Profile value")),
+ cfg.StrOpt('max_networks', default='65568',
+ help=_("Maximum Network value")),
+ cfg.StrOpt('model_class',
+ default='quantum.plugins.cisco.models.virt_phy_sw_v2.'
+ 'VirtualPhysicalSwitchModelV2',
+ help=_("Model Class")),
+ cfg.StrOpt('manager_class',
+ default='quantum.plugins.cisco.segmentation.'
+ 'l2network_vlan_mgr_v2.L2NetworkVLANMgr',
+ help=_("Manager Class")),
+ cfg.StrOpt('nexus_driver',
+ default='quantum.plugins.cisco.tests.unit.v2.nexus.'
+ 'fake_nexus_driver.CiscoNEXUSFakeDriver',
+ help=_("Nexus Driver Name")),
+]
+
+cfg.CONF.register_opts(cisco_opts, "CISCO")
+cfg.CONF.register_opts(cisco_plugins_opts, "CISCO_PLUGINS")
+cfg.CONF.register_opts(cisco_test_opts, "CISCO_TEST")
+config.register_root_helper(cfg.CONF)
+
+# shortcuts
+CISCO = cfg.CONF.CISCO
+CISCO_PLUGINS = cfg.CONF.CISCO_PLUGINS
+CISCO_TEST = cfg.CONF.CISCO_TEST
+
+#
+# When populated the nexus_dictionary format is:
+# {('<nexus ipaddr>', '<key>'): '<value>', ...}
+#
+# Example:
+# {('1.1.1.1', 'username'): 'admin',
+# ('1.1.1.1', 'password'): 'mySecretPassword',
+# ('1.1.1.1', 'compute1'): '1/1', ...}
+#
+nexus_dictionary = {}
+
+
+class CiscoConfigOptions():
+ """ Cisco Configuration Options Class """
+ def __init__(self):
+ self._create_nexus_dictionary()
+
+ def _create_nexus_dictionary(self):
+ """
+ Create the Nexus dictionary from the cisco_plugins.ini
+ NEXUS_SWITCH section(s).
+ """
+ for parsed_file in cfg.CONF._cparser.parsed:
+ for parsed_item in parsed_file.keys():
+ nexus_name, sep, nexus_ip = parsed_item.partition(':')
+ if nexus_name == 'NEXUS_SWITCH':
+ for nexus_key, value in parsed_file[parsed_item].items():
+ nexus_dictionary[nexus_ip, nexus_key] = value[0]
+
+
+def get_nexus_dictionary():
+ return nexus_dictionary
diff --git a/quantum/plugins/cisco/db/l2network_db.py b/quantum/plugins/cisco/db/l2network_db.py
index 2380d89c72..74b8350c92 100644
--- a/quantum/plugins/cisco/db/l2network_db.py
+++ b/quantum/plugins/cisco/db/l2network_db.py
@@ -20,8 +20,8 @@ from sqlalchemy.orm import exc
from quantum.common import exceptions as q_exc
from quantum.openstack.common import log as logging
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
+from quantum.plugins.cisco.common import config
from quantum.plugins.cisco.db import l2network_models
-from quantum.plugins.cisco import l2network_plugin_configuration as conf
import quantum.plugins.cisco.db.api as db
@@ -43,8 +43,8 @@ def create_vlanids():
except exc.MultipleResultsFound:
pass
except exc.NoResultFound:
- start = int(conf.VLAN_START)
- end = int(conf.VLAN_END)
+ start = int(config.CISCO.vlan_start)
+ end = int(config.CISCO.vlan_end)
while start <= end:
vlanid = l2network_models.VlanID(start)
session.add(vlanid)
diff --git a/quantum/plugins/cisco/db/network_db_v2.py b/quantum/plugins/cisco/db/network_db_v2.py
index 5c91aabfe2..1c2b1978d4 100644
--- a/quantum/plugins/cisco/db/network_db_v2.py
+++ b/quantum/plugins/cisco/db/network_db_v2.py
@@ -22,9 +22,9 @@ from quantum.common import exceptions as q_exc
from quantum.db import api as db
from quantum.openstack.common import log as logging
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
+from quantum.plugins.cisco.common import config
from quantum.plugins.cisco.db import network_models_v2
from quantum.plugins.cisco.db import nexus_models_v2
-from quantum.plugins.cisco import l2network_plugin_configuration as conf
from quantum.plugins.openvswitch import ovs_models_v2
@@ -40,8 +40,8 @@ def create_vlanids():
except exc.MultipleResultsFound:
pass
except exc.NoResultFound:
- start = int(conf.VLAN_START)
- end = int(conf.VLAN_END)
+ start = int(config.CISCO.vlan_start)
+ end = int(config.CISCO.vlan_end)
while start <= end:
vlanid = network_models_v2.VlanID(start)
session.add(vlanid)
diff --git a/quantum/plugins/cisco/l2network_plugin_configuration.py b/quantum/plugins/cisco/l2network_plugin_configuration.py
deleted file mode 100644
index f01efab319..0000000000
--- a/quantum/plugins/cisco/l2network_plugin_configuration.py
+++ /dev/null
@@ -1,67 +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: Rohit Agarwalla, Cisco Systems, Inc.
-
-from quantum.common.utils import find_config_file
-from quantum.plugins.cisco.common import cisco_configparser as confp
-
-
-CONF_FILE = find_config_file({'plugin': 'cisco'}, "l2network_plugin.ini")
-CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
-
-
-# Read the conf for the l2network_plugin
-SECTION_CONF = CONF_PARSER_OBJ['VLANS']
-VLAN_NAME_PREFIX = SECTION_CONF['vlan_name_prefix']
-VLAN_START = SECTION_CONF['vlan_start']
-VLAN_END = SECTION_CONF['vlan_end']
-
-SECTION_CONF = CONF_PARSER_OBJ['PORTS']
-MAX_PORTS = SECTION_CONF['max_ports']
-
-SECTION_CONF = CONF_PARSER_OBJ['NETWORKS']
-MAX_NETWORKS = SECTION_CONF['max_networks']
-
-SECTION_CONF = CONF_PARSER_OBJ['MODEL']
-MODEL_CLASS = SECTION_CONF['model_class']
-
-if 'TEST' in CONF_PARSER_OBJ.keys():
- TEST = CONF_PARSER_OBJ['TEST']
-
-CONF_FILE = find_config_file({'plugin': 'cisco'}, "cisco_plugins.ini")
-
-SECTION_CONF = CONF_PARSER_OBJ['SEGMENTATION']
-MANAGER_CLASS = SECTION_CONF['manager_class']
-
-
-CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
-
-# Read the config for the device plugins
-PLUGINS = CONF_PARSER_OBJ.walk(CONF_PARSER_OBJ.dummy)
-
-CONF_FILE = find_config_file({'plugin': 'cisco'}, "db_conn.ini")
-
-CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
-
-
-# Read DB config for the Quantum DB
-SECTION_CONF = CONF_PARSER_OBJ['DATABASE']
-DB_NAME = SECTION_CONF['name']
-DB_USER = SECTION_CONF['user']
-DB_PASS = SECTION_CONF['pass']
-DB_HOST = SECTION_CONF['host']
diff --git a/quantum/plugins/cisco/models/virt_phy_sw_v2.py b/quantum/plugins/cisco/models/virt_phy_sw_v2.py
index faef734d37..8a9cea25fe 100644
--- a/quantum/plugins/cisco/models/virt_phy_sw_v2.py
+++ b/quantum/plugins/cisco/models/virt_phy_sw_v2.py
@@ -23,8 +23,8 @@ from copy import deepcopy
import inspect
import logging
-from keystoneclient.v2_0 import client as keystone_client
from novaclient.v1_1 import client as nova_client
+from oslo.config import cfg
from quantum.db import l3_db
from quantum.manager import QuantumManager
@@ -32,7 +32,7 @@ from quantum.openstack.common import importutils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
from quantum.plugins.cisco.db import network_db_v2 as cdb
-from quantum.plugins.cisco import l2network_plugin_configuration as conf
+from quantum.plugins.cisco.common import config as conf
from quantum.plugins.openvswitch import ovs_db_v2 as odb
from quantum import quantum_plugin_base_v2
from quantum.db import api as db_api
@@ -51,7 +51,6 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
__native_bulk_support = True
supported_extension_aliases = []
_plugins = {}
- _inventory = {}
_methods_to_delegate = ['create_network_bulk',
'get_network', 'get_networks',
'create_port_bulk',
@@ -66,16 +65,12 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
configured, and load the inventories those device plugins for which the
inventory is configured
"""
- for key in conf.PLUGINS[const.PLUGINS].keys():
- plugin_obj = conf.PLUGINS[const.PLUGINS][key]
+ conf.CiscoConfigOptions()
+
+ for key in conf.CISCO_PLUGINS.keys():
+ plugin_obj = conf.CISCO_PLUGINS[key]
self._plugins[key] = importutils.import_object(plugin_obj)
- LOG.debug(_("Loaded device plugin %s\n"),
- conf.PLUGINS[const.PLUGINS][key])
- if key in conf.PLUGINS[const.INVENTORY].keys():
- inventory_obj = conf.PLUGINS[const.INVENTORY][key]
- self._inventory[key] = importutils.import_object(inventory_obj)
- LOG.debug(_("Loaded device inventory %s\n"),
- conf.PLUGINS[const.INVENTORY][key])
+ LOG.debug(_("Loaded device plugin %s\n"), conf.CISCO_PLUGINS[key])
if ((const.VSWITCH_PLUGIN in self._plugins) and
hasattr(self._plugins[const.VSWITCH_PLUGIN],
@@ -126,41 +121,18 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
def _invoke_plugin_per_device(self, plugin_key, function_name, args):
"""
- Invokes a device plugin's relevant functions (on the it's
- inventory and plugin implementation) for completing this operation.
+ Invokes a device plugin's relevant functions (based on the
+ plugin implementation) for completing this operation.
"""
if plugin_key not in self._plugins:
LOG.info(_("No %s Plugin loaded"), plugin_key)
LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
"ignored"), locals())
return
- device_params = self._invoke_inventory(plugin_key, function_name,
- args)
- device_ips = device_params[const.DEVICE_IP]
- if not device_ips:
- return [self._invoke_plugin(plugin_key, function_name, args,
- device_params)]
- else:
- output = []
- for device_ip in device_ips:
- new_device_params = deepcopy(device_params)
- new_device_params[const.DEVICE_IP] = device_ip
- output.append(self._invoke_plugin(plugin_key, function_name,
- args, new_device_params))
- return output
-
- def _invoke_inventory(self, plugin_key, function_name, args):
- """
- Invokes the relevant function on a device plugin's
- inventory for completing this operation.
- """
- if plugin_key not in self._inventory:
- LOG.info(_("No %s inventory loaded"), plugin_key)
- LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
- "ignored"), locals())
- return {const.DEVICE_IP: []}
- else:
- return getattr(self._inventory[plugin_key], function_name)(args)
+
+ device_params = {const.DEVICE_IP: []}
+ return [self._invoke_plugin(plugin_key, function_name, args,
+ device_params)]
def _invoke_plugin(self, plugin_key, function_name, args, kwargs):
"""
@@ -202,18 +174,14 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
return False
def _get_instance_host(self, tenant_id, instance_id):
- keystone = cred._creds_dictionary['keystone']
- kc = keystone_client.Client(username=keystone['username'],
- password=keystone['password'],
- tenant_id=tenant_id,
- auth_url=keystone['auth_url'])
- tenant = kc.tenants.get(tenant_id)
- tenant_name = tenant.name
-
- nc = nova_client.Client(keystone['username'],
- keystone['password'],
- tenant_name,
- keystone['auth_url'],
+ keystone_conf = cfg.CONF.keystone_authtoken
+ keystone_auth_url = '%s://%s:%s/v2.0/' % (keystone_conf.auth_protocol,
+ keystone_conf.auth_host,
+ keystone_conf.auth_port)
+ nc = nova_client.Client(keystone_conf.admin_user,
+ keystone_conf.admin_password,
+ keystone_conf.admin_tenant_name,
+ keystone_auth_url,
no_cache=True)
serv = nc.servers.get(instance_id)
host = serv.__getattr__('OS-EXT-SRV-ATTR:host')
@@ -234,7 +202,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
vlan_id = self._get_segmentation_id(ovs_output[0]['id'])
if not self._validate_vlan_id(vlan_id):
return ovs_output[0]
- vlan_name = conf.VLAN_NAME_PREFIX + str(vlan_id)
+ vlan_name = conf.CISCO.vlan_name_prefix + str(vlan_id)
vlanids = self._get_all_segmentation_ids()
args = [ovs_output[0]['tenant_id'], ovs_output[0]['name'],
ovs_output[0]['id'], vlan_name, vlan_id,
@@ -307,7 +275,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
host = self._get_instance_host(tenant_id, instance_id)
# Trunk segmentation id for only this host
- vlan_name = conf.VLAN_NAME_PREFIX + str(vlan_id)
+ vlan_name = conf.CISCO.vlan_name_prefix + str(vlan_id)
n_args = [tenant_id, net_name, net_id,
vlan_name, vlan_id, host, instance_id]
nexus_output = self._invoke_plugin_per_device(
@@ -332,8 +300,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
instance_id = port['port']['device_id']
device_owner = port['port']['device_owner']
- if hasattr(conf, 'TEST'):
- host = conf.TEST['host']
+ if conf.CISCO_TEST.host is not None:
+ host = conf.CISCO_TEST.host
elif device_owner == 'network:dhcp':
return ovs_output[0]
elif instance_id:
diff --git a/quantum/plugins/cisco/network_plugin.py b/quantum/plugins/cisco/network_plugin.py
index 5c31235670..2e5f64a759 100644
--- a/quantum/plugins/cisco/network_plugin.py
+++ b/quantum/plugins/cisco/network_plugin.py
@@ -28,8 +28,8 @@ from quantum.openstack.common import importutils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_exceptions as cexc
from quantum.plugins.cisco.common import cisco_utils as cutil
+from quantum.plugins.cisco.common import config
from quantum.plugins.cisco.db import network_db_v2 as cdb
-from quantum.plugins.cisco import l2network_plugin_configuration as conf
LOG = logging.getLogger(__name__)
@@ -53,10 +53,10 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
"""
Loads the model class.
"""
- self._model = importutils.import_object(conf.MODEL_CLASS)
+ self._model = importutils.import_object(config.CISCO.model_class)
if hasattr(self._model, "MANAGE_STATE") and self._model.MANAGE_STATE:
self._master = False
- LOG.debug(_("Model %s manages state"), conf.MODEL_CLASS)
+ LOG.debug(_("Model %s manages state"), config.CISCO.model_class)
native_bulk_attr_name = ("_%s__native_bulk_support"
% self._model.__class__.__name__)
self.__native_bulk_support = getattr(self._model,
diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py b/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py
deleted file mode 100644
index d862a39a14..0000000000
--- a/quantum/plugins/cisco/nexus/cisco_nexus_configuration.py
+++ /dev/null
@@ -1,36 +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.
-#
-"""
-Configuration consolidation for the Nexus Driver
-This module will export the configuration parameters
-from the nexus.ini file
-"""
-
-from quantum.common.utils import find_config_file
-from quantum.plugins.cisco.common import cisco_configparser as confp
-
-
-CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'},
- "nexus.ini"))
-
-NEXUS_DETAILS = CP['SWITCH']
-
-SECTION = CP['DRIVER']
-NEXUS_DRIVER = SECTION['name']
diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py b/quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py
index 5138c65cf8..183e385bba 100644
--- a/quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py
+++ b/quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py
@@ -31,10 +31,10 @@ from quantum.openstack.common import importutils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
from quantum.plugins.cisco.common import cisco_exceptions as excep
+from quantum.plugins.cisco.common import config as conf
from quantum.plugins.cisco.db import network_db_v2 as cdb
from quantum.plugins.cisco.db import nexus_db_v2 as nxos_db
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
-from quantum.plugins.cisco.nexus import cisco_nexus_configuration as conf
LOG = logging.getLogger(__name__)
@@ -50,9 +50,9 @@ class NexusPlugin(L2DevicePluginBase):
"""
Extracts the configuration parameters from the configuration file
"""
- self._client = importutils.import_object(conf.NEXUS_DRIVER)
- LOG.debug(_("Loaded driver %s"), conf.NEXUS_DRIVER)
- self._nexus_switches = conf.NEXUS_DETAILS
+ self._client = importutils.import_object(conf.CISCO.nexus_driver)
+ LOG.debug(_("Loaded driver %s"), conf.CISCO.nexus_driver)
+ self._nexus_switches = conf.get_nexus_dictionary()
self.credentials = {}
def get_credential(self, nexus_ip):
@@ -85,11 +85,11 @@ class NexusPlugin(L2DevicePluginBase):
# Grab the switch IP and port for this host
switch_ip = ''
port_id = ''
- for switch in self._nexus_switches.keys():
- for hostname in self._nexus_switches[switch].keys():
- if str(hostname) == str(host):
- switch_ip = switch
- port_id = self._nexus_switches[switch][hostname]['ports']
+ for keys in self._nexus_switches.keys():
+ if str(keys[1]) == str(host):
+ switch_ip = keys[0]
+ port_id = self._nexus_switches[keys[0], keys[1]]
+
# Check if this network is already in the DB
binding = nxos_db.get_port_vlan_switch_binding(
port_id, vlan_id, switch_ip)
@@ -97,7 +97,7 @@ class NexusPlugin(L2DevicePluginBase):
_nexus_ip = switch_ip
_nexus_ports = (port_id,)
_nexus_ssh_port = \
- self._nexus_switches[switch_ip]['ssh_port']['ssh_port']
+ self._nexus_switches[switch_ip, 'ssh_port']
_nexus_creds = self.get_credential(_nexus_ip)
_nexus_username = _nexus_creds['username']
_nexus_password = _nexus_creds['password']
@@ -187,7 +187,7 @@ class NexusPlugin(L2DevicePluginBase):
_nexus_ip = row['switch_ip']
_nexus_ports = (row['port_id'],)
_nexus_ssh_port = \
- self._nexus_switches[_nexus_ip]['ssh_port']['ssh_port']
+ self._nexus_switches[_nexus_ip, 'ssh_port']
_nexus_creds = self.get_credential(_nexus_ip)
_nexus_username = _nexus_creds['username']
_nexus_password = _nexus_creds['password']
diff --git a/quantum/tests/unit/cisco/test_nexus_plugin.py b/quantum/tests/unit/cisco/test_nexus_plugin.py
index bd1426004b..67c6d6d286 100644
--- a/quantum/tests/unit/cisco/test_nexus_plugin.py
+++ b/quantum/tests/unit/cisco/test_nexus_plugin.py
@@ -51,14 +51,8 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
self.second_vlan_name = "q-" + str(self.second_net_id) + "vlan"
self.second_vlan_id = 265
self._nexus_switches = {
- NEXUS_IP_ADDRESS: {
- HOSTNAME: {
- 'ports': NEXUS_PORTS,
- },
- 'ssh_port': {
- 'ssh_port': NEXUS_SSH_PORT
- }
- }
+ (NEXUS_IP_ADDRESS, HOSTNAME): NEXUS_PORTS,
+ (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
}
self._hostname = HOSTNAME
diff --git a/setup.py b/setup.py
index cdb8f5101b..57366fa6bf 100644
--- a/setup.py
+++ b/setup.py
@@ -92,11 +92,7 @@ else:
(ovs_plugin_config_path,
['etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini']),
(cisco_plugin_config_path,
- ['etc/quantum/plugins/cisco/credentials.ini',
- 'etc/quantum/plugins/cisco/l2network_plugin.ini',
- 'etc/quantum/plugins/cisco/nexus.ini',
- 'etc/quantum/plugins/cisco/cisco_plugins.ini',
- 'etc/quantum/plugins/cisco/db_conn.ini']),
+ ['etc/quantum/plugins/cisco/cisco_plugins.ini']),
(bigswitch_plugin_config_path,
['etc/quantum/plugins/bigswitch/restproxy.ini']),
(brocade_plugin_config_path,