def main():
    try:
        CONF(project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    app_lists = CONF.app_lists + CONF.app

    app_mgr = AppManager()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    app_mgr.instantiate_apps(**contexts)

    services = []

    # TODO: do the following in app_manager's instantiate_apps()
    ofpapp = controller.start_service(app_mgr)
    if ofpapp:
        thr = hub.spawn(ofpapp)
        services.append(thr)

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #2
0
def main():
    try:
        CONF(project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #3
0
def main():
    try:
        CONF(project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #4
0
def main():
    try:
        CONF(project='ryu',
             version='ofa_neutron_agent %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ofa_neutron_agent %s' % version)

    osn_config.setup_logging(CONF)

    app_lists = CONF.app_lists + CONF.app
    if not app_lists:
        app_lists = [
            'ryu.app.ofctl.service',
            'neutron.plugins.ofagent.agent.ofa_neutron_agent'
        ]

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #5
0
def main():
    try:
        CONF(project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    # always enable ofp for now.
    app_lists = CONF.app_lists + CONF.app + ['ryu.controller.ofp_handler']

    app_mgr = AppManager()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    app_mgr.instantiate_apps(**contexts)

    services = []

    ctlr = controller.OpenFlowController()
    thr = hub.spawn(ctlr)
    services.append(thr)

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #6
0
def main(args=None, prog=None):
    # 加载函数库
    _parse_user_flags()

    # 加载配置文件
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)

    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behavior, run ofp if no application is specified.
    # 如果配置文件的列表为空,则加载ryu.controller.ofp_handler
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    # 创建实例,调用get_instance,实现单例模式
    app_mgr = AppManager.get_instance()
    # 加载app_lists中的app
    app_mgr.load_apps(app_lists)
    # 创建上下文
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        # 加入services列表
        services.append(thr)

    try:
        # 对server服务列表遍历wait
        hub.joinall(services)
    except KeyboardInterrupt:
        # KeyboardInterrupt 用户中断执行(通常是输入^C)
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()
Beispiel #7
0
def main():
    try:
        CONF(project='ryu', version='ofa_neutron_agent %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ofa_neutron_agent %s' % version)

    osn_config.setup_logging(CONF)

    app_lists = CONF.app_lists + CONF.app
    if not app_lists:
        app_lists = ['neutron.plugins.ofagent.agent.ofa_neutron_agent']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #8
0
def main():
    try:
        CONF(project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    # always enable ofp for now.
    app_lists = CONF.app_lists + CONF.app + ['ryu.controller.ofp_handler']

    app_mgr = AppManager()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    app_mgr.instantiate_apps(**contexts)

    services = []

    ctlr = controller.OpenFlowController()
    thr = hub.spawn(ctlr)
    services.append(thr)

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #9
0
def main():
    try:
        CONF(project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    app_lists = CONF.app_lists + CONF.app

    app_mgr = AppManager()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    app_mgr.instantiate_apps(**contexts)

    services = []

    # TODO: do the following in app_manager's instantiate_apps()
    ofpapp = controller.start_service(app_mgr)
    if ofpapp:
        thr = hub.spawn(ofpapp)
        services.append(thr)

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #10
0
def main():
    app_lists = ['ryu.controller.ofp_handler', 'TestId1', 'TestId2']

    app_mgr = app_manager.AppManager.get_instance()
    # app_mgr.run_apps(app_lists)
    app_mgr.contexts_cls.update({'TestId1': TestId1, 'TestId2': TestId2})
    contexts = app_mgr.create_contexts()
    services = app_mgr.instantiate_apps(**contexts)
    webapp = ryuwsgi.start_service(app_mgr)
Beispiel #11
0
def main(args=None, prog=None):
    _parse_user_flags()
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)

    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # print('1:app_lists:',app_lists)    #('1:app_lists:', [])
    # keep old behavior, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    # print('2:app_mgr',app_mgr)     #('2:app_mgr', <ryu.base.app_manager.AppManager object at 0x7ff3ce974450>)
    app_mgr.load_apps(app_lists)
    # print('17:app_lists:',app_lists)   #('17:app_lists:', ['ryu.controller.ofp_handler'])
    contexts = app_mgr.create_contexts()
    # print('22:contexts',contexts)   #('22:contexts', {})
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))
    # print('services:',services)
    #('services:', [<eventlet.greenthread.GreenThread object at 0x7f4f3540c190>])

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()
Beispiel #12
0
def main(args=None, prog=None):

    _parse_user_flags()
    try:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version)

    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behavior, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()

    app_mgr.load_apps(app_lists)

    # sys.stdout.write("hello world!\n")

    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))


    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        for name, app in app_mgr.applications.items():
            if getattr(app, "set_xml", None):
                app.set_xml()
        app_mgr.close()
Beispiel #13
0
def main(args=None, prog=None):
    _parse_user_flags()
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)

    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behavior, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    # step1: 实例化AppManager,是之后管理的基础
    app_mgr = AppManager.get_instance()
    # step2:加载需要的服务,并不实例化,只是保存在对应字典中,还要加载每个app所需要的app
    app_mgr.load_apps(app_lists)
    # step3:实例化依赖模块,上面的APP可能需要其他模块服务,进行实例化
    contexts = app_mgr.create_contexts()
    services = []
    # step4:关键的一步,实例化app
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()
Beispiel #14
0
def main(args=None, prog=None):
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)

    log.init_log()

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    #if CONF.oxp_role == 'super':
    #    app_lists.extend(['ryu.openexchange.super.oxp_server_handler',
    #                      'ryu.openexchange.super.topology',
    #                      'ryu.openexchange.super.routing'])

    #elif CONF.oxp_role == 'domain':
    #    app_lists.extend(
    #        ['ryu.openexchange.domain.oxp_client_handler',
    #         'ryu.openexchange.network.abstract',
    #         'ryu.openexchange.network.topo_reply',
    #         'ryu.openexchange.network.echo_loop',
    #         'ryu.openexchange.domain.translation'])

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #15
0
def main(args=None, prog=None):
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager {}'.format(version),
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager {}'.format(version))

    log.init_log()
    hub.patch(thread=True)

    if CONF.pid_file:
        LOG.info('Pid file : %s', CONF.pid_file)
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app

    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler', 'dragon_knight.dk_plugin']

    if 'ryu.controller.ofp_handler' not in app_lists:
        app_lists.append('ryu.controller.ofp_handler')

    if 'dragon_knight.dk_plugin' not in app_lists:
        app_lists.append('dragon_knight.dk_plugin')

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)

    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)

    finally:
        app_mgr.close()
def main(args=None, prog=None):
    try:
        CONF(
            args=args,
            prog=prog,
            project="ryu",
            version="ryu-manager {}".format(version),
            default_config_files=["/usr/local/etc/ryu/ryu.conf"],
        )
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, prog=prog, project="ryu", version="ryu-manager {}".format(version))

    log.init_log()
    hub.patch(thread=True)

    if CONF.pid_file:
        LOG.info("Pid file : %s", CONF.pid_file)
        import os

        with open(CONF.pid_file, "w") as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app

    if not app_lists:
        app_lists = ["ryu.controller.ofp_handler", "dragon_knight.dk_plugin"]

    if "ryu.controller.ofp_handler" not in app_lists:
        app_lists.append("ryu.controller.ofp_handler")

    if "dragon_knight.dk_plugin" not in app_lists:
        app_lists.append("dragon_knight.dk_plugin")

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)

    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)

    finally:
        app_mgr.close()
Beispiel #17
0
def main(args=None, prog=None):
    try:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    #if CONF.oxp_role == 'super':
    #    app_lists.extend(['ryu.openexchange.super.oxp_server_handler',
    #                      'ryu.openexchange.super.topology',
    #                      'ryu.openexchange.super.routing'])

    #elif CONF.oxp_role == 'domain':
    #    app_lists.extend(
    #        ['ryu.openexchange.domain.oxp_client_handler',
    #         'ryu.openexchange.network.abstract',
    #         'ryu.openexchange.network.topo_reply',
    #         'ryu.openexchange.network.echo_loop',
    #         'ryu.openexchange.domain.translation'])

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #18
0
def main(args=None, prog=None):
    try:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)

    log.init_log()

    if CONF.enable_debugger:
        LOG = logging.getLogger('ryu.cmd.manager')
        msg = 'debugging is available (--enable-debugger option is turned on)'
        LOG.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #19
0
def main(args=None, prog=None):
    try:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version)

    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behavior, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()
Beispiel #20
0
    def run_apps(app_lists):
        """Run a set of Ryu applications

        A convenient method to load and instantiate apps.
        This blocks until all relevant apps stop.
        """
        app_mgr = AppManager.get_instance()
        app_mgr.load_apps(app_lists)
        contexts = app_mgr.create_contexts()
        services = app_mgr.instantiate_apps(**contexts)
        webapp = wsgi.start_service(app_mgr)
        if webapp:
            services.append(hub.spawn(webapp))
        try:
            hub.joinall(services)
        finally:
            app_mgr.close()
Beispiel #21
0
    def run_apps(app_lists):
        """Run a set of Ryu applications

        A convenient method to load and instantiate apps.
        This blocks until all relevant apps stop.
        """
        app_mgr = AppManager.get_instance()
        app_mgr.load_apps(app_lists)
        contexts = app_mgr.create_contexts()
        services = app_mgr.instantiate_apps(**contexts)
        webapp = wsgi.start_service(app_mgr)
        if webapp:
            services.append(hub.spawn(webapp))
        try:
            hub.joinall(services)
        finally:
            app_mgr.close()
Beispiel #22
0
def main():
    log.init_log()
    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(['./ryu_controller.py'])

    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    print services
    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #23
0
def real_main():
    LOGGER.info('I win leader election, Ryu controller start running')

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #24
0
def main(args=None, prog=None):
    try:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, prog=prog,
             project='ryu', version='ryu-manager %s' % version)

    log.init_log()

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))

    app_lists = CONF.app_lists + CONF.app
    # keep old behaivor, run ofp if no application is specified.
    if not app_lists:
        app_lists = ['ryu.controller.ofp_handler']
    # add oxp_handler
    #app_lists.append('ryu.openexchange.oxp_handler')
    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    finally:
        app_mgr.close()
Beispiel #25
0
            pid_file.write(str(os.getpid()))
    app_lists = CONF.app_lists + CONF.app
    print(app_lists)
    

	# keep old behavior, run ofp if no application is specified.
	if not app_lists:
		#app_lists = ['ryu.controller.ofp_handler']
		app_lists = ['ryu.app.rest_firewall']
	app_mgr = AppManager.get_instance()
	app_mgr.load_apps(app_lists)
	contexts = app_mgr.create_contexts()
	services = []
	services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)

    try:
        hub.joinall(services)
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()


if __name__ == "__main__":
    main()
Beispiel #26
0
def main(args=None, prog=None):

    print('aaa')
    try:
        print('aaa')
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version,
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='ryu',
             version='ryu-manager %s' % version)
    log.init_log()
    logger = logging.getLogger(__name__)

    if CONF.enable_debugger:
        msg = 'debugging is available (--enable-debugger option is turned on)'
        logger.info(msg)
    else:
        hub.patch(thread=True)

    if CONF.pid_file:
        import os
        with open(CONF.pid_file, 'w') as pid_file:
            pid_file.write(str(os.getpid()))
    app_lists = CONF.app_lists + CONF.app
    print(app_lists)

    # keep old behavior, run ofp if no application is specified.
    if not app_lists:
        #app_lists = ['ryu.controller.ofp_handler']
        print('bbb')
        app_lists = ['ryu.app.rest_firewall']

    app_mgr = AppManager.get_instance()
    app_mgr.load_apps(app_lists)
    contexts = app_mgr.create_contexts()
    print('contexts:')
    print(contexts)

    services = []
    services.extend(app_mgr.instantiate_apps(**contexts))

    webapp = wsgi.start_service(app_mgr)
    print('ccc')
    print(webapp)
    if webapp:
        thr = hub.spawn(webapp)
        services.append(thr)
    print('ddd')
    try:
        print(services[0])
        services[1].wait()
        print('eee3')
        services[0].wait()
        print('eee')
        hub.joinall(services)
        print('fff')
    except KeyboardInterrupt:
        logger.debug("Keyboard Interrupt received. "
                     "Closing RYU application manager...")
    finally:
        app_mgr.close()
Beispiel #27
0
def start(app_manager):
    webapp = wsgi.start_service(app_manager)
    return hub.spawn(webapp)