Merge "Enable agents and plugins to use the same configuration file."
This commit is contained in:
commit
58ce34c6a7
@ -98,6 +98,8 @@ mysql> FLUSH PRIVILEGES;
|
|||||||
Make sure it matches your mysql configuration. This file must be updated
|
Make sure it matches your mysql configuration. This file must be updated
|
||||||
with the addresses and credentials to access the database.
|
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
|
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
|
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).
|
of these should be active in the conf file (you can comment out the other).
|
||||||
@ -116,9 +118,13 @@ mysql> FLUSH PRIVILEGES;
|
|||||||
and etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
|
and etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
|
||||||
to the compute node.
|
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:
|
$ Run the following:
|
||||||
python linuxbridge_quantum_agent.py linuxbridge_conf.ini
|
python linuxbridge_quantum_agent.py --config-file quantum.conf
|
||||||
(Use --verbose option to see the logs)
|
--config-file linuxbridge_conf.ini
|
||||||
|
|
||||||
Note that the the user running the agent must have sudo priviliges
|
Note that the the user running the agent must have sudo priviliges
|
||||||
to run various networking commands. Also, the agent can be
|
to run various networking commands. Also, the agent can be
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from optparse import OptionParser
|
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import signal
|
import signal
|
||||||
@ -33,6 +32,8 @@ import time
|
|||||||
|
|
||||||
from sqlalchemy.ext.sqlsoup import SqlSoup
|
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.plugins.linuxbridge.common import config
|
||||||
|
|
||||||
from quantum.agent.linux import utils
|
from quantum.agent.linux import utils
|
||||||
@ -486,35 +487,21 @@ class LinuxBridgeQuantumAgent:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usagestr = "%prog [OPTIONS] <config file>"
|
cfg.CONF(args=sys.argv, project='quantum')
|
||||||
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()
|
# (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
|
br_name_prefix = BRIDGE_NAME_PREFIX
|
||||||
physical_interface = conf.LINUX_BRIDGE.physical_interface
|
physical_interface = cfg.CONF.LINUX_BRIDGE.physical_interface
|
||||||
polling_interval = conf.AGENT.polling_interval
|
polling_interval = cfg.CONF.AGENT.polling_interval
|
||||||
reconnect_interval = conf.DATABASE.reconnect_interval
|
reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
|
||||||
root_helper = conf.AGENT.root_helper
|
root_helper = cfg.CONF.AGENT.root_helper
|
||||||
'Establish database connection and load models'
|
'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,
|
plugin = LinuxBridgeQuantumAgent(br_name_prefix, physical_interface,
|
||||||
polling_interval, reconnect_interval,
|
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... ")
|
LOG.info("Agent initialized successfully, now running... ")
|
||||||
plugin.daemon_loop(db_connection_url)
|
plugin.daemon_loop(db_connection_url)
|
||||||
|
|
||||||
|
@ -42,15 +42,7 @@ agent_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def parse(config_file):
|
cfg.CONF.register_opts(vlan_opts, "VLANS")
|
||||||
conf = cfg.CONF
|
cfg.CONF.register_opts(database_opts, "DATABASE")
|
||||||
if 'config_file' in conf:
|
cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE")
|
||||||
conf.config_file.append(config_file)
|
cfg.CONF.register_opts(agent_opts, "AGENT")
|
||||||
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
|
|
||||||
|
@ -21,17 +21,14 @@ from sqlalchemy import func
|
|||||||
from sqlalchemy.orm import exc
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
from quantum.common import exceptions as q_exc
|
from quantum.common import exceptions as q_exc
|
||||||
from quantum.common.utils import find_config_file
|
|
||||||
import quantum.db.api as db
|
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 config
|
||||||
from quantum.plugins.linuxbridge.common import exceptions as c_exc
|
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
|
||||||
from quantum.plugins.linuxbridge.db import l2network_models_v2
|
from quantum.plugins.linuxbridge.db import l2network_models_v2
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
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
|
# The global variable for the database version model
|
||||||
L2_MODEL = l2network_models
|
L2_MODEL = l2network_models
|
||||||
@ -39,9 +36,10 @@ L2_MODEL = l2network_models
|
|||||||
|
|
||||||
def initialize(base=None):
|
def initialize(base=None):
|
||||||
global L2_MODEL
|
global L2_MODEL
|
||||||
options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
|
options = {"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection}
|
||||||
options.update({"sql_max_retries": CONF.DATABASE.sql_max_retries})
|
options.update({"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries})
|
||||||
options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
|
options.update({"reconnect_interval":
|
||||||
|
cfg.CONF.DATABASE.reconnect_interval})
|
||||||
if base:
|
if base:
|
||||||
options.update({"base": base})
|
options.update({"base": base})
|
||||||
L2_MODEL = l2network_models_v2
|
L2_MODEL = l2network_models_v2
|
||||||
@ -53,8 +51,8 @@ def create_vlanids():
|
|||||||
"""Prepopulate the vlan_bindings table"""
|
"""Prepopulate the vlan_bindings table"""
|
||||||
LOG.debug("create_vlanids() called")
|
LOG.debug("create_vlanids() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
start = CONF.VLANS.vlan_start
|
start = cfg.CONF.VLANS.vlan_start
|
||||||
end = CONF.VLANS.vlan_end
|
end = cfg.CONF.VLANS.vlan_end
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(L2_MODEL.VlanID).one()
|
vlanid = session.query(L2_MODEL.VlanID).one()
|
||||||
except exc.MultipleResultsFound:
|
except exc.MultipleResultsFound:
|
||||||
@ -120,7 +118,8 @@ def release_vlanid(vlan_id):
|
|||||||
filter_by(vlan_id=vlan_id).
|
filter_by(vlan_id=vlan_id).
|
||||||
one())
|
one())
|
||||||
vlanid["vlan_used"] = False
|
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)
|
session.merge(vlanid)
|
||||||
else:
|
else:
|
||||||
session.delete(vlanid)
|
session.delete(vlanid)
|
||||||
|
@ -24,6 +24,7 @@ import logging
|
|||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
import quantum.db.api as db
|
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.common.exceptions as c_exc
|
||||||
import quantum.plugins.linuxbridge.db.l2network_db as l2network_db
|
import quantum.plugins.linuxbridge.db.l2network_db as l2network_db
|
||||||
|
|
||||||
@ -265,3 +266,24 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
for vlan in vlans:
|
for vlan in vlans:
|
||||||
netid = vlan["net-id"]
|
netid = vlan["net-id"]
|
||||||
self.dbtest.delete_vlan_binding(netid)
|
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)
|
||||||
|
@ -21,13 +21,14 @@
|
|||||||
# @author: Aaron Rosen, Nicira Networks, Inc.
|
# @author: Aaron Rosen, Nicira Networks, Inc.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from optparse import OptionParser
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from sqlalchemy.ext import sqlsoup
|
from sqlalchemy.ext import sqlsoup
|
||||||
|
|
||||||
from quantum.agent.linux import ovs_lib
|
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
|
from quantum.plugins.openvswitch.common import config
|
||||||
|
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
@ -548,51 +549,27 @@ class OVSQuantumTunnelAgent(object):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usagestr = "%prog [OPTIONS] <config file>"
|
cfg.CONF(args=sys.argv, project='quantum')
|
||||||
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()
|
# (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)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Determine which agent type to use.
|
# Determine which agent type to use.
|
||||||
enable_tunneling = conf.OVS.enable_tunneling
|
enable_tunneling = cfg.CONF.OVS.enable_tunneling
|
||||||
integ_br = conf.OVS.integration_bridge
|
integ_br = cfg.CONF.OVS.integration_bridge
|
||||||
db_connection_url = conf.DATABASE.sql_connection
|
db_connection_url = cfg.CONF.DATABASE.sql_connection
|
||||||
polling_interval = conf.AGENT.polling_interval
|
polling_interval = cfg.CONF.AGENT.polling_interval
|
||||||
reconnect_interval = conf.DATABASE.reconnect_interval
|
reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
|
||||||
root_helper = conf.AGENT.root_helper
|
root_helper = cfg.CONF.AGENT.root_helper
|
||||||
|
|
||||||
# Determine API Version to use
|
# 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:
|
if enable_tunneling:
|
||||||
# Get parameters for OVSQuantumTunnelAgent
|
# Get parameters for OVSQuantumTunnelAgent
|
||||||
tun_br = conf.OVS.tunnel_bridge
|
tun_br = cfg.CONF.OVS.tunnel_bridge
|
||||||
# Mandatory parameter.
|
# 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,
|
plugin = OVSQuantumTunnelAgent(integ_br, tun_br, local_ip, root_helper,
|
||||||
polling_interval, reconnect_interval,
|
polling_interval, reconnect_interval,
|
||||||
target_v2_api)
|
target_v2_api)
|
||||||
|
@ -40,14 +40,6 @@ agent_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def parse(config_file):
|
cfg.CONF.register_opts(database_opts, "DATABASE")
|
||||||
conf = cfg.CONF
|
cfg.CONF.register_opts(ovs_opts, "OVS")
|
||||||
if 'config_file' in conf:
|
cfg.CONF.register_opts(agent_opts, "AGENT")
|
||||||
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
|
|
||||||
|
@ -30,6 +30,7 @@ from quantum.common.utils import find_config_file
|
|||||||
from quantum.db import api as db
|
from quantum.db import api as db
|
||||||
from quantum.db import db_base_plugin_v2
|
from quantum.db import db_base_plugin_v2
|
||||||
from quantum.db import models_v2
|
from quantum.db import models_v2
|
||||||
|
from quantum.openstack.common import cfg
|
||||||
from quantum.plugins.openvswitch.common import config
|
from quantum.plugins.openvswitch.common import config
|
||||||
from quantum.plugins.openvswitch import ovs_db
|
from quantum.plugins.openvswitch import ovs_db
|
||||||
from quantum.plugins.openvswitch import ovs_db_v2
|
from quantum.plugins.openvswitch import ovs_db_v2
|
||||||
@ -38,8 +39,6 @@ from quantum import policy
|
|||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("ovs_quantum_plugin")
|
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
|
# Exception thrown if no more VLANs are available
|
||||||
@ -117,15 +116,14 @@ class VlanMap(object):
|
|||||||
class OVSQuantumPlugin(QuantumPluginBase):
|
class OVSQuantumPlugin(QuantumPluginBase):
|
||||||
|
|
||||||
def __init__(self, configfile=None):
|
def __init__(self, configfile=None):
|
||||||
conf = config.parse(CONF_FILE)
|
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
|
||||||
options = {"sql_connection": conf.DATABASE.sql_connection}
|
sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
|
||||||
sql_max_retries = conf.DATABASE.sql_max_retries
|
|
||||||
options.update({"sql_max_retries": 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})
|
options.update({"reconnect_interval": reconnect_interval})
|
||||||
db.configure_db(options)
|
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
|
# Populate the map with anything that is already present in the
|
||||||
# database
|
# database
|
||||||
self.vmap.populate_already_used(ovs_db.get_vlans())
|
self.vmap.populate_already_used(ovs_db.get_vlans())
|
||||||
@ -267,18 +265,16 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
supported_extension_aliases = ["provider"]
|
supported_extension_aliases = ["provider"]
|
||||||
|
|
||||||
def __init__(self, configfile=None):
|
def __init__(self, configfile=None):
|
||||||
conf = config.parse(CONF_FILE)
|
self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
|
||||||
self.enable_tunneling = conf.OVS.enable_tunneling
|
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
|
||||||
|
|
||||||
options = {"sql_connection": conf.DATABASE.sql_connection}
|
|
||||||
options.update({'base': models_v2.model_base.BASEV2})
|
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})
|
options.update({"sql_max_retries": sql_max_retries})
|
||||||
reconnect_interval = conf.DATABASE.reconnect_interval
|
reconnect_interval = conf.DATABASE.reconnect_interval
|
||||||
options.update({"reconnect_interval": reconnect_interval})
|
options.update({"reconnect_interval": reconnect_interval})
|
||||||
db.configure_db(options)
|
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())
|
self.vmap.populate_already_used(ovs_db_v2.get_vlans())
|
||||||
|
|
||||||
# TODO(rkukura) Use core mechanism for attribute authorization
|
# TODO(rkukura) Use core mechanism for attribute authorization
|
||||||
|
31
quantum/plugins/openvswitch/tests/unit/test_defaults.py
Normal file
31
quantum/plugins/openvswitch/tests/unit/test_defaults.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# 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)
|
@ -21,7 +21,6 @@
|
|||||||
# @author: Isaku Yamahata
|
# @author: Isaku Yamahata
|
||||||
|
|
||||||
import logging as LOG
|
import logging as LOG
|
||||||
from optparse import OptionParser
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ from sqlalchemy.ext.sqlsoup import SqlSoup
|
|||||||
|
|
||||||
from quantum.agent.linux import ovs_lib
|
from quantum.agent.linux import ovs_lib
|
||||||
from quantum.agent.linux.ovs_lib import VifPort
|
from quantum.agent.linux.ovs_lib import VifPort
|
||||||
|
from quantum.openstack.common import cfg
|
||||||
from quantum.plugins.ryu.common import config
|
from quantum.plugins.ryu.common import config
|
||||||
|
|
||||||
OP_STATUS_UP = "UP"
|
OP_STATUS_UP = "UP"
|
||||||
@ -224,29 +224,15 @@ class OVSQuantumOFPRyuAgent:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usagestr = "%prog [OPTIONS] <config file>"
|
cfg.CONF(args=sys.argv, project='quantum')
|
||||||
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()
|
# (TODO) gary - swap with common logging
|
||||||
|
logging_config.setup_logging(cfg.CONF)
|
||||||
|
|
||||||
if options.verbose:
|
integ_br = cfg.CONF.OVS.integration_bridge
|
||||||
LOG.basicConfig(level=LOG.DEBUG)
|
root_helper = cfg.CONF.AGENT.root_helper
|
||||||
else:
|
target_v2_api = cfg.CONF.AGENT.target_v2_api
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
|
||||||
|
|
||||||
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}
|
|
||||||
db = SqlSoup(options["sql_connection"])
|
db = SqlSoup(options["sql_connection"])
|
||||||
|
|
||||||
LOG.info("Connecting to database \"%s\" on %s",
|
LOG.info("Connecting to database \"%s\" on %s",
|
||||||
|
@ -36,14 +36,6 @@ agent_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def parse(config_file):
|
cfg.CONF.register_opts(database_opts, "DATABASE")
|
||||||
conf = cfg.CONF
|
cfg.CONF.register_opts(ovs_opts, "OVS")
|
||||||
if 'config_file' in conf:
|
cfg.CONF.register_opts(agent_opts, "AGENT")
|
||||||
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
|
|
||||||
|
@ -23,6 +23,7 @@ import os
|
|||||||
from quantum.api.api_common import OperationalStatus
|
from quantum.api.api_common import OperationalStatus
|
||||||
from quantum.common import exceptions as q_exc
|
from quantum.common import exceptions as q_exc
|
||||||
import quantum.db.api as db
|
import quantum.db.api as db
|
||||||
|
from quantum.openstack.common import cfg
|
||||||
from quantum.plugins.ryu.common import config
|
from quantum.plugins.ryu.common import config
|
||||||
from quantum.quantum_plugin_base import QuantumPluginBase
|
from quantum.quantum_plugin_base import QuantumPluginBase
|
||||||
|
|
||||||
@ -54,25 +55,14 @@ class OVSQuantumPluginBase(QuantumPluginBase):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, conf_file, mod_file, configfile=None):
|
def __init__(self, conf_file, mod_file, configfile=None):
|
||||||
super(OVSQuantumPluginBase, self).__init__()
|
super(OVSQuantumPluginBase, self).__init__()
|
||||||
if configfile is None:
|
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
|
||||||
if os.path.exists(conf_file):
|
sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
|
||||||
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.update({"sql_max_retries": 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})
|
options.update({"reconnect_interval": reconnect_interval})
|
||||||
db.configure_db(options)
|
db.configure_db(options)
|
||||||
|
|
||||||
self.conf = conf
|
self.conf = cfg.CONF
|
||||||
# Subclass must set self.driver to its own OVSQuantumPluginDriverBase
|
# Subclass must set self.driver to its own OVSQuantumPluginDriverBase
|
||||||
self.driver = None
|
self.driver = None
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ from quantum.plugins.ryu import ovs_quantum_plugin_base
|
|||||||
from quantum.plugins.ryu.common import config
|
from quantum.plugins.ryu.common import config
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF_FILE = find_config_file({"plugin": "ryu"}, "ryu.ini")
|
|
||||||
|
|
||||||
|
|
||||||
class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
|
class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
|
||||||
@ -70,28 +69,20 @@ class OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
|
|||||||
|
|
||||||
class RyuQuantumPlugin(ovs_quantum_plugin_base.OVSQuantumPluginBase):
|
class RyuQuantumPlugin(ovs_quantum_plugin_base.OVSQuantumPluginBase):
|
||||||
def __init__(self, configfile=None):
|
def __init__(self, configfile=None):
|
||||||
super(RyuQuantumPlugin, self).__init__(CONF_FILE, __file__, configfile)
|
super(RyuQuantumPlugin, self).__init__(__file__, configfile)
|
||||||
self.driver = OFPRyuDriver(self.conf)
|
self.driver = OFPRyuDriver(self.conf)
|
||||||
|
|
||||||
|
|
||||||
class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||||
def __init__(self, configfile=None):
|
def __init__(self, configfile=None):
|
||||||
if configfile is None:
|
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
|
||||||
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.update({'base': models_v2.model_base.BASEV2})
|
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})
|
options.update({"reconnect_interval": reconnect_interval})
|
||||||
db.configure_db(options)
|
db.configure_db(options)
|
||||||
|
|
||||||
ofp_con_host = conf.OVS.openflow_controller
|
ofp_con_host = cfg.CONF.OVS.openflow_controller
|
||||||
ofp_api_host = conf.OVS.openflow_rest_api
|
ofp_api_host = cfg.CONF.OVS.openflow_rest_api
|
||||||
|
|
||||||
if ofp_con_host is None or ofp_api_host is None:
|
if ofp_con_host is None or ofp_api_host is None:
|
||||||
raise q_exc.Invalid("invalid configuration. check ryu.ini")
|
raise q_exc.Invalid("invalid configuration. check ryu.ini")
|
||||||
|
@ -19,6 +19,7 @@ import os
|
|||||||
|
|
||||||
import mox
|
import mox
|
||||||
|
|
||||||
|
from quantum.openstack.common import cfg
|
||||||
from quantum.plugins.ryu.tests.unit.basetest import BaseRyuTest
|
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 fake_plugin
|
||||||
from quantum.plugins.ryu.tests.unit import utils
|
from quantum.plugins.ryu.tests.unit import utils
|
||||||
@ -53,3 +54,13 @@ class PluginBaseTest(BaseRyuTest):
|
|||||||
|
|
||||||
plugin.delete_network(tenant_id, ret['net-id'])
|
plugin.delete_network(tenant_id, ret['net-id'])
|
||||||
self.mox.VerifyAll()
|
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)
|
||||||
|
@ -17,22 +17,19 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from quantum.common.utils import find_config_file
|
|
||||||
import quantum.db.api as db
|
import quantum.db.api as db
|
||||||
|
from quantum.openstack.common import cfg
|
||||||
from quantum.plugins.ryu.common import config
|
from quantum.plugins.ryu.common import config
|
||||||
from quantum.plugins.ryu.tests.unit.basetest import BaseRyuTest
|
from quantum.plugins.ryu.tests.unit.basetest import BaseRyuTest
|
||||||
from quantum.plugins.ryu.tests.unit import utils
|
from quantum.plugins.ryu.tests.unit import utils
|
||||||
from quantum.plugins.ryu.tests.unit.utils import patch_fake_ryu_client
|
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 RyuDriverTest(BaseRyuTest):
|
||||||
"""Class conisting of OFPRyuDriver unit tests"""
|
"""Class conisting of OFPRyuDriver unit tests"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(RyuDriverTest, self).setUp()
|
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
|
# fake up ryu.app.client and ryu.app.rest_nw_id
|
||||||
# With those, plugin can be tested without ryu installed
|
# With those, plugin can be tested without ryu installed
|
||||||
self.module_patcher = patch_fake_ryu_client()
|
self.module_patcher = patch_fake_ryu_client()
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
# 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")
|
|
@ -1,134 +0,0 @@
|
|||||||
# 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")
|
|
@ -1,88 +0,0 @@
|
|||||||
# 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")
|
|
Loading…
Reference in New Issue
Block a user