本文整理汇总了Python中ryu.base.app_manager.AppManager.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python AppManager.get_instance方法的具体用法?Python AppManager.get_instance怎么用?Python AppManager.get_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ryu.base.app_manager.AppManager
的用法示例。
在下文中一共展示了AppManager.get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [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
# 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()
示例2: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [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.get_instance()
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()
示例3: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
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()
示例4: __init__
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def __init__(self, chassis_name):
self.next_network_id = 0
self.db_store = db_store.DbStore()
self.chassis_name = chassis_name
self.ip = cfg.CONF.df.local_ip
self.tunnel_type = cfg.CONF.df.tunnel_type
self.sync_finished = False
nb_driver_class = importutils.import_class(cfg.CONF.df.nb_db_class)
self.nb_api = api_nb.NbApi(
nb_driver_class(),
use_pubsub=cfg.CONF.df.enable_df_pub_sub)
self.vswitch_api = ovsdb_vswitch_impl.OvsdbSwitchApi(
self.ip, self.nb_api)
kwargs = dict(
nb_api=self.nb_api,
vswitch_api=self.vswitch_api,
db_store=self.db_store
)
app_mgr = AppManager.get_instance()
self.open_flow_app = app_mgr.instantiate(RyuDFAdapter, **kwargs)
self.topology = None
self.enable_selective_topo_dist = \
cfg.CONF.df.enable_selective_topology_distribution
self.integration_bridge = cfg.CONF.df.integration_bridge
示例5: __init__
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def __init__(self, *args, **kwargs):
super(Loader, self).__init__(*args, **kwargs)
self.feature_events = []
self.table_id = 0
self.ryu_mgr = AppManager.get_instance()
self.install(OFPHandler)
self.install(SwitchListen(lambda ev: self.switch_features_handler(ev)))
self.start_listening()
示例6: initialize
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def initialize(self):
app_mgr = AppManager.get_instance()
LOG.debug(("RYU openflow stack, DragonFlow OpenFlow Controller"))
l3app_kwargs = dict(
idle_timeout=self.cfg.CONF.subnet_flows_idle_timeout,
hard_timeout=self.cfg.CONF.subnet_flows_hard_timeout
)
self.open_flow_hand = app_mgr.instantiate(OFPHandler, None, None)
self.l3_app = app_mgr.instantiate(L3ReactiveApp, None, **l3app_kwargs)
示例7: __init__
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def __init__(self, *args, **kwargs):
super(DynamicLoader, self).__init__(*args, **kwargs)
self.ryu_mgr = AppManager.get_instance()
self.available_app = []
self.init_apps()
wsgi = self.create_wsgi_app('0.0.0.0', 5566)
self.mapper = wsgi.mapper
wsgi.registory['DLController'] = self
self.init_mapper()
示例8: run
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def run(self):
self.nb_api = ovsdb_nb_impl.OvsdbNbApi(self.remote_db_ip)
#self.nb_api = etcd_nb_impl.EtcdNbApi()
self.nb_api.initialize()
self.vswitch_api = ovsdb_vswitch_impl.OvsdbSwitchApi(self.ip)
self.vswitch_api.initialize()
app_mgr = AppManager.get_instance()
self.open_flow_app = app_mgr.instantiate(OFPHandler, None, None)
self.open_flow_app.start()
self.l2_app = app_mgr.instantiate(L2App, None, None)
self.l2_app.start()
self.db_sync_loop()
示例9: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
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()
示例10: __init__
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def __init__(self, chassis_name):
self.next_network_id = 0
self.db_store = db_store.DbStore()
self.nb_api = None
self.vswitch_api = None
self.chassis_name = chassis_name
self.ip = cfg.CONF.df.local_ip
self.tunnel_type = cfg.CONF.df.tunnel_type
self.sync_finished = False
kwargs = dict(
db_store=self.db_store
)
app_mgr = AppManager.get_instance()
self.open_flow_app = app_mgr.instantiate(RyuDFAdapter, **kwargs)
示例11: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
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()
示例12: load
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def load(self):
app_mgr = AppManager.get_instance()
self.open_flow_app = app_mgr.instantiate(OFPHandler, None, None)
self.open_flow_app.start()
for app in self.apps_list:
app_class_name = self.apps_location_prefix + "." + app
try:
app_class = importutils.import_class(app_class_name)
app = app_mgr.instantiate(app_class, None, **self.params)
app.start()
self.apps.append(app)
except ImportError as e:
LOG.exception(_LE("Error loading application by class, %s"), e)
raise ImportError(_("Application class not found."))
示例13: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
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()
示例14: run
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
def run(self):
sb_db_connection = ('tcp:%s:6640' % self.sb_db_ip)
self.ovsdb_sb = connection.Connection(sb_db_connection,
10,
'OVN_Southbound')
local_connection = ('tcp:%s:6640' % self.ip)
self.ovsdb_local = connection.Connection(local_connection,
10,
'Open_vSwitch')
self.ovsdb_sb.start()
self.ovsdb_local.start()
self.idl_sb = self.ovsdb_sb.idl
self.idl = self.ovsdb_local.idl
app_mgr = AppManager.get_instance()
self.open_flow_app = app_mgr.instantiate(OFPHandler, None, None)
self.open_flow_app.start()
self.l2_app = app_mgr.instantiate(L2App, None, None)
self.l2_app.start()
self.db_sync_loop()
示例15: main
# 需要导入模块: from ryu.base.app_manager import AppManager [as 别名]
# 或者: from ryu.base.app_manager.AppManager import get_instance [as 别名]
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()