mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #36538 from clinta/daemon-reload
daemon-reload on call to service.avaliable
This commit is contained in:
commit
0c2bd4b66b
@ -71,6 +71,23 @@ def _canonical_unit_name(name):
|
|||||||
return '%s.service' % name
|
return '%s.service' % name
|
||||||
|
|
||||||
|
|
||||||
|
def _check_available(name):
|
||||||
|
'''
|
||||||
|
Returns boolean telling whether or not the named service is available
|
||||||
|
'''
|
||||||
|
out = _systemctl_status(name).lower()
|
||||||
|
for line in salt.utils.itertools.split(out, '\n'):
|
||||||
|
match = re.match(r'\s+loaded:\s+(\S+)', line)
|
||||||
|
if match:
|
||||||
|
ret = match.group(1) != 'not-found'
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise CommandExecutionError(
|
||||||
|
'Failed to get information on unit \'%s\'' % name
|
||||||
|
)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def _check_for_unit_changes(name):
|
def _check_for_unit_changes(name):
|
||||||
'''
|
'''
|
||||||
Check for modified/updated unit files, and run a daemon-reload if any are
|
Check for modified/updated unit files, and run a daemon-reload if any are
|
||||||
@ -298,7 +315,7 @@ def _untracked_custom_unit_found(name):
|
|||||||
'''
|
'''
|
||||||
unit_path = os.path.join('/etc/systemd/system',
|
unit_path = os.path.join('/etc/systemd/system',
|
||||||
_canonical_unit_name(name))
|
_canonical_unit_name(name))
|
||||||
return os.access(unit_path, os.R_OK) and not available(name)
|
return os.access(unit_path, os.R_OK) and not _check_available(name)
|
||||||
|
|
||||||
|
|
||||||
def _unit_file_changed(name):
|
def _unit_file_changed(name):
|
||||||
@ -481,17 +498,8 @@ def available(name):
|
|||||||
|
|
||||||
salt '*' service.available sshd
|
salt '*' service.available sshd
|
||||||
'''
|
'''
|
||||||
out = _systemctl_status(name).lower()
|
_check_for_unit_changes(name)
|
||||||
for line in salt.utils.itertools.split(out, '\n'):
|
return _check_available(name)
|
||||||
match = re.match(r'\s+loaded:\s+(\S+)', line)
|
|
||||||
if match:
|
|
||||||
ret = match.group(1) != 'not-found'
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise CommandExecutionError(
|
|
||||||
'Failed to get information on unit \'%s\'' % name
|
|
||||||
)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
def missing(name):
|
def missing(name):
|
||||||
|
Loading…
Reference in New Issue
Block a user