.. versionadded:: 2017.7.0

    Return Elasticsearch information.

    CLI example::

        salt myminion elasticsearch.info
        salt myminion elasticsearch.info profile=elasticsearch-extra
4282
def info(hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)

    try:
        return es.info()
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot retrieve server information, server returned code {0} with message {1}".format(e.status_code, e.error))
99178
def get_extra_info(self, name, default=None):
        
        if name == 'related_address':
            return self.__inner_protocol.transport.get_extra_info('sockname')
        elif name == 'sockname':
            return self.__relayed_address
        return default
910748
def type_info(type, elem)
    scimfo = {
        user: {
            path: '/Users',
            name_attr: 'userName',
            origin_attr: 'origin'
        },
        group: {
            path: '/Groups',
            name_attr: 'displayName',
            origin_attr: 'zoneid'
        },
        client: {
            path: '/oauth/clients',
            name_attr: 'client_id'
        },
        user_id: {
            path: '/ids/Users',
            name_attr: 'userName',
            origin_attr: 'origin',
        },
        group_mapping: {
            path: '/Groups/External',
            name_attr: 'externalGroup',
            origin_attr: 'origin'
        }
    }

    type_info = scimfo[type]

    unless type_info
      raise ArgumentError, "scim resource type must be one of #{scimfo.keys.inspect}"
    end

    value = type_info[elem]

    unless value
      raise ArgumentError, "scim schema element must be one of #{type_info.keys.inspect}"
    end

    value
  end
264586
def dependency_information(include_salt_cloud=False):
    '''
    
    '''
    libs = [
        ('Python', None, sys.version.rsplit('\n')[0].strip()),
        ('Jinja2', 'jinja2', '__version__'),
        ('M2Crypto', 'M2Crypto', 'version'),
        ('msgpack-python', 'msgpack', 'version'),
        ('msgpack-pure', 'msgpack_pure', 'version'),
        ('pycrypto', 'Crypto', '__version__'),
        ('pycryptodome', 'Cryptodome', 'version_info'),
        ('PyYAML', 'yaml', '__version__'),
        ('PyZMQ', 'zmq', '__version__'),
        ('ZMQ', 'zmq', 'zmq_version'),
        ('Mako', 'mako', '__version__'),
        ('Tornado', 'tornado', 'version'),
        ('timelib', 'timelib', 'version'),
        ('dateutil', 'dateutil', '__version__'),
        ('pygit2', 'pygit2', '__version__'),
        ('libgit2', 'pygit2', 'LIBGIT2_VERSION'),
        ('smmap', 'smmap', '__version__'),
        ('cffi', 'cffi', '__version__'),
        ('pycparser', 'pycparser', '__version__'),
        ('gitdb', 'gitdb', '__version__'),
        ('gitpython', 'git', '__version__'),
        ('python-gnupg', 'gnupg', '__version__'),
        ('mysql-python', 'MySQLdb', '__version__'),
        ('cherrypy', 'cherrypy', '__version__'),
        ('docker-py', 'docker', '__version__'),
    ]

    if include_salt_cloud:
        libs.append(
            ('Apache Libcloud', 'libcloud', '__version__'),
        )

    for name, imp, attr in libs:
        if imp is None:
            yield name, attr
            continue
        try:
            imp = __import__(imp)
            version = getattr(imp, attr)
            if callable(version):
                version = version()
            if isinstance(version, (tuple, list)):
                version = '.'.join(map(str, version))
            yield name, version
        except Exception:
            yield name, None
16628
def info(name):
    '''
    
    '''
    if salt.utils.stringutils.contains_whitespace(name):
        raise SaltInvocationError('Group name cannot contain whitespace')
    try:
        # getgrnam seems to cache weirdly, so don't use it
        grinfo = next(iter(x for x in grp.getgrall() if x.gr_name == name))
    except StopIteration:
        return {}
    else:
        return _format_info(grinfo)
95707
def salt_extend(extension, name, description, salt_dir, merge):
    '''
    
    '''
    import salt.utils.extend
    salt.utils.extend.run(extension=extension,
                          name=name,
                          description=description,
                          salt_dir=salt_dir,
                          merge=merge)
211988
def get_ext_pillar_extra_minion_data(self, opts):
        '''
        
        '''
        def get_subconfig(opts_key):
            '''
            Returns a dict containing the opts key subtree, while maintaining
            the opts structure
            '''
            ret_dict = aux_dict = {}
            config_val = opts
            subkeys = opts_key.split(':')
            # Build an empty dict with the opts path
            for subkey in subkeys[:-1]:
                aux_dict[subkey] = {}
                aux_dict = aux_dict[subkey]
                if not config_val.get(subkey):
                    # The subkey is not in the config
                    return {}
                config_val = config_val[subkey]
            if subkeys[-1] not in config_val:
                return {}
            aux_dict[subkeys[-1]] = config_val[subkeys[-1]]
            return ret_dict

        extra_data = {}
        if 'pass_to_ext_pillars' in opts:
            if not isinstance(opts['pass_to_ext_pillars'], list):
                log.exception('\'pass_to_ext_pillars\' config is malformed.')
                raise SaltClientError('\'pass_to_ext_pillars\' config is '
                                      'malformed.')
            for key in opts['pass_to_ext_pillars']:
                salt.utils.dictupdate.update(extra_data,
                                             get_subconfig(key),
                                             recursive_update=True,
                                             merge_lists=True)
        log.trace('ext_pillar_extra_data = %s', extra_data)
        return extra_data
1084365
def index_get(index, hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)

    try:
        return es.indices.get(index=index)
    except elasticsearch.exceptions.NotFoundError:
        return None
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot retrieve index {0}, server returned code {1} with message {2}".format(index, e.status_code, e.error))
833145
def _external_pillar_data(self, pillar, val, key):
        '''
        
        '''
        ext = None
        args = salt.utils.args.get_function_argspec(self.ext_pillars[key]).args

        if isinstance(val, dict):
            if ('extra_minion_data' in args) and self.extra_minion_data:
                ext = self.ext_pillars[key](
                    self.minion_id, pillar,
                    extra_minion_data=self.extra_minion_data, **val)
            else:
                ext = self.ext_pillars[key](self.minion_id, pillar, **val)
        elif isinstance(val, list):
            if ('extra_minion_data' in args) and self.extra_minion_data:
                ext = self.ext_pillars[key](
                    self.minion_id, pillar, *val,
                    extra_minion_data=self.extra_minion_data)
            else:
                ext = self.ext_pillars[key](self.minion_id,
                                            pillar,
                                            *val)
        else:
            if ('extra_minion_data' in args) and self.extra_minion_data:
                ext = self.ext_pillars[key](
                    self.minion_id,
                    pillar,
                    val,
                    extra_minion_data=self.extra_minion_data)
            else:
                ext = self.ext_pillars[key](self.minion_id,
                                            pillar,
                                            val)
        return ext
548584
def get_info(cls):
        
        mod = try_import(cls.mod_name)
        if not mod:
            return None
        version = getattr(mod, '__version__', None) or getattr(mod, 'version',
                                                               None)
        return BackendInfo(version or 'deprecated', '')
365573
def get_index_by_alias(self, alias):
        
        try:
            info = self.es.indices.get_alias(name=alias)
            return next(iter(info.keys()))
        except elasticsearch.exceptions.NotFoundError:
            return alias
794808
def ext_pillar(minion_id,
               pillar,  # pylint: disable=W0613
               conf):
    '''
    
    '''
    comps = conf.split()

    profile = None
    if comps[0]:
        profile = comps[0]
    client = salt.utils.etcd_util.get_conn(__opts__, profile)

    path = '/'
    if len(comps) > 1 and comps[1].startswith('root='):
        path = comps[1].replace('root=', '')

    # put the minion's ID in the path if necessary
    path %= {
        'minion_id': minion_id
    }

    try:
        pillar = salt.utils.etcd_util.tree(client, path)
    except KeyError:
        log.error('No such key in etcd profile %s: %s', profile, path)
        pillar = {}

    return pillar
560668
def query(host=None, quiet=False):
    '''
    
    '''
    if quiet:
        log.warning("'quiet' is deprecated. Please migrate to --quiet")
    ret = {}
    client = salt.client.get_local_client(__opts__['conf_file'])
    try:
        for info in client.cmd_iter('virtual:physical',
                                    'virt.full_info', tgt_type='grain'):
            if not info:
                continue
            if not isinstance(info, dict):
                continue
            chunk = {}
            id_ = next(six.iterkeys(info))
            if host:
                if host != id_:
                    continue
            if not isinstance(info[id_], dict):
                continue
            if 'ret' not in info[id_]:
                continue
            if not isinstance(info[id_]['ret'], dict):
                continue
            chunk[id_] = info[id_]['ret']
            ret.update(chunk)
            if not quiet:
                __jid_event__.fire_event({'data': chunk, 'outputter': 'virt_query'}, 'progress')
    except SaltClientError as client_error:
        print(client_error)
    return ret
961884
def get(key, profile=None):
    '''
    
    '''
    if not profile:
        return None
    _, cur, table = _connect(profile)
    q = profile.get('get_query', ('SELECT value FROM {0} WHERE '
                                  'key=:key'.format(table)))
    res = cur.execute(q, {'key': key})
    res = res.fetchone()
    if not res:
        return None
    return salt.utils.msgpack.unpackb(res[0])
450704
def ext_pillar(minion_id,  # pylint: disable=W0613
               pillar,  # pylint: disable=W0613
               command):
    '''
    
    '''
    try:
        command = command.replace('%s', minion_id)
        return salt.utils.json.loads(__salt__['cmd.run'](command))
    except Exception:
        log.critical('JSON data from %s failed to parse', command)
        return {}
584280
def list_items(action, key, profile_dict=None, api_key=None, opts=None):
    '''
    
    '''
    items = salt.utils.json.loads(query(
        profile_dict=profile_dict,
        api_key=api_key,
        action=action,
        opts=opts
    ))
    ret = {}
    for item in items[action]:
        ret[item[key]] = item
    return ret
1008211
def compile_pillar(self):
        '''
        
        '''
        load = {'id': self.minion_id,
                'grains': self.grains,
                'saltenv': self.opts['saltenv'],
                'pillarenv': self.opts['pillarenv'],
                'pillar_override': self.pillar_override,
                'extra_minion_data': self.extra_minion_data,
                'ver': '2',
                'cmd': '_pillar'}
        if self.ext:
            load['ext'] = self.ext
        ret_pillar = self.channel.crypted_transfer_decode_dictentry(load,
                                                                    dictkey='pillar',
                                                                    )

        if not isinstance(ret_pillar, dict):
            log.error(
                'Got a bad pillar from master, type %s, expecting dict: %s',
                type(ret_pillar).__name__, ret_pillar
            )
            return {}
        return ret_pillar