# Pastebin ZmkC0MoP def _query(tgt=None, tgt_type='glob', kwargs={}): if tgt is not None: return __salt__['mine.get'](tgt, 'network.ip_addrs', tgt_type) else: # FIXME: encoding return __salt__['mine.get']( ' and '.join('G@{}:{}'.format(k, v) for k, v in kwargs.items()), 'network.ip_addrs', 'compound' ) def get_server(tgt=None, tgt_type='glob', **kwargs): """ Gets the IP address of the minion matching the query. """ servers = _query(tgt, tgt_type, kwargs) try: addrs = next(iter(servers.values())) return addrs[0] except StopIteration: return def get_cluster(tgt=None, tgt_type='glob', **kwargs): """ Gets the IP addresses of all the minions matching the query """ servers = _query(tgt, tgt_type, kwargs) return [addrs[0] for addrs in servers.values()]