本文整理汇总了Python中charmhelpers.core.host.init_is_systemd方法的典型用法代码示例。如果您正苦于以下问题:Python host.init_is_systemd方法的具体用法?Python host.init_is_systemd怎么用?Python host.init_is_systemd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.core.host
的用法示例。
在下文中一共展示了host.init_is_systemd方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_ntpmon
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def install_ntpmon():
"""
Install package dependencies, source files, and startup configuration.
"""
hookenv.log('installing ntpmon dependencies')
apt_install(['python3-psutil'])
hookenv.log('installing ntpmon')
host.rsync('src/', ntpmon_dir)
if host.init_is_systemd():
hookenv.log('installing ntpmon systemd configuration')
host.rsync('src/' + service_name + '.systemd', systemd_config)
subprocess.call(['systemd', 'daemon-reload'])
else:
hookenv.log('installing ntpmon upstart configuration')
host.rsync('src/' + service_name + '.upstart', upstart_config)
set_state('ntpmon.installed')
remove_state('ntpmon.configured')
示例2: register_configs
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def register_configs():
"""
Register config files with their respective contexts.
Regstration of some configs may not be required depending on
existing of certain relations.
"""
# if called without anything installed (eg during install hook)
# just default to earliest supported release. configs dont get touched
# till post-install, anyway.
release = (get_os_codename_package('ceilometer-common', fatal=False) or
'grizzly')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
for conf in (CEILOMETER_CONF, HAPROXY_CONF):
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
if init_is_systemd():
configs.register(
CEILOMETER_API_SYSTEMD_CONF,
CONFIG_FILES[CEILOMETER_API_SYSTEMD_CONF]['hook_contexts']
)
if os.path.exists('/etc/apache2/conf-available'):
configs.register(HTTPS_APACHE_24_CONF,
CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts'])
else:
configs.register(HTTPS_APACHE_CONF,
CONFIG_FILES[HTTPS_APACHE_CONF]['hook_contexts'])
if enable_memcache(release=release):
configs.register(MEMCACHED_CONF, [context.MemcacheContext()])
if run_in_apache():
wsgi_script = "/usr/share/ceilometer/app.wsgi"
configs.register(WSGI_CEILOMETER_API_CONF,
[context.WSGIWorkerConfigContext(name="ceilometer",
script=wsgi_script),
CeilometerContext(),
HAProxyContext()])
return configs
示例3: reload_systemd
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def reload_systemd():
"""Reload systemd configuration on systemd based installs
"""
if init_is_systemd():
subprocess.check_call(['systemctl', 'daemon-reload'])
示例4: reload_and_restart
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def reload_and_restart():
if ch_host.init_is_systemd():
subprocess.check_call(['systemctl', 'daemon-reload'])
ch_host.service_restart('aodh-api')
示例5: test_init_is_systemd_upstart
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_init_is_systemd_upstart(self, path, lsb_release):
"""Upstart based init is correctly detected"""
lsb_release.return_value = {'DISTRIB_CODENAME': 'whatever'}
path.isdir.return_value = False
self.assertFalse(host.init_is_systemd())
path.isdir.assert_called_with('/run/systemd/system')
示例6: test_init_is_systemd_system
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_init_is_systemd_system(self, path, lsb_release):
"""Systemd based init is correctly detected"""
lsb_release.return_value = {'DISTRIB_CODENAME': 'whatever'}
path.isdir.return_value = True
self.assertTrue(host.init_is_systemd())
path.isdir.assert_called_with('/run/systemd/system')
示例7: test_init_is_systemd_trusty
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_init_is_systemd_trusty(self, path, lsb_release):
# Never returns true under trusty, even if the systemd
# packages have been installed. lp:1670944
lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
path.isdir.return_value = True
self.assertFalse(host.init_is_systemd())
self.assertFalse(path.isdir.called)
示例8: test_is_container_with_systemd_container
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_is_container_with_systemd_container(self,
call,
init_is_systemd,
mock_os):
init_is_systemd.return_value = True
call.return_value = 0
self.assertTrue(host.is_container())
call.assert_called_with(['systemd-detect-virt', '--container'])
示例9: test_is_container_with_systemd_non_container
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_is_container_with_systemd_non_container(self,
call,
init_is_systemd,
mock_os):
init_is_systemd.return_value = True
call.return_value = 1
self.assertFalse(host.is_container())
call.assert_called_with(['systemd-detect-virt', '--container'])
示例10: test_is_container_with_upstart_not_container
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def test_is_container_with_upstart_not_container(self,
call,
init_is_systemd,
mock_os):
init_is_systemd.return_value = False
mock_os.path.exists.return_value = False
self.assertFalse(host.is_container())
mock_os.path.exists.assert_called_with('/run/container_type')
示例11: add_init_service_checks
# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import init_is_systemd [as 别名]
def add_init_service_checks(nrpe, services, unit_name, immediate_check=True):
"""
Add checks for each service in list
:param NRPE nrpe: NRPE object to add check to
:param list services: List of services to check
:param str unit_name: Unit name to use in check description
:param bool immediate_check: For sysv init, run the service check immediately
"""
for svc in services:
# Don't add a check for these services from neutron-gateway
if svc in ['ext-port', 'os-charm-phy-nic-mtu']:
next
upstart_init = '/etc/init/%s.conf' % svc
sysv_init = '/etc/init.d/%s' % svc
if host.init_is_systemd():
nrpe.add_check(
shortname=svc,
description='process check {%s}' % unit_name,
check_cmd='check_systemd.py %s' % svc
)
elif os.path.exists(upstart_init):
nrpe.add_check(
shortname=svc,
description='process check {%s}' % unit_name,
check_cmd='check_upstart_job %s' % svc
)
elif os.path.exists(sysv_init):
cronpath = '/etc/cron.d/nagios-service-check-%s' % svc
checkpath = '%s/service-check-%s.txt' % (nrpe.homedir, svc)
croncmd = (
'/usr/local/lib/nagios/plugins/check_exit_status.pl '
'-e -s /etc/init.d/%s status' % svc
)
cron_file = '*/5 * * * * root %s > %s\n' % (croncmd, checkpath)
f = open(cronpath, 'w')
f.write(cron_file)
f.close()
nrpe.add_check(
shortname=svc,
description='service check {%s}' % unit_name,
check_cmd='check_status_file.py -f %s' % checkpath,
)
# if /var/lib/nagios doesn't exist open(checkpath, 'w') will fail
# (LP: #1670223).
if immediate_check and os.path.isdir(nrpe.homedir):
f = open(checkpath, 'w')
subprocess.call(
croncmd.split(),
stdout=f,
stderr=subprocess.STDOUT
)
f.close()
os.chmod(checkpath, 0o644)