Support comma separated minion list in TCP transport

This commit is contained in:
Dmitry Kuzmenko 2018-01-30 16:11:01 +03:00
parent 7c5fef13a9
commit f303a9b864
No known key found for this signature in database
GPG Key ID: 4C7CAD30C95651DA

View File

@ -1336,6 +1336,7 @@ class TCPPubServerChannel(salt.transport.server.PubServerChannel):
def __init__(self, opts): def __init__(self, opts):
self.opts = opts self.opts = opts
self.serial = salt.payload.Serial(self.opts) # TODO: in init? self.serial = salt.payload.Serial(self.opts) # TODO: in init?
self.ckminions = salt.utils.minions.CkMinions(opts)
self.io_loop = None self.io_loop = None
def __setstate__(self, state): def __setstate__(self, state):
@ -1440,6 +1441,16 @@ class TCPPubServerChannel(salt.transport.server.PubServerChannel):
# add some targeting stuff for lists only (for now) # add some targeting stuff for lists only (for now)
if load['tgt_type'] == 'list': if load['tgt_type'] == 'list':
int_payload['topic_lst'] = load['tgt'] if isinstance(load['tgt'], six.string_types):
# Fetch a list of minions that match
_res = self.ckminions.check_minions(load['tgt'],
tgt_type=load['tgt_type'])
match_ids = _res['minions']
log.debug("Publish Side Match: %s", match_ids)
# Send list of miions thru so zmq can target them
int_payload['topic_lst'] = match_ids
else:
int_payload['topic_lst'] = load['tgt']
# Send it over IPC! # Send it over IPC!
pub_sock.send(int_payload) pub_sock.send(int_payload)