Skip to content

Commit

Permalink
simplify stdin use of stdin in at.present state
Browse files Browse the repository at this point in the history
Corollary to saltstack#28187.
  • Loading branch information
jfindlay committed Nov 11, 2015
1 parent decc31a commit 987d1fe
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions salt/states/at.py
Expand Up @@ -66,26 +66,21 @@ def present(name, timespec, tag=None, user=None, job=None):
timespec)
return ret

if __grains__['os_family'] == 'RedHat':
echo_cmd = 'echo -e'
else:
echo_cmd = 'echo'

if tag:
cmd = '{0} "### SALT: {4}\n{1}" | {2} {3}'.format(echo_cmd,
job, binary, timespec, tag)
stdin = '### SALT: {0}\n{1}'.format(tag, job)
else:
cmd = '{0} "{1}" | {2} {3}'.format(echo_cmd, name, binary, timespec)
stdin = name
cmd = '{0} {1}'.format(binary, timespec)

if user:
luser = __salt__['user.info'](user)
if not luser:
ret['comment'] = 'User: {0} is not exists'.format(user)
ret['result'] = False
return ret
ret['comment'] = __salt__['cmd.run']('{0}'.format(cmd), runas=user, python_shell=True)
ret['comment'] = __salt__['cmd.run'](cmd, stdin=stdin, runas=user)
else:
ret['comment'] = __salt__['cmd.run']('{0}'.format(cmd), python_shell=True)
ret['comment'] = __salt__['cmd.run'](cmd, stdin=stdin)

return ret

Expand Down

0 comments on commit 987d1fe

Please sign in to comment.