Пример #1
0
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.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
    'Establish database connection and load models'
    db_connection_url = conf.DATABASE.sql_connection
    LOG.info("Connecting to %s" % (db_connection_url))

    plugin = LinuxBridgeQuantumAgent(br_name_prefix, physical_interface,
                                     polling_interval, reconnect_interval,
                                     root_helper)
    LOG.info("Agent initialized successfully, now running... ")
    plugin.daemon_loop(db_connection_url)

    sys.exit(0)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
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.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
    'Establish database connection and load models'
    db_connection_url = conf.DATABASE.sql_connection
    LOG.info("Connecting to %s" % (db_connection_url))

    plugin = LinuxBridgeQuantumAgent(br_name_prefix, physical_interface,
                                     polling_interval, reconnect_interval,
                                     root_helper)
    LOG.info("Agent initialized successfully, now running... ")
    plugin.daemon_loop(db_connection_url)

    sys.exit(0)
Пример #5
0
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
    end = CONF.VLANS.vlan_end
Пример #6
0
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()