mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
timezone module: handle timedatectl errors
This commit is contained in:
parent
9a0171089d
commit
ef26f067b2
1 changed files with 7 additions and 2 deletions
|
@ -100,8 +100,13 @@ def get_zone():
|
|||
'''
|
||||
cmd = ''
|
||||
if salt.utils.which('timedatectl'):
|
||||
out = __salt__['cmd.run'](['timedatectl'], python_shell=False)
|
||||
for line in (x.strip() for x in out.splitlines()):
|
||||
ret = __salt__['cmd.run_all'](['timedatectl'], python_shell=False)
|
||||
|
||||
if ret['retcode'] > 0:
|
||||
msg = 'timedatectl failed: {}'.format(ret['stderr'])
|
||||
raise CommandExecutionError(msg)
|
||||
|
||||
for line in (x.strip() for x in ret['stdout'].splitlines()):
|
||||
try:
|
||||
return re.match(r'Time ?zone:\s+(\S+)', line).group(1)
|
||||
except AttributeError:
|
||||
|
|
Loading…
Add table
Reference in a new issue