当前位置: 首页>>代码示例>>Python>>正文


Python AppManager.instantiate_apps方法代码示例

本文整理汇总了Python中ryu.base.app_manager.AppManager.instantiate_apps方法的典型用法代码示例。如果您正苦于以下问题:Python AppManager.instantiate_apps方法的具体用法?Python AppManager.instantiate_apps怎么用?Python AppManager.instantiate_apps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ryu.base.app_manager.AppManager的用法示例。


在下文中一共展示了AppManager.instantiate_apps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import instantiate_apps [as 别名]
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()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:35,代码来源:manager.py

示例2: main

# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import instantiate_apps [as 别名]
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()
开发者ID:MichalPalatinus,项目名称:ryu,代码行数:34,代码来源:manager.py

示例3: Echo

# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import instantiate_apps [as 别名]
import logging
logging.basicConfig(level=logging.DEBUG)

class Echo(WebSocketHandler):
    def initialize(self, clients=[]):
        super(Echo, self).initialize()
        self.clients = clients
    def open(self):
        self.clients.append(self)
    def on_message(self, message):
        for client in self.clients:
            client.write_message("hello")
    def close(self):
        print "bye"

ws_clients = []
Application([
    ("/echo", Echo, {"clients":ws_clients}),
    ], 
    static_path=os.path.join(os.path.dirname(__file__), "html")).listen(8888)

apps = AppManager()
apps.load_apps(["ryu.controller.ofp_handler", "ryu.app.simple_switch", "ofc2ws"])
contexts = apps.create_contexts()
contexts["ws_clients"] = ws_clients
apps.instantiate_apps(**contexts)

OpenflowController().listen(6633)

IOLoop.instance().start()
开发者ID:hkwi,项目名称:hkwi_seeds,代码行数:32,代码来源:boot_example.py


注:本文中的ryu.base.app_manager.AppManager.instantiate_apps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。