text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_config_status(): ''' Get the status of the current DSC Configuration Returns: dict: A dictionary representing the status of the current DSC Configuration on the machine CLI Example: .. code-block:: bash salt '*' dsc.get_config_status ''' cmd = 'Get-Dsc...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def sense(chip, fahrenheit=False): ''' Gather lm-sensors data from a given chip To determine the chip to query, use the 'sensors' command and see the leading line in the block. Example: /usr/bin/sensors coretemp-isa-0000 Adapter: ISA adapter Physical id 0: +56.0°C (high = +87.0...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def convert_duration(duration): ''' Convert the a duration string into XXhYYmZZs format duration Duration to convert Returns: duration_string String representation of duration in XXhYYmZZs format ''' # durations must be specified in days, weeks or hours if duration.endswi...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def present(name, database, duration="7d", replication=1, default=False, **client_args): ''' Ensure that given retention policy is present. name Name of the retention policy to create. database Database to create retention policy on. ''' ret = {'name': n...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def fire_master(data, tag, preload=None, timeout=60): ''' Fire an event off up to the master server CLI Example: .. code-block:: bash salt '*' event.fire_master '{"data":"my event data"}' 'tag' ''' if (__opts__.get('local', None) or __opts__.get('file_client', None) == 'local') and no...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def fire(data, tag, timeout=None): ''' Fire an event on the local minion event bus. Data must be formed as a dict. CLI Example: .. code-block:: bash salt '*' event.fire '{"data":"my event data"}' 'tag' ''' if timeout is None: timeout = 60000 else: timeout = timeout...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def absent(version, name): ''' Ensure that the named cluster is absent version Version of the postgresql server of the cluster to remove name The name of the cluster to remove .. versionadded:: 2015.XX ''' ret = {'name': name, 'changes': {}, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _send_splunk(event, index_override=None, sourcetype_override=None): ''' Send the results to Splunk. Requires the Splunk HTTP Event Collector running on port 8088. This is available on Splunk Enterprise version 6.3 or higher. ''' # Get Splunk Options opts = _get_options() log.info(st...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _get_salt_params(): ''' Try to get all sort of parameters for Server Density server info. NOTE: Missing publicDNS and publicIPs parameters. There might be way of getting them with salt-cloud. ''' all_stats = __salt__['status.all_status']() all_grains = __salt__['grains.items']() par...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def monitored(name, group=None, salt_name=True, salt_params=True, agent_version=1, **params): ''' Device is monitored with Server Density. name Device name in Server Density. salt_name If ``True`` (default), takes the name from the ``id`` grain. If ``False``, the provided name ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _conn(queue): ''' Return an sqlite connection ''' queue_dir = __opts__['sqlite_queue_dir'] db = os.path.join(queue_dir, '{0}.db'.format(queue)) log.debug('Connecting to: %s', db) con = sqlite3.connect(db) tables = _list_tables(con) if queue not in tables: _create_table(c...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _list_items(queue): ''' Private function to list contents of a queue ''' con = _conn(queue) with con: cur = con.cursor() cmd = 'SELECT name FROM {0}'.format(queue) log.debug('SQL Query: %s', cmd) cur.execute(cmd) contents = cur.fetchall() return conten...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _list_queues(): ''' Return a list of sqlite databases in the queue_dir ''' queue_dir = __opts__['sqlite_queue_dir'] files = os.path.join(queue_dir, '*.db') paths = glob.glob(files) queues = [os.path.splitext(os.path.basename(item))[0] for item in paths] return queues
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def list_items(queue): ''' List contents of a queue ''' itemstuple = _list_items(queue) items = [item[0] for item in itemstuple] return items
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_all_topics(region=None, key=None, keyid=None, profile=None): ''' Returns a list of the all topics.. CLI example:: salt myminion boto_sns.get_all_topics ''' cache_key = _cache_get_key() try: return __context__[cache_key] except KeyError: pass conn = _get...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_all_subscriptions_by_topic(name, region=None, key=None, keyid=None, profile=None): ''' Get list of all subscriptions to a specific topic. CLI example to delete a topic:: salt myminion boto_sns.get_all_subscriptions_by_topic mytopic region=us-east-1 ''' cache_key = _subscriptions_ca...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_arn(name, region=None, key=None, keyid=None, profile=None): ''' Returns the full ARN for a given topic name. CLI example:: salt myminion boto_sns.get_arn mytopic ''' if name.startswith('arn:aws:sns:'): return name account_id = __salt__['boto_iam.get_account_id']( ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def current_ioloop(io_loop): ''' A context manager that will set the current ioloop to io_loop for the context ''' orig_loop = tornado.ioloop.IOLoop.current() io_loop.make_current() try: yield finally: orig_loop.make_current()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _get_top_file_envs(): ''' Get all environments from the top file ''' try: return __context__['saltutil._top_file_envs'] except KeyError: try: st_ = salt.state.HighState(__opts__, initial_pillar=__pillar__) top = st_.g...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _sync(form, saltenv=None, extmod_whitelist=None, extmod_blacklist=None): ''' Sync the given directory in the given environment ''' if saltenv is None: saltenv = _get_top_file_envs() if isinstance(saltenv, six.string_types): saltenv = saltenv.split(',') ret, touched = salt.uti...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def refresh_pillar(**kwargs): ''' Signal the minion to refresh the pillar data. .. versionchanged:: Neon The ``async`` argument has been added. The default value is True. CLI Example: .. code-block:: bash salt '*' saltutil.refresh_pillar salt '*' saltutil.refresh_pillar a...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def clear_cache(days=-1): ''' Forcibly removes all caches on a minion. .. versionadded:: 2014.7.0 WARNING: The safest way to clear a minion cache is by first stopping the minion and then deleting the cache files before restarting it. CLI Example: .. code-block:: bash salt '*' sa...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def clear_job_cache(hours=24): ''' Forcibly removes job cache folders and files on a minion. .. versionadded:: 2018.3.0 WARNING: The safest way to clear a minion cache is by first stopping the minion and then deleting the cache files before restarting it. CLI Example: .. code-block:: bas...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def find_cached_job(jid): ''' Return the data for a specific cached job id. Note this only works if cache_jobs has previously been set to True on the minion. CLI Example: .. code-block:: bash salt '*' saltutil.find_cached_job <job id> ''' serial = salt.payload.Serial(__opts__) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def signal_job(jid, sig): ''' Sends a signal to the named salt job's process CLI Example: .. code-block:: bash salt '*' saltutil.signal_job <job id> 15 ''' if HAS_PSUTIL is False: log.warning('saltutil.signal job called, but psutil is not installed. ' 'Inst...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def regen_keys(): ''' Used to regenerate the minion keys. CLI Example: .. code-block:: bash salt '*' saltutil.regen_keys ''' for fn_ in os.listdir(__opts__['pki_dir']): path = os.path.join(__opts__['pki_dir'], fn_) try: os.remove(path) except os.err...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def revoke_auth(preserve_minion_cache=False): ''' The minion sends a request to the master to revoke its own key. Note that the minion session will be revoked and the minion may not be able to return the result of this command back to the master. If the 'preserve_minion_cache' flag is set to True, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def runner(name, arg=None, kwarg=None, full_return=False, saltenv='base', jid=None, asynchronous=False, **kwargs): ''' Execute a runner function. This function must be run on the master, either by targeting a minion running on a master or by using salt-call on a master. .. versionadded:: 2014.7.0 ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def wheel(name, *args, **kwargs): ''' Execute a wheel module and function. This function must be run against a minion that is local to the master. .. versionadded:: 2014.7.0 name The name of the function to run args Any positional arguments to pass to the wheel function. A com...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def mmodule(saltenv, fun, *args, **kwargs): ''' Loads minion modules from an environment so that they can be used in pillars for that environment CLI Example: .. code-block:: bash salt '*' saltutil.mmodule base test.ping ''' mminion = _MMinion(saltenv) return mminion.functions...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _session(): ''' Create a session to be used when connecting to Zenoss. ''' config = __salt__['config.option']('zenoss') session = requests.session() session.auth = (config.get('username'), config.get('password')) session.verify = False session.headers.update({'Content-type': 'applic...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _router_request(router, method, data=None): ''' Make a request to the Zenoss API router ''' if router not in ROUTERS: return False req_data = salt.utils.json.dumps([dict( action=router, method=method, data=data, type='rpc', tid=1)]) config = ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def find_device(device=None): ''' Find a device in Zenoss. If device not found, returns None. Parameters: device: (Optional) Will use the grain 'fqdn' by default CLI Example: salt '*' zenoss.find_device ''' data = [{'uid': '/zport/dmd/Devices', 'params': {}, 'limit': N...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def add_device(device=None, device_class=None, collector='localhost', prod_state=1000): ''' A function to connect to a zenoss server and add a new device entry. Parameters: device: (Optional) Will use the grain 'fqdn' by default. device_class: (Optional) The device class to use. I...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def set_prod_state(prod_state, device=None): ''' A function to set the prod_state in zenoss. Parameters: prod_state: (Required) Integer value of the state device: (Optional) Will use the grain 'fqdn' by default. CLI Example: salt zenoss.set_prod_state 1000 hostname ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _valid_deleted_file(path): ''' Filters file path against unwanted directories and decides whether file is marked as deleted. Returns: True if file is desired deleted file, else False. Args: path: A string - path to file ''' ret = False if path.endswith(' (deleted)'): ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _format_output(kernel_restart, packages, verbose, restartable, nonrestartable, restartservicecommands, restartinitcommands): ''' Formats the output of the restartcheck module. Returns: String - formatted output. Args: kernel_restart: indicates that newer kernel i...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _file_changed_nilrt(full_filepath): ''' Detect whether a file changed in an NILinuxRT system using md5sum and timestamp files from a state directory. Returns: - False if md5sum/timestamp state files don't exist - True/False depending if ``base_filename`` got modified/touch...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _sysapi_changed_nilrt(): ''' Besides the normal Linux kernel driver interfaces, NILinuxRT-supported hardware features an extensible, plugin-based device enumeration and configuration interface named "System API". When an installed package is extending the API it is very hard to know all repercurssio...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def default_storage_policy_assigned(name, policy, datastore): ''' Assigns a default storage policy to a datastore policy Name of storage policy datastore Name of datastore ''' log.info('Running state %s for policy \'%s\', datastore \'%s\'.', name, policy, datastore...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _get_client(): ''' Return a cloud client ''' client = salt.cloud.CloudClient( os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud'), pillars=copy.deepcopy(__pillar__.get('cloud', {})) ) return client
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def has_instance(name, provider=None): ''' Return true if the instance is found on a provider CLI Example: .. code-block:: bash salt minionname cloud.has_instance myinstance ''' data = get_instance(name, provider) if data is None: return False return True
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_instance(name, provider=None): ''' Return details on an instance. Similar to the cloud action show_instance but returns only the instance details. CLI Example: .. code-block:: bash salt minionname cloud.get_instance myinstance SLS Example: .. code-block:: bash ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def profile_(profile, names, vm_overrides=None, opts=None, **kwargs): ''' Spin up an instance using Salt Cloud CLI Example: .. code-block:: bash salt minionname cloud.profile my-gce-config myinstance ''' client = _get_client() if isinstance(opts, dict): client.opts.update(...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def volume_list(provider): ''' List block storage volumes CLI Example: .. code-block:: bash salt minionname cloud.volume_list my-nova ''' client = _get_client() info = client.extra_action(action='volume_list', provider=provider, names='name') return info['name']
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def volume_attach(provider, names, **kwargs): ''' Attach volume to a server CLI Example: .. code-block:: bash salt minionname cloud.volume_attach my-nova myblock server_name=myserver device='/dev/xvdf' ''' client = _get_client() info = client.extra_action(provider=provider, names...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def network_list(provider): ''' List private networks CLI Example: .. code-block:: bash salt minionname cloud.network_list my-nova ''' client = _get_client() return client.extra_action(action='network_list', provider=provider, names='names')
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def network_create(provider, names, **kwargs): ''' Create private network CLI Example: .. code-block:: bash salt minionname cloud.network_create my-nova names=['salt'] cidr='192.168.100.0/24' ''' client = _get_client() return client.extra_action(provider=provider, names=names, ac...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def virtual_interface_list(provider, names, **kwargs): ''' List virtual interfaces on a server CLI Example: .. code-block:: bash salt minionname cloud.virtual_interface_list my-nova names=['salt-master'] ''' client = _get_client() return client.extra_action(provider=provider, nam...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def virtual_interface_create(provider, names, **kwargs): ''' Attach private interfaces to a server CLI Example: .. code-block:: bash salt minionname cloud.virtual_interface_create my-nova names=['salt-master'] net_name='salt' ''' client = _get_client() return client.extra_action(...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get(name): ''' Return a single sysctl parameter for this minion CLI Example: .. code-block:: bash salt '*' sysctl.get hw.physmem ''' cmd = 'sysctl -n {0}'.format(name) out = __salt__['cmd.run'](cmd, python_shell=False) return out
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def post_message(name, user=None, device=None, message=None, title=None, priority=None, expire=None, retry=None, sound=None, api_version=1, token=None...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def check_ip(addr): ''' Check if address is a valid IP. returns True if valid, otherwise False. CLI Example: .. code-block:: bash salt ns1 dig.check_ip 127.0.0.1 salt ns1 dig.check_ip 1111:2222:3333:4444:5555:6666:7777:8888 ''' try: addr = addr.rsplit('/', 1) exce...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def AAAA(host, nameserver=None): ''' Return the AAAA record for ``host``. Always returns a list. CLI Example: .. code-block:: bash salt ns1 dig.AAAA www.google.com ''' dig = ['dig', '+short', six.text_type(host), 'AAAA'] if nameserver is not None: dig.append('@{0}'.f...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def SPF(domain, record='SPF', nameserver=None): ''' Return the allowed IPv4 ranges in the SPF record for ``domain``. If record is ``SPF`` and the SPF record is empty, the TXT record will be searched automatically. If you know the domain uses TXT and not SPF, specifying that will save a lookup. ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def TXT(host, nameserver=None): ''' Return the TXT record for ``host``. Always returns a list. CLI Example: .. code-block:: bash salt ns1 dig.TXT google.com ''' dig = ['dig', '+short', six.text_type(host), 'TXT'] if nameserver is not None: dig.append('@{0}'.format(na...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _workout_filename(filename): ''' Recursively workout the file name from an augeas change ''' if os.path.isfile(filename) or filename == '/': if filename == '/': filename = None return filename else: return _workout_filename(os.path.dirname(filename))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _check_filepath(changes): ''' Ensure all changes are fully qualified and affect only one file. This ensures that the diff output works and a state change is not incorrectly reported. ''' filename = None for change_ in changes: try: cmd, arg = change_.split(' ', 1) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def bgrewriteaof(host=None, port=None, db=None, password=None): ''' Asynchronously rewrite the append-only file CLI Example: .. code-block:: bash salt '*' redis.bgrewriteaof ''' server = _connect(host, port, db, password) return server.bgrewriteaof()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def bgsave(host=None, port=None, db=None, password=None): ''' Asynchronously save the dataset to disk CLI Example: .. code-block:: bash salt '*' redis.bgsave ''' server = _connect(host, port, db, password) return server.bgsave()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def config_get(pattern='*', host=None, port=None, db=None, password=None): ''' Get redis server configuration values CLI Example: .. code-block:: bash salt '*' redis.config_get salt '*' redis.config_get port ''' server = _connect(host, port, db, password) return server.con...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def config_set(name, value, host=None, port=None, db=None, password=None): ''' Set redis server configuration values CLI Example: .. code-block:: bash salt '*' redis.config_set masterauth luv_kittens ''' server = _connect(host, port, db, password) return server.config_set(name, va...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def dbsize(host=None, port=None, db=None, password=None): ''' Return the number of keys in the selected database CLI Example: .. code-block:: bash salt '*' redis.dbsize ''' server = _connect(host, port, db, password) return server.dbsize()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def delete(*keys, **connection_args): ''' Deletes the keys from redis, returns number of keys deleted CLI Example: .. code-block:: bash salt '*' redis.delete foo ''' # Get connection args from keywords if set conn_args = {} for arg in ['host', 'port', 'db', 'password']: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def exists(key, host=None, port=None, db=None, password=None): ''' Return true if the key exists in redis CLI Example: .. code-block:: bash salt '*' redis.exists foo ''' server = _connect(host, port, db, password) return server.exists(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def expire(key, seconds, host=None, port=None, db=None, password=None): ''' Set a keys time to live in seconds CLI Example: .. code-block:: bash salt '*' redis.expire foo 300 ''' server = _connect(host, port, db, password) return server.expire(key, seconds)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def expireat(key, timestamp, host=None, port=None, db=None, password=None): ''' Set a keys expire at given UNIX time CLI Example: .. code-block:: bash salt '*' redis.expireat foo 1400000000 ''' server = _connect(host, port, db, password) return server.expireat(key, timestamp)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def flushall(host=None, port=None, db=None, password=None): ''' Remove all keys from all databases CLI Example: .. code-block:: bash salt '*' redis.flushall ''' server = _connect(host, port, db, password) return server.flushall()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def flushdb(host=None, port=None, db=None, password=None): ''' Remove all keys from the selected database CLI Example: .. code-block:: bash salt '*' redis.flushdb ''' server = _connect(host, port, db, password) return server.flushdb()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_key(key, host=None, port=None, db=None, password=None): ''' Get redis key value CLI Example: .. code-block:: bash salt '*' redis.get_key foo ''' server = _connect(host, port, db, password) return server.get(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hexists(key, field, host=None, port=None, db=None, password=None): ''' Determine if a hash fields exists. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hexists foo_hash bar_field ''' server = _connect(host, port, db, password) return server.h...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hgetall(key, host=None, port=None, db=None, password=None): ''' Get all fields and values from a redis hash, returns dict CLI Example: .. code-block:: bash salt '*' redis.hgetall foo_hash ''' server = _connect(host, port, db, password) return server.hgetall(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hlen(key, host=None, port=None, db=None, password=None): ''' Returns number of fields of a hash. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hlen foo_hash ''' server = _connect(host, port, db, password) return server.hlen(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hmget(key, *fields, **options): ''' Returns the values of all the given hash fields. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hmget foo_hash bar_field1 bar_field2 ''' host = options.get('host', None) port = options.get('port', None) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hmset(key, **fieldsvals): ''' Sets multiple hash fields to multiple values. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hmset foo_hash bar_field1=bar_value1 bar_field2=bar_value2 ''' host = fieldsvals.pop('host', None) port = fieldsvals.pop...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hset(key, field, value, host=None, port=None, db=None, password=None): ''' Set the value of a hash field. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hset foo_hash bar_field bar_value ''' server = _connect(host, port, db, password) return s...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def hvals(key, host=None, port=None, db=None, password=None): ''' Return all the values in a hash. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' redis.hvals foo_hash bar_field1 bar_value1 ''' server = _connect(host, port, db, password) return server.hv...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def info(host=None, port=None, db=None, password=None): ''' Get information and statistics about the server CLI Example: .. code-block:: bash salt '*' redis.info ''' server = _connect(host, port, db, password) return server.info()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def keys(pattern='*', host=None, port=None, db=None, password=None): ''' Get redis keys, supports glob style patterns CLI Example: .. code-block:: bash salt '*' redis.keys salt '*' redis.keys test* ''' server = _connect(host, port, db, password) return server.keys(pattern)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def key_type(key, host=None, port=None, db=None, password=None): ''' Get redis key type CLI Example: .. code-block:: bash salt '*' redis.type foo ''' server = _connect(host, port, db, password) return server.type(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def lastsave(host=None, port=None, db=None, password=None): ''' Get the UNIX time in seconds of the last successful save to disk CLI Example: .. code-block:: bash salt '*' redis.lastsave ''' # Use of %s to get the timestamp is not supported by Python. The reason it # works is beca...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def llen(key, host=None, port=None, db=None, password=None): ''' Get the length of a list in Redis CLI Example: .. code-block:: bash salt '*' redis.llen foo_list ''' server = _connect(host, port, db, password) return server.llen(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def ping(host=None, port=None, db=None, password=None): ''' Ping the server, returns False on connection errors CLI Example: .. code-block:: bash salt '*' redis.ping ''' server = _connect(host, port, db, password) try: return server.ping() except redis.ConnectionError:...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def save(host=None, port=None, db=None, password=None): ''' Synchronously save the dataset to disk CLI Example: .. code-block:: bash salt '*' redis.save ''' server = _connect(host, port, db, password) return server.save()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def set_key(key, value, host=None, port=None, db=None, password=None): ''' Set redis key value CLI Example: .. code-block:: bash salt '*' redis.set_key foo bar ''' server = _connect(host, port, db, password) return server.set(key, value)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def shutdown(host=None, port=None, db=None, password=None): ''' Synchronously save the dataset to disk and then shut down the server CLI Example: .. code-block:: bash salt '*' redis.shutdown ''' server = _connect(host, port, db, password) try: # Return false if unable to p...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def slaveof(master_host=None, master_port=None, host=None, port=None, db=None, password=None): ''' Make the server a slave of another instance, or promote it as master CLI Example: .. code-block:: bash # Become slave of redis-n01.example.com:6379 salt '*' redis.slaveof red...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def smembers(key, host=None, port=None, db=None, password=None): ''' Get members in a Redis set CLI Example: .. code-block:: bash salt '*' redis.smembers foo_set ''' server = _connect(host, port, db, password) return list(server.smembers(key))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def time(host=None, port=None, db=None, password=None): ''' Return the current server UNIX time in seconds CLI Example: .. code-block:: bash salt '*' redis.time ''' server = _connect(host, port, db, password) return server.time()[0]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def zcard(key, host=None, port=None, db=None, password=None): ''' Get the length of a sorted set in Redis CLI Example: .. code-block:: bash salt '*' redis.zcard foo_sorted ''' server = _connect(host, port, db, password) return server.zcard(key)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def zrange(key, start, stop, host=None, port=None, db=None, password=None): ''' Get a range of values from a sorted set in Redis by index CLI Example: .. code-block:: bash salt '*' redis.zrange foo_sorted 0 10 ''' server = _connect(host, port, db, password) return server.zrange(ke...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def sentinel_get_master_ip(master, host=None, port=None, password=None): ''' Get ip for sentinel master .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.sentinel_get_master_ip 'mymaster' ''' server = _sconnect(host, port, password) ret = server.senti...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def get_master_ip(host=None, port=None, password=None): ''' Get host information about slave .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.get_master_ip ''' server = _connect(host, port, password) srv_info = server.info() ret = (srv_info.get('...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _get_conn(key=None, keyid=None, profile=None, region=None, **kwargs): ''' Create a boto3 client connection to EFS ''' client = None if profile: if isinstance(profile, six.string_types): if profile in __pillar__: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def create_file_system(name, performance_mode='generalPurpose', keyid=None, key=None, profile=None, region=None, creation_token=None, **kwargs): ''' Cr...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def create_mount_target(filesystemid, subnetid, ipaddress=None, securitygroups=None, keyid=None, key=None, profile=None, region=None, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def create_tags(filesystemid, tags, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Creates or overwrites tags associated with a file system. Each tag is a key-value pair. If a tag key specified i...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def delete_file_system(filesystemid, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes a file system, permanently severing access to its contents. Upon return, the file sy...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def delete_mount_target(mounttargetid, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes the specified mount target. This operation forcibly breaks any mounts of the file...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def delete_tags(filesystemid, tags, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes the specified tags from a file system. filesystemid (string) - ID of the file system for whose ...