本文整理汇总了Python中juju.state.service.ServiceStateManager.get_relation_endpoints方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceStateManager.get_relation_endpoints方法的具体用法?Python ServiceStateManager.get_relation_endpoints怎么用?Python ServiceStateManager.get_relation_endpoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类juju.state.service.ServiceStateManager
的用法示例。
在下文中一共展示了ServiceStateManager.get_relation_endpoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate_hooks
# 需要导入模块: from juju.state.service import ServiceStateManager [as 别名]
# 或者: from juju.state.service.ServiceStateManager import get_relation_endpoints [as 别名]
def validate_hooks(client, unit_state, hook_names):
# Assemble a list of valid hooks for the charm.
valid_hooks = ["start", "stop", "install", "config-changed"]
service_manager = ServiceStateManager(client)
endpoints = yield service_manager.get_relation_endpoints(
unit_state.service_name)
endpoint_names = [ep.relation_name for ep in endpoints]
for endpoint_name in endpoint_names:
valid_hooks.extend([
endpoint_name + "-relation-joined",
endpoint_name + "-relation-changed",
endpoint_name + "-relation-departed",
endpoint_name + "-relation-broken",
])
# Verify the debug names.
for hook_name in hook_names:
if hook_name in valid_hooks:
continue
break
else:
returnValue(True)
# We dereference to the charm to give a fully qualified error
# message. I wish this was a little easier to dereference, the
# service_manager.get_relation_endpoints effectively does this
# already.
service_manager = ServiceStateManager(client)
service_state = yield service_manager.get_service_state(
unit_state.service_name)
charm_id = yield service_state.get_charm_id()
charm_manager = CharmStateManager(client)
charm = yield charm_manager.get_charm_state(charm_id)
raise InvalidCharmHook(charm.id, hook_name)