當前位置: 首頁>>代碼示例>>Python>>正文


Python host.service_start方法代碼示例

本文整理匯總了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') 
開發者ID:openstack,項目名稱:charm-manila,代碼行數:21,代碼來源:manila_handlers.py

示例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) 
開發者ID:openstack,項目名稱:charms.openstack,代碼行數:23,代碼來源:core.py

示例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 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:15,代碼來源:base.py

示例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 
開發者ID:tasdomas,項目名稱:juju-charm-prometheus,代碼行數:15,代碼來源:prometheus.py


注:本文中的charmhelpers.core.host.service_start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。