1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2013 Cisco Systems, Inc.
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
# not use this file except in compliance with the License. You may obtain
7
# a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
# License for the specific language governing permissions and limitations
17
from oslo.config import cfg
19
from quantum.agent.common import config
22
cisco_plugins_opts = [
23
cfg.StrOpt('vswitch_plugin',
24
default='quantum.plugins.openvswitch.ovs_quantum_plugin.'
26
help=_("Virtual Switch to use")),
27
cfg.StrOpt('nexus_plugin',
28
default='quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.'
30
help=_("Nexus Switch to use")),
35
cfg.StrOpt('vlan_start', default='100',
36
help=_("VLAN start value")),
37
cfg.StrOpt('vlan_end', default='3000',
38
help=_("VLAN end value")),
39
cfg.StrOpt('vlan_name_prefix', default='q-',
40
help=_("VLAN Name prefix")),
41
cfg.StrOpt('max_ports', default='100',
42
help=_("Maximum Port value")),
43
cfg.StrOpt('max_port_profiles', default='65568',
44
help=_("Maximum Port Profile value")),
45
cfg.StrOpt('max_networks', default='65568',
46
help=_("Maximum Network value")),
47
cfg.StrOpt('model_class',
48
default='quantum.plugins.cisco.models.virt_phy_sw_v2.'
49
'VirtualPhysicalSwitchModelV2',
50
help=_("Model Class")),
51
cfg.StrOpt('manager_class',
52
default='quantum.plugins.cisco.segmentation.'
53
'l2network_vlan_mgr_v2.L2NetworkVLANMgr',
54
help=_("Manager Class")),
55
cfg.StrOpt('nexus_driver',
56
default='quantum.plugins.cisco.tests.unit.v2.nexus.'
57
'fake_nexus_driver.CiscoNEXUSFakeDriver',
58
help=_("Nexus Driver Name")),
61
cfg.CONF.register_opts(cisco_opts, "CISCO")
62
cfg.CONF.register_opts(cisco_plugins_opts, "CISCO_PLUGINS")
63
config.register_root_helper(cfg.CONF)
67
CISCO = cfg.CONF.CISCO
68
CISCO_PLUGINS = cfg.CONF.CISCO_PLUGINS
71
# When populated the nexus_dictionary format is:
72
# {('<nexus ipaddr>', '<key>'): '<value>', ...}
75
# {('1.1.1.1', 'username'): 'admin',
76
# ('1.1.1.1', 'password'): 'mySecretPassword',
77
# ('1.1.1.1', 'ssh_port'): 22,
78
# ('1.1.1.1', 'compute1'): '1/1', ...}
83
class CiscoConfigOptions():
84
"""Cisco Configuration Options Class."""
87
self._create_nexus_dictionary()
89
def _create_nexus_dictionary(self):
90
"""Create the Nexus dictionary.
92
Reads data from cisco_plugins.ini NEXUS_SWITCH section(s).
94
for parsed_file in cfg.CONF._cparser.parsed:
95
for parsed_item in parsed_file.keys():
96
nexus_name, sep, nexus_ip = parsed_item.partition(':')
97
if nexus_name == 'NEXUS_SWITCH':
98
for nexus_key, value in parsed_file[parsed_item].items():
99
nexus_dictionary[nexus_ip, nexus_key] = value[0]
102
def get_nexus_dictionary():
103
return nexus_dictionary