当前位置: 首页>>代码示例>>Python>>正文


Python host.service方法代码示例

本文整理汇总了Python中charmhelpers.core.host.service方法的典型用法代码示例。如果您正苦于以下问题:Python host.service方法的具体用法?Python host.service怎么用?Python host.service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charmhelpers.core.host的用法示例。


在下文中一共展示了host.service方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def write(self, nagios_context, hostname, nagios_servicegroups):
        nrpe_check_file = self._get_check_filename()
        with open(nrpe_check_file, 'w') as nrpe_check_config:
            nrpe_check_config.write("# check {}\n".format(self.shortname))
            if nagios_servicegroups:
                nrpe_check_config.write(
                    "# The following header was added automatically by juju\n")
                nrpe_check_config.write(
                    "# Modifying it will affect nagios monitoring and alerting\n")
                nrpe_check_config.write(
                    "# servicegroups: {}\n".format(nagios_servicegroups))
            nrpe_check_config.write("command[{}]={}\n".format(
                self.command, self.check_cmd))

        if not os.path.exists(NRPE.nagios_exportdir):
            log('Not writing service config as {} is not accessible'.format(
                NRPE.nagios_exportdir))
        else:
            self.write_service_config(nagios_context, hostname,
                                      nagios_servicegroups) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:22,代码来源:nrpe.py

示例2: test_pauses_a_running_upstart_service

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def test_pauses_a_running_upstart_service(self, service, systemd,
                                              service_running):
        """Pause on a running service will call service stop."""
        service_name = 'foo-service'
        service.side_effect = [True]
        systemd.return_value = False
        service_running.return_value = True
        tempdir = mkdtemp(prefix="test_pauses_an_upstart_service")
        conf_path = os.path.join(tempdir, "{}.conf".format(service_name))
        # Just needs to exist
        with open(conf_path, "w") as fh:
            fh.write("")
        self.addCleanup(rmtree, tempdir)
        self.assertTrue(host.service_pause(service_name, init_dir=tempdir))

        service.assert_called_with('stop', service_name)
        override_path = os.path.join(
            tempdir, "{}.override".format(service_name))
        with open(override_path, "r") as fh:
            override_contents = fh.read()
        self.assertEqual("manual\n", override_contents) 
开发者ID:juju,项目名称:charm-helpers,代码行数:23,代码来源:test_host.py

示例3: test_pauses_a_stopped_upstart_service

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def test_pauses_a_stopped_upstart_service(self, service, systemd,
                                              service_running):
        """Pause on a stopped service will not call service stop."""
        service_name = 'foo-service'
        service.side_effect = [True]
        systemd.return_value = False
        service_running.return_value = False
        tempdir = mkdtemp(prefix="test_pauses_an_upstart_service")
        conf_path = os.path.join(tempdir, "{}.conf".format(service_name))
        # Just needs to exist
        with open(conf_path, "w") as fh:
            fh.write("")
        self.addCleanup(rmtree, tempdir)
        self.assertTrue(host.service_pause(service_name, init_dir=tempdir))

        # Stop isn't called because service is already stopped
        self.assertRaises(
            AssertionError, service.assert_called_with, 'stop', service_name)
        override_path = os.path.join(
            tempdir, "{}.override".format(service_name))
        with open(override_path, "r") as fh:
            override_contents = fh.read()
        self.assertEqual("manual\n", override_contents) 
开发者ID:juju,项目名称:charm-helpers,代码行数:25,代码来源:test_host.py

示例4: test_pauses_a_stopped_sysv_service

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def test_pauses_a_stopped_sysv_service(self, service, check_call,
                                           systemd, service_running):
        """Pause does not call service stop on a stopped sysv service."""
        service_name = 'foo-service'
        service.side_effect = [True]
        systemd.return_value = False
        service_running.return_value = False
        tempdir = mkdtemp(prefix="test_pauses_a_sysv_service")
        sysv_path = os.path.join(tempdir, service_name)
        # Just needs to exist
        with open(sysv_path, "w") as fh:
            fh.write("")
        self.addCleanup(rmtree, tempdir)
        self.assertTrue(host.service_pause(
            service_name, init_dir=tempdir, initd_dir=tempdir))

        # Stop isn't called because service is already stopped
        self.assertRaises(
            AssertionError, service.assert_called_with, 'stop', service_name)
        check_call.assert_called_with(["update-rc.d", service_name, "disable"]) 
开发者ID:juju,项目名称:charm-helpers,代码行数:22,代码来源:test_host.py

示例5: __init__

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def __init__(self, shortname, description, check_cmd):
        super(Check, self).__init__()
        # XXX: could be better to calculate this from the service name
        if not re.match(self.shortname_re, shortname):
            raise CheckException("shortname must match {}".format(
                Check.shortname_re))
        self.shortname = shortname
        self.command = "check_{}".format(shortname)
        # Note: a set of invalid characters is defined by the
        # Nagios server config
        # The default is: illegal_object_name_chars=`~!$%^&*"|'<>?,()=
        self.description = description
        self.check_cmd = self._locate_cmd(check_cmd) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:15,代码来源:nrpe.py

示例6: add_haproxy_checks

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def add_haproxy_checks(nrpe, unit_name):
    """
    Add checks for each service in list

    :param NRPE nrpe: NRPE object to add check to
    :param str unit_name: Unit name to use in check description
    """
    nrpe.add_check(
        shortname='haproxy_servers',
        description='Check HAProxy {%s}' % unit_name,
        check_cmd='check_haproxy.sh')
    nrpe.add_check(
        shortname='haproxy_queue',
        description='Check HAProxy queue depth {%s}' % unit_name,
        check_cmd='check_haproxy_queue_depth.sh') 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:17,代码来源:nrpe.py

示例7: service

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service [as 别名]
def service(subparser):
    subparser.add_argument("action", help="The action to perform (start, stop, etc...)")
    subparser.add_argument("service_name", help="Name of the service to control")
    return host.service 
开发者ID:openstack,项目名称:charm-heat,代码行数:6,代码来源:host.py


注:本文中的charmhelpers.core.host.service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。