Add runner for sending error results over XMPP
This commit is contained in:
parent
b85f96a8f4
commit
29d1ab59f9
29
_runners/handle_minion_data.py
Normal file
29
_runners/handle_minion_data.py
Normal file
@ -0,0 +1,29 @@
|
||||
import subprocess
|
||||
|
||||
import salt.modules.xmpp
|
||||
|
||||
|
||||
def xmpp_errors(recipient, data):
|
||||
error = False
|
||||
changes = False
|
||||
|
||||
with open('/tmp/whatever', 'w') as f:
|
||||
f.write(repr(data['return']))
|
||||
f.write(str(type(data['return'])))
|
||||
|
||||
if isinstance(data['return'], dict):
|
||||
error = not all(result['result'] for result in data['return'].values())
|
||||
changes = any(result['changes'] for result in data['return'].values())
|
||||
else:
|
||||
error = not data['success']
|
||||
|
||||
if error or changes:
|
||||
msg = subprocess.check_output(
|
||||
["salt-run", "jobs.lookup_jid", data['jid']])
|
||||
|
||||
salt.modules.xmpp.send_msg(
|
||||
recipient, msg.decode(),
|
||||
jid='salt@adamgoldsmith.name',
|
||||
password="aewae2goh1Tee2Imahhe8iceika5aoph")
|
||||
|
||||
return error
|
Loading…
Reference in New Issue
Block a user