Set redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_set masterauth luv_kittens
510443
def config_set(name, value, host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.config_set(name, value)
89090
def set(self, key, value):
        """"""
        key = "{0}{1}".format(self.prefix, key)

        value = json.dumps(value, cls=NumpyEncoder)
        self.redis.set(key, value)
342211
def __init_configrs(self, rs_cfg):
        """"""
        # Use 'rs_id' to set the id for consistency, but need to rename
        # to 'id' to use with ReplicaSets.create()
        rs_cfg['id'] = rs_cfg.pop('rs_id', None)
        for member in rs_cfg.setdefault('members', [{}]):
            member['procParams'] = self._strip_auth(
                member.get('procParams', {}))
            member['procParams']['configsvr'] = True
            if self.enable_ipv6:
                common.enable_ipv6_single(member['procParams'])
        rs_cfg['sslParams'] = self.sslParams
        self._configsvrs.append(ReplicaSets().create(rs_cfg))
567741
def configure(options, cfg)
      cfg[:root_dir]           = AgentConfig.root_dir
      cfg[:pid_dir]            = AgentConfig.pid_dir
      cfg[:identity]           = options[:identity] if options[:identity]
      cfg[:token]              = options[:token] if options[:token]
      cfg[:api_url]            = options[:api_url] if options[:api_url]
      cfg[:account_id]         = options[:account_id] if options[:account_id]
      cfg[:shard_id]           = options[:shard_id] if options[:shard_id]
      cfg[:mode]               = options[:mode] if options[:mode]
      cfg[:user]               = options[:user] if options[:user]
      cfg[:pass]               = options[:pass] if options[:pass]
      cfg[:vhost]              = options[:vhost] if options[:vhost]
      cfg[:port]               = options[:port] if options[:port]
      cfg[:host]               = options[:host] if options[:host]
      cfg[:prefetch]           = options[:prefetch] || 1
      cfg[:heartbeat]          = options[:heartbeat] if options[:heartbeat]
      cfg[:time_to_live]       = options[:time_to_live] || 60
      cfg[:retry_timeout]      = options[:retry_timeout] || 60
      cfg[:retry_interval]     = options[:retry_interval] || 5
      cfg[:ping_interval]      = options[:ping_interval] ||= 4 * 60 * 60
      cfg[:check_interval]     = options[:check_interval] if options[:check_interval]
      cfg[:reconnect_interval] = options[:reconnect_interval] if options[:reconnect_interval]
      cfg[:grace_timeout]      = options[:grace_timeout] if options[:grace_timeout]
      cfg[:dup_check]          = options[:dup_check].nil? ? true : options[:dup_check]
      cfg[:http_proxy]         = options[:http_proxy] if options[:http_proxy]
      cfg[:http_no_proxy]      = options[:http_no_proxy] if options[:http_no_proxy]
      cfg[:fiber_pool_size]    = options[:fiber_pool_size] if options[:fiber_pool_size]
      cfg[:airbrake_endpoint]  = options[:airbrake_endpoint] if options[:airbrake_endpoint]
      cfg[:airbrake_api_key]   = options[:airbrake_api_key] if options[:airbrake_api_key]
      cfg
    end
487278
def setup_redis(self, crawler=None):
        
        if self.server is not None:
            return

        if crawler is None:
            # We allow optional crawler argument to keep backwards
            # compatibility.
            # XXX: Raise a deprecation warning.
            crawler = getattr(self, 'crawler', None)

        if crawler is None:
            raise ValueError("crawler is required")

        settings = crawler.settings

        if self.redis_key is None:
            self.redis_key = settings.get(
                'REDIS_START_URLS_KEY', defaults.START_URLS_KEY,
            )

        self.redis_key = self.redis_key % {'name': self.name}

        if not self.redis_key.strip():
            raise ValueError("redis_key must not be empty")

        if self.redis_batch_size is None:
            # TODO: Deprecate this setting (REDIS_START_URLS_BATCH_SIZE).
            self.redis_batch_size = settings.getint(
                'REDIS_START_URLS_BATCH_SIZE',
                settings.getint('CONCURRENT_REQUESTS'),
            )

        try:
            self.redis_batch_size = int(self.redis_batch_size)
        except (TypeError, ValueError):
            raise ValueError("redis_batch_size must be an integer")

        if self.redis_encoding is None:
            self.redis_encoding = settings.get('REDIS_ENCODING', defaults.REDIS_ENCODING)

        self.logger.info("Reading start URLs from redis key '%(redis_key)s' "
                         "(batch size: %(redis_batch_size)s, encoding: %(redis_encoding)s",
                         self.__dict__)

        self.server = connection.from_settings(crawler.settings)
        # The idle signal is called when the spider has no requests left,
        # that's when we will schedule new requests from redis queue
        crawler.signals.connect(self.spider_idle, signal=signals.spider_idle)
247358
def set(self, key, value):
        """"""
        value = pickle.dumps(value, protocol=constants.PICKLE_PROTOCOL)
        redis_conn.set(key, value)
383171
def set_cache_token(self, token_data):
        

        if self.conn is None:
            raise CacheException('Redis is not connected')

        token = token_data['auth_token']
        token_expires = token_data['expires_at']
        roles = token_data['roles']

        try:
            datetime_object = datetime.strptime(
                token_expires, '%Y-%m-%dT%H:%M:%S.%fZ')
        except ValueError:
            datetime_object = datetime.strptime(
                token_expires, '%Y-%m-%dT%H:%M:%SZ')

        ttl = (datetime.utcnow().now() - datetime_object)
        token_data = json.dumps({
            'expires_at': token_expires,
            'roles': roles,
            'user': token_data['user']
        })

        self.conn.set(token, token_data, ex=ttl.seconds)
1028542
def set_ssh_creds(config, args):
    
    creds = config.get(A.DEPLOYER_CREDS, {})
    creds[A.creds.SSH_USER] = args.user if args.user else creds.get(
            A.creds.SSH_USER,
            DEFAULT_SSH_USER,
            )
    if args.ask_pass:
        creds[A.creds.SSH_PASS] = getpass.getpass('SSH Password: ')
    config[A.DEPLOYER_CREDS] = creds
963673
def set_servers(*servers):
    '''
    
    '''
    service_name = 'w32time'
    if not __salt__['service.status'](service_name):
        if not __salt__['service.start'](service_name):
            return False

    server_cmd = ['W32tm', '/config', '/syncfromflags:manual',
                  '/manualpeerlist:{0}'.format(' '.join(servers))]
    reliable_cmd = ['W32tm', '/config', '/reliable:yes']
    update_cmd = ['W32tm', '/config', '/update']

    for cmd in server_cmd, reliable_cmd, update_cmd:
        __salt__['cmd.run'](cmd, python_shell=False)

    if not sorted(list(servers)) == get_servers():
        return False

    __salt__['service.restart'](service_name)
    return True
596688
def set_client_cmd(self, *args):
        
        self.client_cmd.update(args)
        self.output['client_cmd'] = list(self.client_cmd)
225705
def set(self, key, value, **kwargs):
        '''
        
        '''
        return requests.put(
            '{}/{}/kv/{}'.format(
                self.master, pyconsul.__consul_api_version__, key),
            data=value,
            params=kwargs
        )
1266063
def set_multiple(self, **kwargs):
        """"""
        quiet = False
        if not kwargs:
            return
        cmd = ["heroku", "config:set"]
        for k in sorted(kwargs):
            cmd.append("{}={}".format(k, quote(str(kwargs[k]))))
            if self._is_sensitive_key(k):
                quiet = True
        cmd.extend(["--app", self.name])
        if quiet:
            self._run_quiet(cmd)
        else:
            self._run(cmd)
557291
def set_master(self, url):
        """"""
        m = urlparse(url)
        self.master_scheme = m.scheme
        self.master_netloc = m.netloc
        self.master_path = os.path.dirname(m.path)
502336
def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs):
        """"""
        if self.username == "root":
            exit_config_mode = False
        return super(LinuxSSH, self).send_config_set(
            config_commands=config_commands, exit_config_mode=exit_config_mode, **kwargs
        )
1009437
def _config(key, mandatory=True, opts=None):
    '''
    
    '''
    try:
        if opts:
            value = opts['auth.ldap.{0}'.format(key)]
        else:
            value = __opts__['auth.ldap.{0}'.format(key)]
    except KeyError:
        try:
            value = __defopts__['auth.ldap.{0}'.format(key)]
        except KeyError:
            if mandatory:
                msg = 'missing auth.ldap.{0} in master config'.format(key)
                raise SaltInvocationError(msg)
            return False
    return value
345617
def _save_config(section, token, value):
    '''
    
    '''
    cmd = NIRTCFG_PATH
    cmd += ' --set section={0},token=\'{1}\',value=\'{2}\''.format(section, token, value)
    if __salt__['cmd.run_all'](cmd)['retcode'] != 0:
        exc_msg = 'Error: could not set {} to {} for {}\n'.format(token, value, section)
        raise salt.exceptions.CommandExecutionError(exc_msg)
1030719
def configure(access_key=None, secret_key=None, logger=None):
    '''
    
    '''
    if not logger:
        logger = log.get_logger('s3')
    if not all([access_key, secret_key]):
        logger.info('')
        access_key = input('AWS Access Key: ')
        secret_key = input('AWS Secret Key: ')
    _write_config(access_key, secret_key)
    logger.info('')
    logger.info('Completed writing S3 config file.')
    logger.info('')