updated runners
This commit is contained in:
parent
4d6b8dd50d
commit
736d270364
@ -5,10 +5,12 @@ import subprocess
|
||||
import json
|
||||
import salt.modules.smtp
|
||||
|
||||
|
||||
'''
|
||||
For use with salt reactor
|
||||
For use with salt reactor
|
||||
'''
|
||||
|
||||
|
||||
def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server):
|
||||
data = eval(data_str)
|
||||
error = False
|
||||
@ -30,10 +32,10 @@ def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server):
|
||||
sys.exit()
|
||||
|
||||
if error or changes:
|
||||
_js = subprocess.check_output(["salt-run", "--out=json",
|
||||
js = subprocess.check_output(["salt-run", "--out=json",
|
||||
"jobs.lookup_jid", data['jid']])
|
||||
body = "JobId is %s\n" % (data['jid'])
|
||||
outdata = json.loads(_js)
|
||||
body = f"JobId is data['jid']\n"
|
||||
outdata = json.loads(js)
|
||||
nodename = outdata.keys()[0]
|
||||
for i in outdata[nodename]:
|
||||
if not outdata[nodename][i]["result"]:
|
||||
@ -43,8 +45,10 @@ def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server):
|
||||
salt.modules.smtp.send_msg(recipient=toaddrs, message=data,
|
||||
subject=subject, sender=fromaddr,
|
||||
server=smtp_server, use_ssl=False)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def email_auth(fromaddr, toaddrs, subject, data_str, smtp_server):
|
||||
data = eval(data_str)
|
||||
salt.modules.smtp.send_msg(recipient=toaddrs, message=data,
|
||||
|
Loading…
Reference in New Issue
Block a user