本文整理汇总了Python中charmhelpers.core.host.service_pause方法的典型用法代码示例。如果您正苦于以下问题:Python host.service_pause方法的具体用法?Python host.service_pause怎么用?Python host.service_pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.core.host
的用法示例。
在下文中一共展示了host.service_pause方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pauses_a_running_upstart_service
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [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)
示例2: test_pauses_a_stopped_upstart_service
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [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)
示例3: test_pauses_a_running_sysv_service
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def test_pauses_a_running_sysv_service(self, service, check_call,
systemd, service_running):
"""Pause calls service stop on a running sysv service."""
service_name = 'foo-service'
service.side_effect = [True]
systemd.return_value = False
service_running.return_value = True
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))
service.assert_called_with('stop', service_name)
check_call.assert_called_with(["update-rc.d", service_name, "disable"])
示例4: test_pauses_a_stopped_sysv_service
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [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"])
示例5: pause
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def pause(args):
"""Pause all the swift services.
@raises Exception if any services fail to stop
"""
for service in args.services:
stopped = service_pause(service)
if not stopped:
raise Exception("{} didn't stop cleanly.".format(service))
set_unit_paused()
assess_status(CONFIGS, args.services)
示例6: disable_services
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def disable_services(self):
'''Disable all services related to gnocchi'''
for svc in self.services:
host.service_pause(svc)
示例7: install
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def install(self):
super(GnocchiCharm, self).install()
# NOTE(jamespage): always pause gnocchi-api service as we force
# execution with Apache2+mod_wsgi
host.service_pause('gnocchi-api')
示例8: pause
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def pause(args):
"""Pause all the swift services.
@raises Exception if any services fail to stop
"""
for service in args.services:
stopped = service_pause(service)
if not stopped:
raise Exception("{} didn't stop cleanly.".format(service))
with HookData()():
kv().set('unit-paused', True)
set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
charm_func=assess_status)
示例9: start_ntpmon
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def start_ntpmon():
"""
Start the ntpmon daemon process.
If ntp is not installed, do nothing.
"""
if os.path.exists(ntp_conf):
hookenv.log(ntp_conf + ' present; enabling and starting ntpmon')
host.service_resume(service_name)
else:
hookenv.log(ntp_conf + ' not present; disabling ntpmon')
host.service_pause(service_name)
set_state('ntpmon.started')
示例10: test_pauses_a_running_systemd_unit
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import service_pause [as 别名]
def test_pauses_a_running_systemd_unit(self, service, systemd,
service_running):
"""Pause on a running systemd unit will be stopped and disabled."""
service_name = 'foo-service'
service_running.return_value = True
systemd.return_value = True
self.assertTrue(host.service_pause(service_name))
service.assert_has_calls([
call('stop', service_name),
call('disable', service_name),
call('mask', service_name)])