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 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 options = {"sql_connection": conf.DATABASE.sql_connection} db = SqlSoup(options["sql_connection"]) LOG.info("Connecting to database \"%s\" on %s", db.engine.url.database, db.engine.url.host) plugin = OVSQuantumOFPRyuAgent(integ_br, db, root_helper) plugin.daemon_loop(db) sys.exit(0)
def test_config(self): configs = """[DATABASE] sql_connection = testlink 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(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 __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} reconnect_interval = conf.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) db.configure_db(options) self.conf = conf # Subclass must set self.driver to its own OVSQuantumPluginDriverBase self.driver = None
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} reconnect_interval = conf.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) db.configure_db(options) self.conf = conf # Subclass must set self.driver to its own OVSQuantumPluginDriverBase self.driver = None