本文整理汇总了Python中crossbar.router.router.RouterFactory.add_role方法的典型用法代码示例。如果您正苦于以下问题:Python RouterFactory.add_role方法的具体用法?Python RouterFactory.add_role怎么用?Python RouterFactory.add_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crossbar.router.router.RouterFactory
的用法示例。
在下文中一共展示了RouterFactory.add_role方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RouterWorkerSession
# 需要导入模块: from crossbar.router.router import RouterFactory [as 别名]
# 或者: from crossbar.router.router.RouterFactory import add_role [as 别名]
#.........这里部分代码省略.........
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
return self.realms[id].roles.values()
def start_router_realm_role(self, id, role_id, config, details=None):
"""
Adds a role to a realm.
:param id: The ID of the realm the role should be added to.
:type id: str
:param role_id: The ID of the role to add.
:type role_id: str
:param config: The role configuration.
:type config: dict
"""
self.log.debug(
"{}.add_router_realm_role".format(self.__class__.__name__), id=id, role_id=role_id, config=config
)
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id in self.realms[id].roles:
raise ApplicationError(
u"crossbar.error.already_exists",
"A role with ID '{}' already exists in realm with ID '{}'".format(role_id, id),
)
self.realms[id].roles[role_id] = RouterRealmRole(role_id, config)
realm = self.realms[id].config["name"]
self._router_factory.add_role(realm, config)
def stop_router_realm_role(self, id, role_id, details=None):
"""
Drop a role from a realm.
:param id: The ID of the realm to drop a role from.
:type id: str
:param role_id: The ID of the role within the realm to drop.
:type role_id: str
"""
self.log.debug("{}.drop_router_realm_role".format(self.__class__.__name__), id=id, role_id=role_id)
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id not in self.realms[id].roles:
raise ApplicationError(
u"crossbar.error.no_such_object", "No role with ID '{}' in realm with ID '{}'".format(role_id, id)
)
del self.realms[id].roles[role_id]
def get_router_components(self, details=None):
"""
List application components currently running (embedded) in this router.
"""
self.log.debug("{}.get_router_components".format(self.__class__.__name__))
res = []
for component in sorted(self.components.values(), key=lambda c: c.created):
res.append({"id": component.id, "created": utcstr(component.created), "config": component.config})
return res
示例2: RouterWorkerSession
# 需要导入模块: from crossbar.router.router import RouterFactory [as 别名]
# 或者: from crossbar.router.router.RouterFactory import add_role [as 别名]
#.........这里部分代码省略.........
:returns: A list of roles.
:rtype: list of dicts
"""
self.log.debug("{}.get_router_realm_roles".format(self.__class__.__name__), id=id)
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
return self.realms[id].roles.values()
def start_router_realm_role(self, id, role_id, config, details=None):
"""
Start a role on a realm running on this router worker.
:param id: The ID of the realm the role should be started on.
:type id: str
:param role_id: The ID of the role to start under.
:type role_id: str
:param config: The role configuration.
:type config: dict
"""
self.log.debug("{}.start_router_realm_role".format(self.__class__.__name__),
id=id, role_id=role_id, config=config)
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id in self.realms[id].roles:
raise ApplicationError(u"crossbar.error.already_exists", "A role with ID '{}' already exists in realm with ID '{}'".format(role_id, id))
self.realms[id].roles[role_id] = RouterRealmRole(role_id, config)
realm = self.realms[id].config['name']
self._router_factory.add_role(realm, config)
def stop_router_realm_role(self, id, role_id, details=None):
"""
Stop a role currently running on a realm running on this router worker.
:param id: The ID of the realm of the role to be stopped.
:type id: str
:param role_id: The ID of the role to be stopped.
:type role_id: str
"""
self.log.debug("{}.stop_router_realm_role".format(self.__class__.__name__),
id=id, role_id=role_id)
if id not in self.realms:
raise ApplicationError(u"crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id not in self.realms[id].roles:
raise ApplicationError(u"crossbar.error.no_such_object", "No role with ID '{}' in realm with ID '{}'".format(role_id, id))
del self.realms[id].roles[role_id]
def get_router_realm_uplinks(self, id, details=None):
"""
Get uplinks currently running on a realm running on this router worker.
:param id: The ID of the router realm to list uplinks for.
:type id: str
:returns: A list of uplinks.
:rtype: list of dicts
"""
self.log.debug("{}.get_router_realm_uplinks".format(self.__class__.__name__))
示例3: RouterWorkerSession
# 需要导入模块: from crossbar.router.router import RouterFactory [as 别名]
# 或者: from crossbar.router.router.RouterFactory import add_role [as 别名]
#.........这里部分代码省略.........
:returns: list -- A list of roles.
"""
if self.debug:
log.msg("{}.get_router_realm_roles".format(self.__class__.__name__), id)
if id not in self.realms:
raise ApplicationError("crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
return self.realms[id].roles.values()
def start_router_realm_role(self, id, role_id, config, details=None):
"""
Adds a role to a realm.
:param id: The ID of the realm the role should be added to.
:type id: str
:param role_id: The ID of the role to add.
:type role_id: str
:param config: The role configuration.
:type config: dict
"""
if self.debug:
log.msg("{}.add_router_realm_role".format(self.__class__.__name__), id, role_id, config)
if id not in self.realms:
raise ApplicationError("crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id in self.realms[id].roles:
raise ApplicationError("crossbar.error.already_exists", "A role with ID '{}' already exists in realm with ID '{}'".format(role_id, id))
self.realms[id].roles[role_id] = RouterRealmRole(role_id, config)
realm = self.realms[id].config['name']
self._router_factory.add_role(realm, config)
def stop_router_realm_role(self, id, role_id, details=None):
"""
Drop a role from a realm.
:param id: The ID of the realm to drop a role from.
:type id: str
:param role_id: The ID of the role within the realm to drop.
:type role_id: str
"""
if self.debug:
log.msg("{}.drop_router_realm_role".format(self.__class__.__name__), id, role_id)
if id not in self.realms:
raise ApplicationError("crossbar.error.no_such_object", "No realm with ID '{}'".format(id))
if role_id not in self.realms[id].roles:
raise ApplicationError("crossbar.error.no_such_object", "No role with ID '{}' in realm with ID '{}'".format(role_id, id))
del self.realms[id].roles[role_id]
def get_router_components(self, details=None):
"""
List application components currently running (embedded) in this router.
"""
if self.debug:
log.msg("{}.get_router_components".format(self.__class__.__name__))
res = []
for component in sorted(self._components.values(), key=lambda c: c.created):
res.append({
'id': component.id,