本文整理汇总了Python中juju.state.service.ServiceStateManager.remove_service_state方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceStateManager.remove_service_state方法的具体用法?Python ServiceStateManager.remove_service_state怎么用?Python ServiceStateManager.remove_service_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类juju.state.service.ServiceStateManager
的用法示例。
在下文中一共展示了ServiceStateManager.remove_service_state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: destroy_service
# 需要导入模块: from juju.state.service import ServiceStateManager [as 别名]
# 或者: from juju.state.service.ServiceStateManager import remove_service_state [as 别名]
def destroy_service(config, environment, verbose, log, service_name):
provider = environment.get_machine_provider()
client = yield provider.connect()
service_manager = ServiceStateManager(client)
service_state = yield service_manager.get_service_state(service_name)
yield service_manager.remove_service_state(service_state)
log.info("Service %r destroyed.", service_state.service_name)
示例2: destroy_service
# 需要导入模块: from juju.state.service import ServiceStateManager [as 别名]
# 或者: from juju.state.service.ServiceStateManager import remove_service_state [as 别名]
def destroy_service(config, environment, verbose, log, service_name):
provider = environment.get_machine_provider()
client = yield provider.connect()
service_manager = ServiceStateManager(client)
service_state = yield service_manager.get_service_state(service_name)
if (yield service_state.is_subordinate()):
# We can destroy the service if does not have relations.
# That implies that principals have already been torn
# down (or were never added).
relation_manager = RelationStateManager(client)
relations = yield relation_manager.get_relations_for_service(
service_state)
if relations:
principal_service = None
# if we have a container we can destroy the subordinate
# (revisit in the future)
for relation in relations:
if relation.relation_scope != "container":
continue
services = yield relation.get_service_states()
remote_service = [s for s in services if s.service_name !=
service_state.service_name][0]
if not (yield remote_service.is_subordinate()):
principal_service = remote_service
break
if principal_service:
raise UnsupportedSubordinateServiceRemoval(
service_state.service_name,
principal_service.service_name)
yield service_manager.remove_service_state(service_state)
log.info("Service %r destroyed.", service_state.service_name)