Make sure it matches your mysql configuration. This file must be updated
with the addresses and credentials to access the database.
+ Note: debug and logging information should be updated in etc/quantum.conf
+
Note: When running the tests, set the connection type to sqlite, and when
actually running the server set it to mysql. At any given time, only one
of these should be active in the conf file (you can comment out the other).
and etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
to the compute node.
+- Copy the quantum.conf file to the compute node
+
+ Note: debug and logging information should be updated in etc/quantum.conf
+
$ Run the following:
- python linuxbridge_quantum_agent.py linuxbridge_conf.ini
- (Use --verbose option to see the logs)
+ python linuxbridge_quantum_agent.py --config-file quantum.conf
+ --config-file linuxbridge_conf.ini
Note that the the user running the agent must have sudo priviliges
to run various networking commands. Also, the agent can be
# @author: Sumit Naiksatam, Cisco Systems, Inc.
import logging
-from optparse import OptionParser
import os
import shlex
import signal
from sqlalchemy.ext.sqlsoup import SqlSoup
+from quantum.openstack.common import cfg
+from quantum.common import config as logging_config
from quantum.plugins.linuxbridge.common import config
from quantum.agent.linux import utils
def main():
- usagestr = "%prog [OPTIONS] <config file>"
- parser = OptionParser(usage=usagestr)
- parser.add_option("-v", "--verbose", dest="verbose",
- action="store_true", default=False,
- help="turn on verbose logging")
+ cfg.CONF(args=sys.argv, project='quantum')
- options, args = parser.parse_args()
+ # (TODO) gary - swap with common logging
+ logging_config.setup_logging(cfg.CONF)
- if options.verbose:
- LOG.setLevel(logging.DEBUG)
- else:
- LOG.setLevel(logging.WARNING)
-
- if len(args) != 1:
- parser.print_help()
- sys.exit(1)
-
- config_file = args[0]
- conf = config.parse(config_file)
br_name_prefix = BRIDGE_NAME_PREFIX
- physical_interface = conf.LINUX_BRIDGE.physical_interface
- polling_interval = conf.AGENT.polling_interval
- reconnect_interval = conf.DATABASE.reconnect_interval
- root_helper = conf.AGENT.root_helper
+ physical_interface = cfg.CONF.LINUX_BRIDGE.physical_interface
+ polling_interval = cfg.CONF.AGENT.polling_interval
+ reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
+ root_helper = cfg.CONF.AGENT.root_helper
'Establish database connection and load models'
- db_connection_url = conf.DATABASE.sql_connection
+ db_connection_url = cfg.CONF.DATABASE.sql_connection
plugin = LinuxBridgeQuantumAgent(br_name_prefix, physical_interface,
polling_interval, reconnect_interval,
- root_helper, conf.AGENT.target_v2_api)
+ root_helper, cfg.CONF.AGENT.target_v2_api)
LOG.info("Agent initialized successfully, now running... ")
plugin.daemon_loop(db_connection_url)
]
-def parse(config_file):
- conf = cfg.CONF
- if 'config_file' in conf:
- conf.config_file.append(config_file)
- else:
- conf.config_file = [config_file]
- conf(args=[], default_config_files=conf.config_file)
- conf.register_opts(vlan_opts, "VLANS")
- conf.register_opts(database_opts, "DATABASE")
- conf.register_opts(bridge_opts, "LINUX_BRIDGE")
- conf.register_opts(agent_opts, "AGENT")
- return conf
+cfg.CONF.register_opts(vlan_opts, "VLANS")
+cfg.CONF.register_opts(database_opts, "DATABASE")
+cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE")
+cfg.CONF.register_opts(agent_opts, "AGENT")
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.openstack.common import cfg
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})
+ options = {"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection}
+ options.update({"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries})
+ options.update({"reconnect_interval":
+ cfg.CONF.DATABASE.reconnect_interval})
if base:
options.update({"base": base})
L2_MODEL = l2network_models_v2
"""Prepopulate the vlan_bindings table"""
LOG.debug("create_vlanids() called")
session = db.get_session()
- start = CONF.VLANS.vlan_start
- end = CONF.VLANS.vlan_end
+ start = cfg.CONF.VLANS.vlan_start
+ end = cfg.CONF.VLANS.vlan_end
try:
vlanid = session.query(L2_MODEL.VlanID).one()
except exc.MultipleResultsFound:
filter_by(vlan_id=vlan_id).
one())
vlanid["vlan_used"] = False
- if vlan_id >= CONF.VLANS.vlan_start and vlan_id <= CONF.VLANS.vlan_end:
+ if (vlan_id >= cfg.CONF.VLANS.vlan_start and
+ vlan_id <= cfg.CONF.VLANS.vlan_end):
session.merge(vlanid)
else:
session.delete(vlanid)
import unittest2 as unittest
import quantum.db.api as db
+from quantum.openstack.common import cfg
import quantum.plugins.linuxbridge.common.exceptions as c_exc
import quantum.plugins.linuxbridge.db.l2network_db as l2network_db
for vlan in vlans:
netid = vlan["net-id"]
self.dbtest.delete_vlan_binding(netid)
+
+
+class ConfigurationTest(unittest.TestCase):
+
+ def test_defaults(self):
+ self.assertEqual('sqlite://',
+ cfg.CONF.DATABASE.sql_connection)
+ self.assertEqual(-1,
+ cfg.CONF.DATABASE.sql_max_retries)
+ self.assertEqual(2,
+ cfg.CONF.DATABASE.reconnect_interval)
+ self.assertEqual(2,
+ cfg.CONF.AGENT.polling_interval)
+ self.assertEqual('sudo',
+ cfg.CONF.AGENT.root_helper)
+ self.assertEqual(1000,
+ cfg.CONF.VLANS.vlan_start)
+ self.assertEqual(3000,
+ cfg.CONF.VLANS.vlan_end)
+ self.assertEqual('eth1',
+ cfg.CONF.LINUX_BRIDGE.physical_interface)
# @author: Aaron Rosen, Nicira Networks, Inc.
import logging
-from optparse import OptionParser
import sys
import time
from sqlalchemy.ext import sqlsoup
from quantum.agent.linux import ovs_lib
+from quantum.common import config as logging_config
+from quantum.openstack.common import cfg
from quantum.plugins.openvswitch.common import config
logging.basicConfig()
def main():
- usagestr = "%prog [OPTIONS] <config file>"
- parser = OptionParser(usage=usagestr)
- parser.add_option("-v", "--verbose", dest="verbose",
- action="store_true", default=False,
- help="turn on verbose logging")
+ cfg.CONF(args=sys.argv, project='quantum')
- options, args = parser.parse_args()
-
- if options.verbose:
- LOG.setLevel(logging.DEBUG)
- else:
- LOG.setLevel(logging.WARNING)
-
- if len(args) != 1:
- parser.print_help()
- sys.exit(1)
-
- config_file = args[0]
- conf = config.parse(config_file)
-
- if conf.AGENT.log_file:
- # Avoid to redirect traces to stdout/stderr
- logging.getLogger().handlers = []
- handler = logging.FileHandler(conf.AGENT.log_file)
- formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
- handler.setFormatter(formatter)
- LOG.addHandler(handler)
- LOG.debug('Verbose: %s', options.verbose)
+ # (TODO) gary - swap with common logging
+ logging_config.setup_logging(cfg.CONF)
# Determine which agent type to use.
- enable_tunneling = conf.OVS.enable_tunneling
- integ_br = conf.OVS.integration_bridge
- db_connection_url = conf.DATABASE.sql_connection
- polling_interval = conf.AGENT.polling_interval
- reconnect_interval = conf.DATABASE.reconnect_interval
- root_helper = conf.AGENT.root_helper
+ enable_tunneling = cfg.CONF.OVS.enable_tunneling
+ integ_br = cfg.CONF.OVS.integration_bridge
+ db_connection_url = cfg.CONF.DATABASE.sql_connection
+ polling_interval = cfg.CONF.AGENT.polling_interval
+ reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
+ root_helper = cfg.CONF.AGENT.root_helper
# Determine API Version to use
- target_v2_api = conf.AGENT.target_v2_api
+ target_v2_api = cfg.CONF.AGENT.target_v2_api
if enable_tunneling:
# Get parameters for OVSQuantumTunnelAgent
- tun_br = conf.OVS.tunnel_bridge
+ tun_br = cfg.CONF.OVS.tunnel_bridge
# Mandatory parameter.
- local_ip = conf.OVS.local_ip
+ local_ip = cfg.CONF.OVS.local_ip
plugin = OVSQuantumTunnelAgent(integ_br, tun_br, local_ip, root_helper,
polling_interval, reconnect_interval,
target_v2_api)
]
-def parse(config_file):
- conf = cfg.CONF
- if 'config_file' in conf:
- conf.config_file.append(config_file)
- else:
- conf.config_file = [config_file]
- conf(args=[], default_config_files=conf.config_file)
- conf.register_opts(database_opts, "DATABASE")
- conf.register_opts(ovs_opts, "OVS")
- conf.register_opts(agent_opts, "AGENT")
- return conf
+cfg.CONF.register_opts(database_opts, "DATABASE")
+cfg.CONF.register_opts(ovs_opts, "OVS")
+cfg.CONF.register_opts(agent_opts, "AGENT")
from quantum.db import api as db
from quantum.db import db_base_plugin_v2
from quantum.db import models_v2
+from quantum.openstack.common import cfg
from quantum.plugins.openvswitch.common import config
from quantum.plugins.openvswitch import ovs_db
from quantum.plugins.openvswitch import ovs_db_v2
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 OVSQuantumPlugin(QuantumPluginBase):
def __init__(self, configfile=None):
- conf = config.parse(CONF_FILE)
- options = {"sql_connection": conf.DATABASE.sql_connection}
- sql_max_retries = conf.DATABASE.sql_max_retries
+ options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
+ sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
options.update({"sql_max_retries": sql_max_retries})
- reconnect_interval = conf.DATABASE.reconnect_interval
+ reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
options.update({"reconnect_interval": reconnect_interval})
db.configure_db(options)
- self.vmap = VlanMap(conf.OVS.vlan_min, conf.OVS.vlan_max)
+ self.vmap = VlanMap(cfg.CONF.OVS.vlan_min, cfg.CONF.OVS.vlan_max)
# Populate the map with anything that is already present in the
# database
self.vmap.populate_already_used(ovs_db.get_vlans())
supported_extension_aliases = ["provider"]
def __init__(self, configfile=None):
- conf = config.parse(CONF_FILE)
- self.enable_tunneling = conf.OVS.enable_tunneling
-
- options = {"sql_connection": conf.DATABASE.sql_connection}
+ self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
+ options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
options.update({'base': models_v2.model_base.BASEV2})
- sql_max_retries = conf.DATABASE.sql_max_retries
+ sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
options.update({"sql_max_retries": sql_max_retries})
reconnect_interval = conf.DATABASE.reconnect_interval
options.update({"reconnect_interval": reconnect_interval})
db.configure_db(options)
- self.vmap = VlanMap(conf.OVS.vlan_min, conf.OVS.vlan_max)
+ self.vmap = VlanMap(cfg.CONF.OVS.vlan_min, cfg.CONF.OVS.vlan_max)
self.vmap.populate_already_used(ovs_db_v2.get_vlans())
# TODO(rkukura) Use core mechanism for attribute authorization
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# 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.
+
+import unittest
+
+from quantum.openstack.common import cfg
+
+
+class ConfigurationTest(unittest.TestCase):
+
+ def test_defaults(self):
+ self.assertFalse(cfg.CONF.OVS.enable_tunneling)
+ self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)
+ self.assertEqual('br-tun', cfg.CONF.OVS.tunnel_bridge)
+ self.assertEqual('sqlite://', cfg.CONF.DATABASE.sql_connection)
+ self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries)
+ self.assertEqual(2, cfg.CONF.DATABASE.reconnect_interval)
+ self.assertEqual(2, cfg.CONF.AGENT.polling_interval)
+ self.assertEqual('sudo', cfg.CONF.AGENT.root_helper)
# @author: Isaku Yamahata
import logging as LOG
-from optparse import OptionParser
import sys
import time
from quantum.agent.linux import ovs_lib
from quantum.agent.linux.ovs_lib import VifPort
+from quantum.openstack.common import cfg
from quantum.plugins.ryu.common import config
OP_STATUS_UP = "UP"
def main():
- usagestr = "%prog [OPTIONS] <config file>"
- parser = OptionParser(usage=usagestr)
- parser.add_option("-v", "--verbose", dest="verbose",
- action="store_true", default=False,
- help="turn on verbose logging")
-
- options, args = parser.parse_args()
-
- if options.verbose:
- LOG.basicConfig(level=LOG.DEBUG)
- else:
- LOG.basicConfig(level=LOG.WARN)
-
- if len(args) != 1:
- parser.print_help()
- sys.exit(1)
-
- config_file = args[0]
- conf = config.parse(config_file)
- integ_br = conf.OVS.integration_bridge
- root_helper = conf.AGENT.root_helper
- target_v2_api = conf.AGENT.target_v2_api
- options = {"sql_connection": conf.DATABASE.sql_connection}
+ cfg.CONF(args=sys.argv, project='quantum')
+
+ # (TODO) gary - swap with common logging
+ logging_config.setup_logging(cfg.CONF)
+
+ integ_br = cfg.CONF.OVS.integration_bridge
+ root_helper = cfg.CONF.AGENT.root_helper
+ target_v2_api = cfg.CONF.AGENT.target_v2_api
+ options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
db = SqlSoup(options["sql_connection"])
LOG.info("Connecting to database \"%s\" on %s",
]
-def parse(config_file):
- conf = cfg.CONF
- if 'config_file' in conf:
- conf.config_file.append(config_file)
- else:
- conf.config_file = [config_file]
- conf(args=[], default_config_files=conf.config_file)
- conf.register_opts(database_opts, "DATABASE")
- conf.register_opts(ovs_opts, "OVS")
- conf.register_opts(agent_opts, "AGENT")
- return conf
+cfg.CONF.register_opts(database_opts, "DATABASE")
+cfg.CONF.register_opts(ovs_opts, "OVS")
+cfg.CONF.register_opts(agent_opts, "AGENT")
from quantum.api.api_common import OperationalStatus
from quantum.common import exceptions as q_exc
import quantum.db.api as db
+from quantum.openstack.common import cfg
from quantum.plugins.ryu.common import config
from quantum.quantum_plugin_base import QuantumPluginBase
"""
def __init__(self, conf_file, mod_file, configfile=None):
super(OVSQuantumPluginBase, self).__init__()
- if configfile is None:
- if os.path.exists(conf_file):
- configfile = conf_file
- else:
- configfile = find_config(os.path.abspath(
- os.path.dirname(__file__)))
- if configfile is None:
- raise Exception("Configuration file \"%s\" doesn't exist" %
- (configfile))
- LOG.debug("Using configuration file: %s" % configfile)
- conf = config.parse(configfile)
- options = {"sql_connection": conf.DATABASE.sql_connection}
- sql_max_retries = conf.DATABASE.sql_max_retries
+ options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
+ sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
options.update({"sql_max_retries": sql_max_retries})
- reconnect_interval = conf.DATABASE.reconnect_interval
+ reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
options.update({"reconnect_interval": reconnect_interval})
db.configure_db(options)
- self.conf = conf
+ self.conf = cfg.CONF
# Subclass must set self.driver to its own OVSQuantumPluginDriverBase
self.driver = None
from quantum.plugins.ryu.common import config
LOG = logging.getLogger(__name__)
-CONF_FILE = find_config_file({"plugin": "ryu"}, "ryu.ini")
class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
class RyuQuantumPlugin(ovs_quantum_plugin_base.OVSQuantumPluginBase):
def __init__(self, configfile=None):
- super(RyuQuantumPlugin, self).__init__(CONF_FILE, __file__, configfile)
+ super(RyuQuantumPlugin, self).__init__(__file__, configfile)
self.driver = OFPRyuDriver(self.conf)
class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
def __init__(self, configfile=None):
- if configfile is None:
- if os.path.exists(CONF_FILE):
- configfile = CONF_FILE
- if configfile is None:
- raise Exception("Configuration file \"%s\" doesn't exist" %
- (configfile))
- LOG.debug("Using configuration file: %s" % configfile)
- conf = config.parse(configfile)
- options = {"sql_connection": conf.DATABASE.sql_connection}
+ options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
options.update({'base': models_v2.model_base.BASEV2})
- reconnect_interval = conf.DATABASE.reconnect_interval
+ reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
options.update({"reconnect_interval": reconnect_interval})
db.configure_db(options)
- ofp_con_host = conf.OVS.openflow_controller
- ofp_api_host = conf.OVS.openflow_rest_api
+ ofp_con_host = cfg.CONF.OVS.openflow_controller
+ ofp_api_host = cfg.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")
import mox
+from quantum.openstack.common import cfg
from quantum.plugins.ryu.tests.unit.basetest import BaseRyuTest
from quantum.plugins.ryu.tests.unit import fake_plugin
from quantum.plugins.ryu.tests.unit import utils
plugin.delete_network(tenant_id, ret['net-id'])
self.mox.VerifyAll()
+
+ def test_defaults(self):
+ self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)
+ self.assertEqual('sqlite://', cfg.CONF.DATABASE.sql_connection)
+ self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries)
+ self.assertEqual(2, cfg.CONF.DATABASE.reconnect_interval)
+ self.assertEqual(2, cfg.CONF.AGENT.polling_interval)
+ self.assertEqual('sudo', cfg.CONF.AGENT.root_helper)
+ self.assertEqual('127.0.0.1:6633', cfg.CONF.OVS.openflow_controller)
+ self.assertEqual('127.0.0.1:8080', cfg.CONF.OVS.openflow_rest_api)
import uuid
-from quantum.common.utils import find_config_file
import quantum.db.api as db
+from quantum.openstack.common import cfg
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)
+ self.conf = cfg.CONF
# 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()
+++ /dev/null
-# Copyright (c) 2012 OpenStack, LLC.
-#
-# 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.
-
-import os
-import tempfile
-import unittest
-
-from quantum.openstack.common import cfg
-from quantum.plugins.linuxbridge.common import config
-
-
-class LinuxBridgeConfigTestCase(unittest.TestCase):
- def test_dummy(self):
- configs = """[DATABASE]
-sql_connection = testlink
-sql_max_retries = 200
-reconnect_interval=100
-[AGENT]
-root_helper = mysudo
-polling_interval=50
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='lb_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertEqual('testlink', conf.DATABASE.sql_connection)
- self.assertEqual(200, conf.DATABASE.sql_max_retries)
- self.assertEqual(100, conf.DATABASE.reconnect_interval)
- self.assertEqual(50, conf.AGENT.polling_interval)
- self.assertEqual('mysudo', conf.AGENT.root_helper)
- self.assertEqual(conf.AGENT.polling_interval,
- cfg.CONF.AGENT.polling_interval)
- finally:
- os.remove(path)
-
- def test_defaults(self):
- configs = """
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='lb_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertEqual('sqlite://', conf.DATABASE.sql_connection)
- self.assertEqual(-1, conf.DATABASE.sql_max_retries)
- self.assertEqual(2, conf.DATABASE.reconnect_interval)
- self.assertEqual(2, conf.AGENT.polling_interval)
- self.assertEqual('sudo', conf.AGENT.root_helper)
- self.assertEqual(1000, conf.VLANS.vlan_start)
- self.assertEqual(3000, conf.VLANS.vlan_end)
- self.assertEqual('eth1', conf.LINUX_BRIDGE.physical_interface)
- self.assertEqual(conf.DATABASE.sql_connection,
- cfg.CONF.DATABASE.sql_connection)
- self.assertEqual(conf.AGENT.root_helper,
- cfg.CONF.AGENT.root_helper)
- finally:
- os.remove(path)
-
- def tearDown(self):
- """Clear the test environment"""
- cfg.CONF.reset()
- cfg.CONF.unregister_opts(config.vlan_opts, "VLANS")
- cfg.CONF.unregister_opts(config.database_opts, "DATABASE")
- cfg.CONF.unregister_opts(config.bridge_opts, "LINUX_BRIDGE")
- cfg.CONF.unregister_opts(config.agent_opts, "AGENT")
+++ /dev/null
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-# Copyright 2011 Red Hat, 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.
-
-import os
-import tempfile
-import unittest
-
-from quantum.openstack.common import cfg
-from quantum.plugins.openvswitch.common import config
-
-
-class OvsConfigTestCase(unittest.TestCase):
- def test_tunnel(self):
- configs = """[DATABASE]
-sql_connection = testlink
-sql_max_retries = 200
-reconnect_interval=100
-[OVS]
-enable_tunneling = True
-integration_bridge = mybrint
-tunnel_bridge = mybrtun
-local_ip = 10.0.0.3
-[AGENT]
-root_helper = mysudo
-polling_interval=50
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ovs_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertTrue(conf.OVS.enable_tunneling)
- self.assertEqual('mybrint', conf.OVS.integration_bridge)
- self.assertEqual('mybrtun', conf.OVS.tunnel_bridge)
- self.assertEqual('testlink', conf.DATABASE.sql_connection)
- self.assertEqual(200, conf.DATABASE.sql_max_retries)
- self.assertEqual(100, conf.DATABASE.reconnect_interval)
- self.assertEqual(50, conf.AGENT.polling_interval)
- self.assertEqual('mysudo', conf.AGENT.root_helper)
- self.assertEqual(conf.OVS.integration_bridge,
- cfg.CONF.OVS.integration_bridge)
- finally:
- os.remove(path)
-
- def test_defaults(self):
- configs = """
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ovs_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertFalse(conf.OVS.enable_tunneling)
- self.assertEqual('br-int', conf.OVS.integration_bridge)
- self.assertEqual('br-tun', conf.OVS.tunnel_bridge)
- self.assertEqual('sqlite://', conf.DATABASE.sql_connection)
- self.assertEqual(-1, conf.DATABASE.sql_max_retries)
- self.assertEqual(2, conf.DATABASE.reconnect_interval)
- self.assertEqual(2, conf.AGENT.polling_interval)
- self.assertEqual('sudo', conf.AGENT.root_helper)
- self.assertEqual(conf.DATABASE.sql_connection,
- cfg.CONF.DATABASE.sql_connection)
- self.assertEqual(conf.AGENT.root_helper,
- cfg.CONF.AGENT.root_helper)
- finally:
- os.remove(path)
-
- def test_without_tunnel(self):
- configs = """
-[OVS]
-enable_tunneling = False
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ovs_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertFalse(conf.OVS.enable_tunneling)
- finally:
- os.remove(path)
-
- def test_invalid_values(self):
- configs = """
-[OVS]
-enable_tunneling = notbool
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ovs_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- exception_raised = False
- try:
- tunnel = conf.OVS.enable_tunneling
- except cfg.ConfigFileValueError:
- exception_raised = True
- self.assertTrue(exception_raised)
- finally:
- os.remove(path)
-
- def tearDown(self):
- """Clear the test environment"""
- cfg.CONF.reset()
- cfg.CONF.unregister_opts(config.database_opts, "DATABASE")
- cfg.CONF.unregister_opts(config.ovs_opts, "OVS")
- cfg.CONF.unregister_opts(config.agent_opts, "AGENT")
+++ /dev/null
-# Copyright (c) 2012 OpenStack, LLC.
-#
-# 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.
-
-import os
-import tempfile
-import unittest
-
-from quantum.openstack.common import cfg
-from quantum.plugins.ryu.common import config
-
-
-class RyuConfigTestCase(unittest.TestCase):
- def test_config(self):
- configs = """[DATABASE]
-sql_connection = testlink
-sql_max_retries = 200
-reconnect_interval=100
-[OVS]
-enable_tunneling = True
-integration_bridge = mybrint
-local_ip = 10.0.0.3
-[AGENT]
-root_helper = mysudo
-polling_interval=50
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ryu_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertEqual('mybrint', conf.OVS.integration_bridge)
- self.assertEqual('testlink', conf.DATABASE.sql_connection)
- self.assertEqual(200, conf.DATABASE.sql_max_retries)
- self.assertEqual(100, conf.DATABASE.reconnect_interval)
- self.assertEqual(50, conf.AGENT.polling_interval)
- self.assertEqual('mysudo', conf.AGENT.root_helper)
- self.assertEqual(conf.OVS.integration_bridge,
- cfg.CONF.OVS.integration_bridge)
- finally:
- os.remove(path)
-
- def test_defaults(self):
- configs = """
-"""
-
- (fd, path) = tempfile.mkstemp(prefix='ryu_config', suffix='.ini')
-
- try:
- os.write(fd, configs)
- os.close(fd)
-
- conf = config.parse(path)
- self.assertEqual('br-int', conf.OVS.integration_bridge)
- self.assertEqual('sqlite://', conf.DATABASE.sql_connection)
- self.assertEqual(-1, conf.DATABASE.sql_max_retries)
- self.assertEqual(2, conf.DATABASE.reconnect_interval)
- self.assertEqual(2, conf.AGENT.polling_interval)
- self.assertEqual('sudo', conf.AGENT.root_helper)
- self.assertEqual('127.0.0.1:6633', conf.OVS.openflow_controller)
- self.assertEqual('127.0.0.1:8080', conf.OVS.openflow_rest_api)
- self.assertEqual(conf.DATABASE.sql_connection,
- cfg.CONF.DATABASE.sql_connection)
- self.assertEqual(conf.AGENT.root_helper,
- cfg.CONF.AGENT.root_helper)
- finally:
- os.remove(path)
-
- def tearDown(self):
- """Clear the test environment"""
- cfg.CONF.reset()
- cfg.CONF.unregister_opts(config.database_opts, "DATABASE")
- cfg.CONF.unregister_opts(config.ovs_opts, "OVS")
- cfg.CONF.unregister_opts(config.agent_opts, "AGENT")