Ejemplo n.º 1
0
    def __init__(self, options=None, config_file=None):
        # If no options have been provided, create an empty dict
        if not options:
            options = {}

        if config_file:
            config_file = [config_file]

        self.configuration_file = find_config_file(options, config_file,
                                                   CONFIG_FILE)
        if not 'plugin_provider' in options:
            options['plugin_provider'] = \
                utils.get_plugin_from_config(self.configuration_file)
        LOG.debug("Plugin location:%s", options['plugin_provider'])

        # If the plugin can't be found let them know gracefully
        try:
            plugin_klass = utils.import_class(options['plugin_provider'])
        except ClassNotFound:
            raise Exception("Plugin not found.  You can install a " \
                            "plugin with: pip install <plugin-name>\n" \
                            "Example: pip install quantum-sample-plugin")

        if not issubclass(plugin_klass, QuantumPluginBase):
            raise Exception("Configured Quantum plug-in " \
                            "didn't pass compatibility test")
        else:
            LOG.debug("Successfully imported Quantum plug-in." \
                      "All compatibility tests passed")
        self.plugin = plugin_klass()
    def __init__(self, options=None, config_file=None):
        # If no options have been provided, create an empty dict
        if not options:
            options = {}

        if config_file:
            config_file = [config_file]

        self.configuration_file = find_config_file(options, config_file,
                                                   CONFIG_FILE)
        if not 'plugin_provider' in options:
            options['plugin_provider'] = \
                utils.get_plugin_from_config(self.configuration_file)
        LOG.debug("Plugin location:%s", options['plugin_provider'])

        # If the plugin can't be found let them know gracefully
        try:
            plugin_klass = utils.import_class(options['plugin_provider'])
        except ClassNotFound:
            raise Exception("Plugin not found.  You can install a " \
                            "plugin with: pip install <plugin-name>\n" \
                            "Example: pip install quantum-sample-plugin")

        if not issubclass(plugin_klass, QuantumPluginBase):
            raise Exception("Configured Quantum plug-in " \
                            "didn't pass compatibility test")
        else:
            LOG.debug("Successfully imported Quantum plug-in." \
                      "All compatibility tests passed")
        self.plugin = plugin_klass()
Ejemplo n.º 3
0
def init():
    global _POLICY_PATH
    if not _POLICY_PATH:
        _POLICY_PATH = config.find_config_file({}, [], 'policy.json')
        if not _POLICY_PATH:
            raise exceptions.PolicyNotFound(path=FLAGS.policy_file)
    with open(_POLICY_PATH) as f:
        _set_brain(f.read())
Ejemplo n.º 4
0
def get_plugin_provider(options, config_file=None):
    if config_file:
        config_file = [config_file]

    if not 'plugin_provider' in options:
        cf = find_config_file(options, config_file, CONFIG_FILE)
        options['plugin_provider'] = utils.get_plugin_from_config(cf)
    return options['plugin_provider']
Ejemplo n.º 5
0
def init():
    global _POLICY_PATH
    if not _POLICY_PATH:
        _POLICY_PATH = config.find_config_file({}, [], 'policy.json')
        if not _POLICY_PATH:
            raise exceptions.PolicyNotFound(path=FLAGS.policy_file)
    with open(_POLICY_PATH) as f:
        _set_brain(f.read())
Ejemplo n.º 6
0
import logging
import os

from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
import quantum.db.api as db
from quantum.plugins.openvswitch import ovs_db
from quantum.plugins.openvswitch.common import config
from quantum.quantum_plugin_base import QuantumPluginBase

LOG = logging.getLogger("ovs_quantum_plugin")


CONF_FILE = find_config_file({"plugin": "openvswitch"},
                             None, "ovs_quantum_plugin.ini")


# Exception thrown if no more VLANs are available
class NoFreeVLANException(Exception):
    pass


class VlanMap(object):
    vlans = {}
    net_ids = {}
    free_vlans = set()
    VLAN_MIN = 1
    VLAN_MAX = 4094

    def __init__(self):
Ejemplo n.º 7
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.
#
"""

import os
from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "ucs_inventory.ini")
CP = confp.CiscoConfigParser(CONF_FILE)

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 8
0
#
# @author: Sumit Naiksatam, Cisco Systems, Inc.

import logging as LOG

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp
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 l2network_db as cdb


LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)

CREDENTIALS_FILE = find_config_file({'plugin': 'cisco'}, None,
                                    "credentials.ini")
TENANT = const.NETWORK_ADMIN

cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
_creds_dictionary = cp.walk(cp.dummy)


class Store(object):
    """Credential Store"""

    @staticmethod
    def initialize():
        for id in _creds_dictionary.keys():
            try:
                cdb.add_credential(TENANT, id,
                                   _creds_dictionary[id][const.USERNAME],
Ejemplo n.º 9
0
# @author: Rohit Agarwalla, Cisco Systems, Inc.

import logging

from sqlalchemy import func
from sqlalchemy.orm import exc

from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
import quantum.db.api as db
from quantum.plugins.linuxbridge.common import exceptions as c_exc
from quantum.plugins.linuxbridge.db import l2network_models
from quantum.plugins.linuxbridge.common import config

LOG = logging.getLogger(__name__)
CONF_FILE = find_config_file({'plugin': 'linuxbridge'}, None,
                             "linuxbridge_conf.ini")
CONF = config.parse(CONF_FILE)


def initialize():
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    db.configure_db(options)
    create_vlanids()


def create_vlanids():
    """Prepopulates the vlan_bindings table"""
    LOG.debug("create_vlanids() called")
    session = db.get_session()
    start = CONF.VLANS.vlan_start
Ejemplo n.º 10
0
#
"""

import os
import logging as LOG

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp
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 l2network_db as cdb

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)

CREDENTIALS_FILE = find_config_file({}, None, "credentials.ini")
TENANT = const.NETWORK_ADMIN

cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
_creds_dictionary = cp.walk(cp.dummy)


class Store(object):
    """Credential Store"""

    @staticmethod
    def initialize():
        for id in _creds_dictionary.keys():
            try:
                cdb.add_credential(TENANT, id,
                                   _creds_dictionary[id][const.USERNAME],
#
#    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.
"""

import os
from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CONF_FILE = find_config_file({}, None, "l2network_plugin.ini")
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)

"""
Reading 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['PORTPROFILES']
MAX_PORT_PROFILES = SECTION_CONF['max_port_profiles']
Ejemplo n.º 12
0
#         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 quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp


CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
                                              'ucs.ini'))

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']

CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
                                              'ucs_inventory.ini'))

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 13
0
#    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
"""
import os

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp


CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, None,
                             "nexus.ini"))

SECTION = CP['SWITCH']
NEXUS_IP_ADDRESS = SECTION['nexus_ip_address']
NEXUS_FIRST_PORT = SECTION['nexus_first_port']
NEXUS_SECOND_PORT = SECTION['nexus_second_port']
NEXUS_SSH_PORT = SECTION['nexus_ssh_port']

SECTION = CP['DRIVER']
NEXUS_DRIVER = SECTION['name']
#
#    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
"""
import os

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(find_config_file({}, None, "nexus.ini"))

SECTION = CP["SWITCH"]
NEXUS_IP_ADDRESS = SECTION["nexus_ip_address"]
NEXUS_FIRST_PORT = SECTION["nexus_first_port"]
NEXUS_SECOND_PORT = SECTION["nexus_second_port"]
NEXUS_SSH_PORT = SECTION["nexus_ssh_port"]

SECTION = CP["DRIVER"]
NEXUS_DRIVER = SECTION["name"]
Ejemplo n.º 15
0
# @author: Dan Wendlandt, Nicira Networks, Inc.

import ConfigParser
import logging as LOG
from optparse import OptionParser
import os
import sys

from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.quantum_plugin_base import QuantumPluginBase

import quantum.db.api as db
import ovs_db

CONF_FILE = find_config_file({}, None, "ovs_quantum_plugin.ini")

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger("ovs_quantum_plugin")


class VlanMap(object):
    vlans = {}

    def __init__(self):
        for x in xrange(2, 4094):
            self.vlans[x] = None

    def set(self, vlan_id, network_id):
        self.vlans[vlan_id] = network_id
#    under the License.
# @author: Isaku Yamahata

import quantum.db.api as db
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.plugins.ryu import ofp_service_type
from quantum.plugins.ryu import ovs_quantum_plugin_base
from quantum.plugins.ryu.db import api as db_api


from ryu.app import client
from ryu.app import rest_nw_id


CONF_FILE = find_config_file({"plugin": "ryu"}, None, "ryu.ini")


class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
    def __init__(self, config):
        super(OFPRyuDriver, self).__init__()
        ofp_con_host = config.get("OVS", "openflow-controller")
        ofp_api_host = config.get("OVS", "openflow-rest-api")

        if ofp_con_host is None or ofp_api_host is None:
            raise q_exc.Invalid("invalid configuration. check ryu.ini")

        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER),
                 (ofp_api_host, ofp_service_type.REST_API)]
        db_api.set_ofp_servers(hosts)
"""
# 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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CONF_FILE = find_config_file({"plugin": "cisco"}, None, "ucs_inventory.ini")
CP = confp.CiscoConfigParser(CONF_FILE)

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 18
0
#    under the License.
# @author: Isaku Yamahata

import quantum.db.api as db
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.plugins.ovscommon import ovs_quantum_plugin_base
from quantum.plugins.ryu.db import api as db_api
from quantum.plugins.ryu import ofp_service_type


from ryu.app import client
from ryu.app import rest_nw_id


CONF_FILE = find_config_file(
  {"config_file": "etc/quantum/plugins/ryu/ryu.ini"}, None, "ryu.ini")


class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
    def __init__(self, config):
        super(OFPRyuDriver, self).__init__()
        ofp_con_host = config.get("OVS", "openflow-controller")
        ofp_api_host = config.get("OVS", "openflow-rest-api")

        if ofp_con_host is None or ofp_api_host is None:
            raise q_exc.Invalid("invalid configuration. "
                                "check ovs_quantum_plugin.ini")

        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER),
                 (ofp_api_host, ofp_service_type.REST_API)]
        db_api.add_ofp_servers(hosts)
Ejemplo n.º 19
0
import ConfigParser
import logging as LOG
from optparse import OptionParser
import os
import sys

from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.quantum_plugin_base import QuantumPluginBase

import quantum.db.api as db
import ovs_db

CONF_FILE = find_config_file(
    {"config_file": "etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"},
    None, "ovs_quantum_plugin.ini")

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger("ovs_quantum_plugin")


class VlanMap(object):
    vlans = {}

    def __init__(self):
        for x in xrange(2, 4094):
            self.vlans[x] = None

    def set(self, vlan_id, network_id):
        self.vlans[vlan_id] = network_id
from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, None,
                                               "catalyst.ini"))
SECTION = CP['SWITCH']

CATALYST_IP_ADDRESS = CP['catalyst_ip_address']
CATALYST_PORT = CP['catayst_port']
SOCKET_PORT = CP['socket_port']

SECTION = CP['DRIVER']
CATALYST_DRIVER = CP['name']
Ejemplo n.º 21
0
# @author: Dave Lapsley, Nicira Networks, Inc.

import logging
import os

from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
import quantum.db.api as db
from quantum.plugins.openvswitch import ovs_db
from quantum.plugins.openvswitch.common import config
from quantum.quantum_plugin_base import QuantumPluginBase

LOG = logging.getLogger("ovs_quantum_plugin")

CONF_FILE = find_config_file({"plugin": "openvswitch"}, None,
                             "ovs_quantum_plugin.ini")


# Exception thrown if no more VLANs are available
class NoFreeVLANException(Exception):
    pass


class VlanMap(object):
    vlans = {}
    net_ids = {}
    free_vlans = set()

    def __init__(self, vlan_min=1, vlan_max=4094):
        self.vlan_min = vlan_min
        self.vlan_max = vlan_max
Ejemplo n.º 22
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
"""
import os

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(
    find_config_file({'plugin': 'cisco'}, None, "nexus.ini"))

SECTION = CP['SWITCH']
NEXUS_IP_ADDRESS = SECTION['nexus_ip_address']
NEXUS_FIRST_PORT = SECTION['nexus_first_port']
NEXUS_SECOND_PORT = SECTION['nexus_second_port']
NEXUS_SSH_PORT = SECTION['nexus_ssh_port']

SECTION = CP['DRIVER']
NEXUS_DRIVER = SECTION['name']
# 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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp


CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "ucs_inventory.ini")
CP = confp.CiscoConfigParser(CONF_FILE)

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 24
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.
"""

import os
from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "l2network_plugin.ini")
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
"""
Reading 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['PORTPROFILES']
MAX_PORT_PROFILES = SECTION_CONF['max_port_profiles']
"""
# 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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CONF_FILE = find_config_file({}, None, "ucs_inventory.ini")
CP = confp.CiscoConfigParser(CONF_FILE)

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 26
0
# @author: Rohit Agarwalla, Cisco Systems, Inc.

import logging

from sqlalchemy import func
from sqlalchemy.orm import exc

from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
import quantum.db.api as db
from quantum.plugins.linuxbridge.common import exceptions as c_exc
from quantum.plugins.linuxbridge.db import l2network_models
from quantum.plugins.linuxbridge.common import config

LOG = logging.getLogger(__name__)
CONF_FILE = find_config_file({'plugin': 'linuxbridge'}, None,
                             "linuxbridge_conf.ini")
CONF = config.parse(CONF_FILE)


def initialize():
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    db.configure_db(options)
    create_vlanids()


def create_vlanids():
    """Prepopulates the vlan_bindings table"""
    LOG.debug("create_vlanids() called")
    session = db.get_session()
    start = CONF.VLANS.vlan_start
"""
# 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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(find_config_file({}, [],
                             'plugins/cisco/ucs_inventory.ini'))

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 28
0
from quantum.tests.unit import BaseTest
from quantum.tests.unit.extension_stubs import (
    ExtensionExpectingPluginInterface,
    StubBaseAppController,
    StubExtension,
    StubPlugin,
    StubPluginInterface,
    )
import quantum.tests.unit.extensions
from quantum import wsgi


LOG = logging.getLogger('test_extensions')


test_conf_file = config.find_config_file({}, None, "quantum.conf.test")
extensions_path = ':'.join(quantum.tests.unit.extensions.__path__)


class ExtensionsTestApp(wsgi.Router):

    def __init__(self, options={}):
        mapper = routes.Mapper()
        controller = StubBaseAppController()
        mapper.resource("dummy_resource", "/dummy_resources",
                        controller=controller)
        super(ExtensionsTestApp, self).__init__(mapper)


class ResourceExtensionTest(unittest.TestCase):
Ejemplo n.º 29
0
#
"""

import os
import logging as LOG

from quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp
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 l2network_db as cdb

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)

CREDENTIALS_FILE = find_config_file({'plugin': 'cisco'}, None,
                                    "credentials.ini")
TENANT = const.NETWORK_ADMIN

cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
_creds_dictionary = cp.walk(cp.dummy)


class Store(object):
    """Credential Store"""
    @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])
Ejemplo n.º 30
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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
                             'ucs.ini'))

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']

CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
                             'ucs_inventory.ini'))

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 31
0
from optparse import OptionParser
import os
import sys

from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.quantum_plugin_base import QuantumPluginBase

import quantum.common.utils
import quantum.db.api as db
import neuca_db
import nova.db.api as nova_db

CONF_FILE = find_config_file(
  {"plugin": "neuca"},
  None, "neuca_quantum_plugin.ini")

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger("neuca_quantum_plugin")


# Exception thrown if no more VLANs are available
class NoFreeVLANException(Exception):
    pass


class VlanMap(object):
    vlans = {}
    net_ids = {}
    free_vlans = set()
Ejemplo n.º 32
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.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(find_config_file({}, [], 'ucs.ini'))

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']

CP = confp.CiscoConfigParser(find_config_file({}, [],
                             'ucs_inventory.ini'))

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 33
0
import ConfigParser
import logging as LOG
from optparse import OptionParser
import os
import sys

from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
from quantum.common.config import find_config_file
from quantum.quantum_plugin_base import QuantumPluginBase

import quantum.db.api as db
import ovs_db

CONF_FILE = find_config_file(
  {"config_file": "etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"},
  None, "ovs_quantum_plugin.ini")

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger("ovs_quantum_plugin")


class VlanMap(object):
    vlans = {}
    net_ids = {}
    free_vlans = set()

    def __init__(self):
        self.vlans.clear()
        self.net_ids.clear()
        self.free_vlans = set(xrange(2, 4094))
Ejemplo n.º 34
0
    ExtensionExpectingPluginInterface)
import quantum.tests.unit.extensions
from quantum.extensions.extensions import (ExtensionManager,
                                           PluginAwareExtensionManager,
                                           ExtensionMiddleware)

LOG = logging.getLogger('test_extensions')

from quantum.common import flags
FLAGS = flags.FLAGS

quantum_dir = os.path.dirname(os.path.abspath(quantum.__file__))
src_dir = os.path.abspath(os.path.join(quantum_dir, ".."))
FLAGS.state_path = src_dir

test_conf_file = config.find_config_file({}, None, "quantum.conf.test")
extensions_path = ':'.join(quantum.tests.unit.extensions.__path__)


class ExtensionsTestApp(wsgi.Router):
    def __init__(self, options={}):
        mapper = routes.Mapper()
        controller = StubBaseAppController()
        mapper.resource("dummy_resource",
                        "/dummy_resources",
                        controller=controller)
        super(ExtensionsTestApp, self).__init__(mapper)


class ResourceExtensionTest(unittest.TestCase):
    class ResourceExtensionController(wsgi.Controller):
Ejemplo n.º 35
0
#    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: Isaku Yamahata

from ryu.app import client
from ryu.app import rest_nw_id

from quantum.common.config import find_config_file
from quantum.common import exceptions as q_exc
import quantum.db.api as db
from quantum.plugins.ryu import ofp_service_type
from quantum.plugins.ryu import ovs_quantum_plugin_base
from quantum.plugins.ryu.db import api as db_api

CONF_FILE = find_config_file({"plugin": "ryu"}, None, "ryu.ini")


class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
    def __init__(self, config):
        super(OFPRyuDriver, self).__init__()
        ofp_con_host = config.get("OVS", "openflow-controller")
        ofp_api_host = config.get("OVS", "openflow-rest-api")

        if ofp_con_host is None or ofp_api_host is None:
            raise q_exc.Invalid("invalid configuration. check ryu.ini")

        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER),
                 (ofp_api_host, ofp_service_type.REST_API)]
        db_api.set_ofp_servers(hosts)
Ejemplo n.º 36
0
#         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 quantum.common.config import find_config_file
from quantum.plugins.cisco.common import cisco_configparser as confp

CP = confp.CiscoConfigParser(
    find_config_file({'plugin': 'cisco'}, [], 'ucs.ini'))

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']

CP = confp.CiscoConfigParser(
    find_config_file({'plugin': 'cisco'}, [], 'ucs_inventory.ini'))

INVENTORY = CP.walk(CP.dummy)