Get redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_get
        salt '*' redis.config_get port
437219
def config_get(pattern='*', host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.config_get(pattern)
1332108
def get_values():
    

    # First load a mapping between config name and default value
    default_initial = ((name, options[0])
                       for name, options in settings.CONFIG.items())
    # Then update the mapping with actually values from the backend
    initial = dict(default_initial, **dict(config._backend.mget(settings.CONFIG)))

    return initial
920562
function getRemoteConfig (remoteConfigUrl, cb) {
  nets({ url: remoteConfigUrl, json: true }, function gotConfig (err, resp, config) {
    if (err || resp.statusCode > 299) config = undefined // ignore errors
    cb(null, config)
  })
}
843349
def _config_getter(get_opt,
                   key,
                   value_regex=None,
                   cwd=None,
                   user=None,
                   password=None,
                   ignore_retcode=False,
                   output_encoding=None,
                   **kwargs):
    '''
    
    '''
    kwargs = salt.utils.args.clean_kwargs(**kwargs)
    global_ = kwargs.pop('global', False)
    if kwargs:
        salt.utils.args.invalid_kwargs(kwargs)

    if cwd is None:
        if not global_:
            raise SaltInvocationError(
                '\'cwd\' argument required unless global=True'
            )
    else:
        cwd = _expand_path(cwd, user)

    if get_opt == '--get-regexp':
        if value_regex is not None \
                and not isinstance(value_regex, six.string_types):
            value_regex = six.text_type(value_regex)
    else:
        # Ignore value_regex
        value_regex = None

    command = ['git', 'config']
    command.extend(_which_git_config(global_, cwd, user, password,
                                     output_encoding=output_encoding))
    command.append(get_opt)
    command.append(key)
    if value_regex is not None:
        command.append(value_regex)
    return _git_run(command,
                    cwd=cwd,
                    user=user,
                    password=password,
                    ignore_retcode=ignore_retcode,
                    failhard=False,
                    output_encoding=output_encoding)
570006
def _get_options(ret=None):
    '''
    
    '''
    attrs = {'host': 'host',
             'port': 'port',
             'unix_socket_path': 'unix_socket_path',
             'db': 'db',
             'password': 'password',
             'cluster_mode': 'cluster_mode',
             'startup_nodes': 'cluster.startup_nodes',
             'skip_full_coverage_check': 'cluster.skip_full_coverage_check',
             }

    if salt.utils.platform.is_proxy():
        return {
            'host': __opts__.get('redis.host', 'salt'),
            'port': __opts__.get('redis.port', 6379),
            'unix_socket_path': __opts__.get('redis.unix_socket_path', None),
            'db': __opts__.get('redis.db', '0'),
            'password': __opts__.get('redis.password', ''),
            'cluster_mode': __opts__.get('redis.cluster_mode', False),
            'startup_nodes': __opts__.get('redis.cluster.startup_nodes', {}),
            'skip_full_coverage_check': __opts__.get('redis.cluster.skip_full_coverage_check', False)
        }

    _options = salt.returners.get_returner_options(__virtualname__,
                                                   ret,
                                                   attrs,
                                                   __salt__=__salt__,
                                                   __opts__=__opts__)
    return _options
497421
def redis
      redis_master_source = @config.redis_server =~ /^\S+\:\d+$/ ? "server_string" : "master_file"
      _eigenclass_.class_eval <<-EVALS, __FILE__, __LINE__
        def redis
          redis_master_from_#{redis_master_source}
        end
      EVALS
      redis
    end
1183726
def get_server_sock():
    ""
    s = _socket.socket()
    s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
    s.setblocking(False)
    s.bind(('0.0.0.0', _config.server_listen_port))
    s.listen(5)
    return s
809353
def get_lock(self, lockname, locktime=60, auto_renewal=False):
        '''  '''
        pid = os.getpid()
        caller = inspect.stack()[0][3]
        try:
            # rl = redlock.Redlock([{"host": settings.REDIS_SERVERS['std_redis']['host'], "port": settings.REDIS_SERVERS['std_redis']['port'], "db": settings.REDIS_SERVERS['std_redis']['db']}, ])
            rl = redis_lock.Lock(self, lockname, expire=locktime, auto_renewal=auto_renewal)
        except:
            if self.logger:
                self.logger.error('Process {0} ({1}) could not get lock {2}. Going ahead without locking!!! {3}'.format(pid, caller, lockname, traceback.format_exc()))
            return False
        try:
            lock = rl.acquire(blocking=False)
        except RedisError:
            return False
        if not lock:
            return False
        else:
            return rl
381572
def _interface_configs():
    '''
    
    '''
    cmd = ['netsh', 'interface', 'ip', 'show', 'config']
    lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    ret = {}
    current_iface = None
    current_ip_list = None

    for line in lines:

        line = line.strip()
        if not line:
            current_iface = None
            current_ip_list = None
            continue

        if 'Configuration for interface' in line:
            _, iface = line.rstrip('"').split('"', 1)  # get iface name
            current_iface = {}
            ret[iface] = current_iface
            continue

        if ':' not in line:
            if current_ip_list:
                current_ip_list.append(line)
            else:
                log.warning('Cannot parse "%s"', line)
            continue

        key, val = line.split(':', 1)
        key = key.strip()
        val = val.strip()

        lkey = key.lower()
        if ('dns servers' in lkey) or ('wins servers' in lkey):
            current_ip_list = []
            current_iface[key] = current_ip_list
            current_ip_list.append(val)

        elif 'ip address' in lkey:
            current_iface.setdefault('ip_addrs', []).append({key: val})

        elif 'subnet prefix' in lkey:
            subnet, _, netmask = val.split(' ', 2)
            last_ip = current_iface['ip_addrs'][-1]
            last_ip['Subnet'] = subnet.strip()
            last_ip['Netmask'] = netmask.lstrip().rstrip(')')

        else:
            current_iface[key] = val

    return ret
1021791
def __get_connection(self) -> redis.Redis:
        

        if self.__redis_use_socket:
            r = redis.from_url(
                'unix://{:s}?db={:d}'.format(
                    self.__redis_host,
                    self.__redis_db
                )
            )
        else:
            r = redis.from_url(
                'redis://{:s}:{:d}/{:d}'.format(
                    self.__redis_host,
                    self.__redis_port,
                    self.__redis_db
                )
            )

        if BlackRed.Settings.REDIS_AUTH is not None:
            r.execute_command('AUTH {:s}'.format(BlackRed.Settings.REDIS_AUTH))
        return r
1220201
def config_get(self, pattern='*'):
        
        result = {}
        for name, value in self.redis_config.items():
            if fnmatch.fnmatch(name, pattern):
                try:
                    result[name] = int(value)
                except ValueError:
                    result[name] = value
        return result
715569
def dns_get_conf(self, domainName, environment):
        
        response = self.client.service.dns_get_conf(domainName, environment)
        dns_config = CotendoDNS(response)
        return dns_config
618915
def salt_key():
    '''
    
    '''
    import salt.cli.key
    try:
        client = salt.cli.key.SaltKey()
        _install_signal_handlers(client)
        client.run()
    except Exception as err:
        sys.stderr.write("Error: {0}\n".format(err))
1085354
def get_redis_connection(config, use_strict_redis=False):
    
    redis_cls = redis.StrictRedis if use_strict_redis else redis.Redis

    if 'URL' in config:
        return redis_cls.from_url(config['URL'], db=config.get('DB'))

    if 'USE_REDIS_CACHE' in config.keys():

        try:
            # Assume that we're using django-redis
            from django_redis import get_redis_connection as get_redis
            return get_redis(config['USE_REDIS_CACHE'])
        except ImportError:
            pass

        from django.core.cache import caches
        cache = caches[config['USE_REDIS_CACHE']]
        # We're using django-redis-cache
        try:
            return cache._client
        except AttributeError:
            # For django-redis-cache > 0.13.1
            return cache.get_master_client()

    if 'UNIX_SOCKET_PATH' in config:
        return redis_cls(unix_socket_path=config['UNIX_SOCKET_PATH'], db=config['DB'])

    if 'SENTINELS' in config:
        sentinel_kwargs = {
            'db': config.get('DB'),
            'password': config.get('PASSWORD'),
            'socket_timeout': config.get('SOCKET_TIMEOUT'),
        }
        sentinel_kwargs.update(config.get('CONNECTION_KWARGS', {}))
        sentinel = Sentinel(config['SENTINELS'], **sentinel_kwargs)
        return sentinel.master_for(
            service_name=config['MASTER_NAME'], redis_class=redis_cls,
        )

    return redis_cls(host=config['HOST'], port=config['PORT'], db=config['DB'], password=config.get('PASSWORD'), ssl=config.get('SSL', False))
1172355
def _retrieve_config_xml(config_xml, saltenv):
    '''
    
    '''
    ret = __salt__['cp.cache_file'](config_xml, saltenv)

    if not ret:
        raise CommandExecutionError('Failed to retrieve {0}'.format(config_xml))

    return ret
703407
def _parse_conf(conf_file=default_conf):
    '''
    
    '''
    ret = {}
    with salt.utils.files.fopen(conf_file, 'r') as ifile:
        for line in ifile:
            line = salt.utils.stringutils.to_unicode(line).strip()
            if not line:
                continue
            if line.startswith('#'):
                continue
            splitline = line.split(' ', 1)
            ret[splitline[0]] = splitline[1]
    return ret
1079789
function readServerConfig( server ) {
  try {
    const severConfig = getConfig( appSeverConfig );
    return Right( Object.assign( server, severConfig ));
  } catch ( e ) {
    print(
      chalk.red( `Failed to read ${SEVER_CONFIG}.` ),
      e.message
    );
    print();
    return Left( null );
  }
}