Skip to content

Commit

Permalink
Merge pull request #7665 from SmithSamuelM/sam_20131001
Browse files Browse the repository at this point in the history
Fixed tags for progress events and preload
  • Loading branch information
thatch45 committed Oct 8, 2013
2 parents d9aa67a + eefbbc1 commit d90491d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
5 changes: 3 additions & 2 deletions salt/minion.py
Expand Up @@ -702,8 +702,9 @@ def _thread_return(cls, minion_instance, opts, data):
if not iret:
iret = []
iret.append(single)
tag = tagify([data['jid'], 'ret', opts['id'], ind])
minion_instance._fire_master({'return': single}, tag)
tag = tagify([data['jid'], 'prog', opts['id'], str(ind)], 'job')
event_data = {'return': single}
minion_instance._fire_master(event_data, tag)
ind += 1
ret['return'] = iret
else:
Expand Down
11 changes: 8 additions & 3 deletions salt/modules/event.py
Expand Up @@ -10,7 +10,7 @@
import salt.payload


def fire_master(data, tag):
def fire_master(data, tag, preload=None):
'''
Fire an event off up to the master server
Expand All @@ -20,10 +20,15 @@ def fire_master(data, tag):
salt '*' event.fire_master 'stuff to be in the event' 'tag'
'''
load = {'id': __opts__['id'],
load = {}
if preload:
load.update(preload)

load.update({'id': __opts__['id'],
'tag': tag,
'data': data,
'cmd': '_minion_event'}
'cmd': '_minion_event'})

auth = salt.crypt.SAuth(__opts__)
sreq = salt.payload.SREQ(__opts__['master_uri'])
try:
Expand Down
5 changes: 3 additions & 2 deletions salt/state.py
Expand Up @@ -1388,9 +1388,10 @@ def event(self, chunk_ret):
'''
if not self.opts.get('local') and self.opts.get('state_events', True):
tag = salt.utils.event.tagify(
[self.jid, str(chunk_ret['__run_num__'])]
[self.jid, 'prog', self.opts['id'], str(chunk_ret['__run_num__'])], 'job'
)
self.functions['event.fire_master'](chunk_ret, tag)
preload = {'jid': self.jid}
self.functions['event.fire_master'](chunk_ret, tag, preload=preload)

def call_chunk(self, low, running, chunks):
'''
Expand Down
15 changes: 10 additions & 5 deletions salt/utils/event.py
Expand Up @@ -592,18 +592,23 @@ def __init__(self, opts, auth=None):
else:
self.auth = auth

def fire_master(self, data, tag):
def fire_master(self, data, tag, preload=None):
'''
Fire an event off on the master server
CLI Example::
salt '*' event.fire_master 'stuff to be in the event' 'tag'
'''
load = {'id': self.opts['id'],
'tag': tag,
'data': data,
'cmd': '_minion_event'}
load = {}
if preload:
load.update(preload)

load.update({'id': self.opts['id'],
'tag': tag,
'data': data,
'cmd': '_minion_event'})

sreq = salt.payload.SREQ(self.opts['master_uri'])
try:
sreq.send('aes', self.auth.crypticle.dumps(load))
Expand Down

0 comments on commit d90491d

Please sign in to comment.