本文整理汇总了Python中charmhelpers.core.host.service_start方法的典型用法代码示例。如果您正苦于以下问题:Python host.service_start方法的具体用法?Python host.service_start怎么用?Python host.service_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.core.host
的用法示例。
在下文中一共展示了host.service_start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_status
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_start [as 别名]
def update_status():
"""Use the update-status hook to check to see if we can restart the
manila-share service: (BUG#1706699). The bug appears to be a race-hazard
but it's proving very difficult to track it down.
This is a band-aid to enable the charm to get into a working state once all
of the interfaces have joined, and the bug has been hit; otherwise the
charm stays "stuck" with the service not running.
Note, there is no need to actually call update_status as one of the other
handlers will activate it.
"""
if not os_utils.is_unit_paused_set():
state, message = os_utils._ows_check_services_running(
services=['manila-share'],
ports=None)
if state == 'blocked':
# try to start the 'manila-share' service
ch_host.service_start('manila-share')
示例2: restart_on_change
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_start [as 别名]
def restart_on_change(self):
"""Restart the services in the self.restart_map{} attribute if any of
the files identified by the keys changes for the wrapped call.
This function is a @decorator that checks if the wrapped function
changes any of the files identified by the keys in the
self.restart_map{} and, if they change, restarts the services in the
corresponding list.
"""
checksums = {path: ch_host.path_hash(path)
for path in self.full_restart_map.keys()}
yield
restarts = []
for path in self.full_restart_map:
if ch_host.path_hash(path) != checksums[path]:
restarts += self.full_restart_map[path]
services_list = list(collections.OrderedDict.fromkeys(restarts).keys())
for service_name in services_list:
ch_host.service_stop(service_name)
for service_name in services_list:
ch_host.service_start(service_name)
示例3: service_restart
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_start [as 别名]
def service_restart(service_name):
"""
Wrapper around host.service_restart to prevent spurious "unknown service"
messages in the logs.
"""
if host.service_available(service_name):
if host.service_running(service_name):
host.service_restart(service_name)
else:
host.service_start(service_name)
# Convenience aliases
示例4: restart_prometheus
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_start [as 别名]
def restart_prometheus():
if not host.service_running(SVCNAME):
hookenv.log('Starting {}...'.format(SVCNAME))
host.service_start(SVCNAME)
else:
hookenv.log('Restarting {}, config file changed...'.format(SVCNAME))
host.service_restart(SVCNAME)
hookenv.status_set('active', 'Ready')
set_state('prometheus.started')
remove_state('prometheus.do-restart')
# Relations