本文整理汇总了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()
示例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()
示例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()