mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
move to systemd utils file code
This commit is contained in:
parent
8fd39ef646
commit
15b4ed1ca6
@ -6,36 +6,21 @@ import os
|
||||
import shutil
|
||||
# Import Salt libs
|
||||
import salt.defaults.exitcodes
|
||||
import salt.utils.systemd
|
||||
|
||||
__virtualname__ = 'nspawn'
|
||||
WANT = '/etc/systemd/system/multi-user.target.wants/systemd-nspawn@{0}.service'
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only work on systems that have been booted with systemd
|
||||
'''
|
||||
if __grains__['kernel'] == 'Linux' and _sd_booted(__context__):
|
||||
if __grains__['kernel'] == 'Linux' and salt.utils.systemd.booted(__context__):
|
||||
return __virtualname__
|
||||
return False
|
||||
|
||||
|
||||
def _sd_booted(context):
|
||||
'''
|
||||
Return True if the system was booted with systemd, False otherwise.
|
||||
'''
|
||||
# We can cache this for as long as the minion runs.
|
||||
if "systemd.sd_booted" not in context:
|
||||
try:
|
||||
# This check does the same as sd_booted() from libsystemd-daemon:
|
||||
# http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
||||
if os.stat('/run/systemd/system'):
|
||||
context['systemd.sd_booted'] = True
|
||||
except OSError:
|
||||
context['systemd.sd_booted'] = False
|
||||
|
||||
return context['systemd.sd_booted']
|
||||
|
||||
|
||||
def _arch_bootstrap(name, **kwargs):
|
||||
'''
|
||||
Bootstrap an Arch Linux container
|
||||
|
Loading…
Reference in New Issue
Block a user