Ejemplo n.º 1
0
def init():
    global _POLICY_PATH
    if not _POLICY_PATH:
        _POLICY_PATH = 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.º 2
0
def init():
    global _POLICY_PATH
    if not _POLICY_PATH:
        _POLICY_PATH = 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.º 3
0
def init():
    global _POLICY_PATH
    global _POLICY_CACHE
    if not _POLICY_PATH:
        _POLICY_PATH = utils.find_config_file({}, cfg.CONF.policy_file)
        if not _POLICY_PATH:
            raise exceptions.PolicyNotFound(path=cfg.CONF.policy_file)
    # pass _set_brain to read_cached_file so that the policy brain
    # is reset only if the file has changed
    utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE, reload_func=_set_brain)
Ejemplo n.º 4
0
def init():
    global _POLICY_PATH
    global _POLICY_CACHE
    if not _POLICY_PATH:
        _POLICY_PATH = utils.find_config_file({}, cfg.CONF.policy_file)
        if not _POLICY_PATH:
            raise exceptions.PolicyNotFound(path=cfg.CONF.policy_file)
    # pass _set_brain to read_cached_file so that the policy brain
    # is reset only if the file has changed
    utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE, reload_func=_set_brain)
Ejemplo n.º 5
0
#    under the License.
#
# @author: Sumit Naiksatam, Cisco Systems, Inc.

import logging as LOG

from quantum.common.utils 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'}, "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.º 6
0
#    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']
Ejemplo n.º 7
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.utils 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.º 8
0
import logging

from sqlalchemy import func
from sqlalchemy.orm import exc

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

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

# The global variable for the database version model
L2_MODEL = l2network_models


def initialize(base=None):
    global L2_MODEL
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"sql_max_retries": CONF.DATABASE.sql_max_retries})
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    if base:
        options.update({"base": base})
        L2_MODEL = l2network_models_v2
    db.configure_db(options)
Ejemplo n.º 9
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.utils 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)
from configobj import ConfigObj
from quantum.common.utils import find_config_file

_CONF_FILE = find_config_file({
    'plugin': 'udp_socket_plugin'}, "udp_socket_plugin.ini")
_CONF_PARSER_OBJ = ConfigObj(_CONF_FILE)

_DB_CONF = _CONF_PARSER_OBJ['DATABASE']

DB_SQL_CONNECTION = _DB_CONF['sql_connection']
DB_RECONNECT_INTERVAL = int(_DB_CONF.get('reconnect_interval', 2))


_DB_CONF = _CONF_PARSER_OBJ['UDP_POOL']
UDP_POOL_CIDR = str(_DB_CONF.get('cidr'))
UDP_PORT_START = int(_DB_CONF.get('port_start'))
UDP_PORT_END = int(_DB_CONF.get('port_end'))
Ejemplo n.º 11
0
#
# @author: Sumit Naiksatam, Cisco Systems, Inc.

import logging as LOG

from quantum.common.utils 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 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)


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.º 12
0
import logging

from sqlalchemy import func
from sqlalchemy.orm import exc

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

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

# The global variable for the database version model
L2_MODEL = l2network_models


def initialize(base=None):
    global L2_MODEL
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    if base:
        options.update({"base": base})
        L2_MODEL = l2network_models_v2
    db.configure_db(options)
    create_vlanids()
Ejemplo n.º 13
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.

import uuid

from quantum.common.utils import find_config_file
import quantum.db.api as db
from quantum.plugins.ryu.common import config
from quantum.plugins.ryu.tests.unit.basetest import BaseRyuTest
from quantum.plugins.ryu.tests.unit import utils
from quantum.plugins.ryu.tests.unit.utils import patch_fake_ryu_client

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


class RyuDriverTest(BaseRyuTest):
    """Class conisting of OFPRyuDriver unit tests"""
    def setUp(self):
        super(RyuDriverTest, self).setUp()
        self.conf = config.parse(CONF_FILE)
        # fake up ryu.app.client and ryu.app.rest_nw_id
        # With those, plugin can be tested without ryu installed
        self.module_patcher = patch_fake_ryu_client()
        self.module_patcher.start()

    def tearDown(self):
        self.module_patcher.stop()
        super(RyuDriverTest, self).tearDown()
from configobj import ConfigObj
from quantum.common.utils import find_config_file

_CONF_FILE = find_config_file({'plugin': 'udp_socket_plugin'},
                              "udp_socket_plugin.ini")
_CONF_PARSER_OBJ = ConfigObj(_CONF_FILE)

_DB_CONF = _CONF_PARSER_OBJ['DATABASE']

DB_SQL_CONNECTION = _DB_CONF['sql_connection']
DB_RECONNECT_INTERVAL = int(_DB_CONF.get('reconnect_interval', 2))

_DB_CONF = _CONF_PARSER_OBJ['UDP_POOL']
UDP_POOL_CIDR = str(_DB_CONF.get('cidr'))
UDP_PORT_START = int(_DB_CONF.get('port_start'))
UDP_PORT_END = int(_DB_CONF.get('port_end'))
#         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['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.
#

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'}, "ucs_inventory.ini")
CP = confp.CiscoConfigParser(CONF_FILE)

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 17
0
#    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 import exceptions as q_exc
from quantum.common.utils import find_config_file
import quantum.db.api as db
from quantum.plugins.ryu.db import api as db_api
from quantum.plugins.ryu import ofp_service_type
from quantum.plugins.ryu import ovs_quantum_plugin_base


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


class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
    def __init__(self, conf):
        super(OFPRyuDriver, self).__init__()
        ofp_con_host = conf.OVS.openflow_controller
        ofp_api_host = conf.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)

        self.client = client.OFPClient(ofp_api_host)
Ejemplo n.º 18
0
import logging
import os

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

LOG = logging.getLogger("ovs_quantum_plugin")
CONF_FILE = find_config_file({"plugin": "openvswitch"},
                             "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):
        if vlan_min > vlan_max:
            LOG.warn("Using default VLAN values! vlan_min = %s is larger"
#
#    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"))

SECTION = CP['SWITCH']
NEXUS_IP_ADDRESS = SECTION['nexus_ip_address']
NEXUS_PORTS = SECTION['ports']
NEXUS_SSH_PORT = SECTION['nexus_ssh_port']

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


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

INVENTORY = CP.walk(CP.dummy)
Ejemplo n.º 21
0
import logging

from sqlalchemy import func
from sqlalchemy.orm import exc

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

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

# The global variable for the database version model
L2_MODEL = l2network_models


def initialize(base=None):
    global L2_MODEL
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    if base:
        options.update({"base": base})
        L2_MODEL = l2network_models_v2
    db.configure_db(options)
    create_vlanids()
Ejemplo n.º 22
0
import os

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


LOG = logging.getLogger("ovs_quantum_plugin")
CONF_FILE = find_config_file({"plugin": "openvswitch"},
                             "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):
        if vlan_min > vlan_max:
            LOG.warn("Using default VLAN values! vlan_min = %s is larger"