Browse Source
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: I9ef356eccfe330c3733f441b96400d03c3d7d1dfchanges/47/21247/13
17 changed files with 213 additions and 297 deletions
@ -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 |
||||
|
@ -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> |
@ -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> |
@ -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 |
@ -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 |
@ -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] |
@ -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 |
@ -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'] |
@ -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'] |
Loading…
Reference in new issue