~ubuntu-branches/ubuntu/saucy/quantum/saucy

« back to all changes in this revision

Viewing changes to quantum/plugins/cisco/common/config.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-05-31 09:37:25 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20130531093725-09i9oem8a2xlw442
Tags: upstream-2013.2~b1
ImportĀ upstreamĀ versionĀ 2013.2~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2013 Cisco Systems, Inc.
 
4
#
 
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
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
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
 
15
#    under the License.
 
16
 
 
17
from oslo.config import cfg
 
18
 
 
19
from quantum.agent.common import config
 
20
 
 
21
 
 
22
cisco_plugins_opts = [
 
23
    cfg.StrOpt('vswitch_plugin',
 
24
               default='quantum.plugins.openvswitch.ovs_quantum_plugin.'
 
25
                       'OVSQuantumPluginV2',
 
26
               help=_("Virtual Switch to use")),
 
27
    cfg.StrOpt('nexus_plugin',
 
28
               default='quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.'
 
29
                       'NexusPlugin',
 
30
               help=_("Nexus Switch to use")),
 
31
]
 
32
 
 
33
 
 
34
cisco_opts = [
 
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")),
 
59
]
 
60
 
 
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)
 
64
 
 
65
# shortcuts
 
66
CONF = cfg.CONF
 
67
CISCO = cfg.CONF.CISCO
 
68
CISCO_PLUGINS = cfg.CONF.CISCO_PLUGINS
 
69
 
 
70
#
 
71
# When populated the nexus_dictionary format is:
 
72
# {('<nexus ipaddr>', '<key>'): '<value>', ...}
 
73
#
 
74
# Example:
 
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', ...}
 
79
#
 
80
nexus_dictionary = {}
 
81
 
 
82
 
 
83
class CiscoConfigOptions():
 
84
    """Cisco Configuration Options Class."""
 
85
 
 
86
    def __init__(self):
 
87
        self._create_nexus_dictionary()
 
88
 
 
89
    def _create_nexus_dictionary(self):
 
90
        """Create the Nexus dictionary.
 
91
 
 
92
        Reads data from cisco_plugins.ini NEXUS_SWITCH section(s).
 
93
        """
 
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]
 
100
 
 
101
 
 
102
def get_nexus_dictionary():
 
103
    return nexus_dictionary