Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tags for progress events and preload #7665

Merged
merged 5 commits into from Oct 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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