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 rm_special(user, cmd, special=None, identifier=None): ''' Remove a special cron job for a specified user. CLI Example: .. code-block:: bash salt '*' cron.rm_special root /usr/bin/foo ''' lst = list_tab(user) ret = 'absent' rm_ = None for ind in range(len(lst['special']...
<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_env(user, name, value=None): ''' Set up an environment variable in the crontab. CLI Example: .. code-block:: bash salt '*' cron.set_env root MAILTO user@example.com ''' lst = list_tab(user) for env in lst['env']: if name == env['name']: if value != env[...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def rm_env(user, name): ''' Remove cron environment variable for a specified user. CLI Example: .. code-block:: bash salt '*' cron.rm_env root MAILTO ''' lst = list_tab(user) ret = 'absent' rm_ = None for ind in range(len(lst['env'])): if name == lst['env'][ind]['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 exists(Bucket, region=None, key=None, keyid=None, profile=None): ''' Given a bucket name, check to see if the given bucket exists. Returns True if the given bucket exists and returns False if the given bucket does not exist. CLI Example: .. code-block:: bash salt mymin...
<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(Bucket, ACL=None, LocationConstraint=None, GrantFullControl=None, GrantRead=None, GrantReadACP=None, GrantWrite=None, GrantWriteACP=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, create an ...
<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(Bucket, MFA=None, RequestPayer=None, Force=False, region=None, key=None, keyid=None, profile=None): ''' Given a bucket name, delete it, optionally emptying it first. Returns {deleted: true} if the bucket was deleted and returns {deleted: false} if the bucket was not 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 delete_objects(Bucket, Delete, MFA=None, RequestPayer=None, region=None, key=None, keyid=None, profile=None): ''' Delete objects in a given S3 bucket. Returns {deleted: true} if all objects were deleted and {deleted: false, failed: [key, ...]} otherwise CLI Example: .. ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def describe(Bucket, region=None, key=None, keyid=None, profile=None): ''' Given a bucket name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.describe mybucket ''' try: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def empty(Bucket, MFA=None, RequestPayer=None, region=None, key=None, keyid=None, profile=None): ''' Delete all objects in a given S3 bucket. Returns {deleted: true} if all objects were deleted and {deleted: false, failed: [key, ...]} otherwise CLI 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 list(region=None, key=None, keyid=None, profile=None): ''' List all buckets owned by the authenticated sender of the request. Returns list of buckets CLI Example: .. code-block:: yaml Owner: {...} Buckets: - {...} - {...} ''' try: conn = _...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_acl(Bucket, ACL=None, AccessControlPolicy=None, GrantFullControl=None, GrantRead=None, GrantReadACP=None, GrantWrite=None, GrantWriteACP=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid confi...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_cors(Bucket, CORSRules, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the CORS rules for a bucket. Returns {updated: true} if CORS was updated and returns {updated: False} if CORS was not updated. CLI Example: .. code-block:: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_lifecycle_configuration(Bucket, Rules, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the Lifecycle rules for a bucket. Returns {updated: true} if Lifecycle was updated and returns {updated: False} if Lifecycle was not updated. CLI ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_logging(Bucket, TargetBucket=None, TargetPrefix=None, TargetGrants=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the logging parameters for a bucket. Returns {updated: true} if parameters were updated and returns {updated: False} ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_notification_configuration(Bucket, TopicConfigurations=None, QueueConfigurations=None, LambdaFunctionConfigurations=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the notification parameters for a bucket. Returns {updated: t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_policy(Bucket, Policy, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the policy for a bucket. Returns {updated: true} if policy was updated and returns {updated: False} if policy was not updated. CLI 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 put_replication(Bucket, Role, Rules, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the replication configuration for a bucket. Returns {updated: true} if replication configuration was updated and returns {updated: False} if replication configuration w...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_request_payment(Bucket, Payer, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the request payment configuration for a bucket. Returns {updated: true} if request payment configuration was updated and returns {updated: False} if request payment confi...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_tagging(Bucket, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Given a valid config, update the tags for a bucket. Returns {updated: true} if tags were updated and returns {updated: False} if tags were not updated. CLI 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 put_versioning(Bucket, Status, MFADelete=None, MFA=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the versioning configuration for a bucket. Returns {updated: true} if versioning configuration was updated and returns {updated: False} if versionin...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def put_website(Bucket, ErrorDocument=None, IndexDocument=None, RedirectAllRequestsTo=None, RoutingRules=None, region=None, key=None, keyid=None, profile=None): ''' Given a valid config, update the website configuration for a bucket. Returns {updated: true} if website configuration wa...
<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_cors(Bucket, region=None, key=None, keyid=None, profile=None): ''' Delete the CORS configuration for the given bucket Returns {deleted: true} if CORS was deleted and returns {deleted: False} if CORS was not deleted. CLI Example: .. code-block:: bash salt myminio...
<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_lifecycle_configuration(Bucket, region=None, key=None, keyid=None, profile=None): ''' Delete the lifecycle configuration for the given bucket Returns {deleted: true} if Lifecycle was deleted and returns {deleted: False} if Lifecycle was not deleted. CLI Example: .. code-...
<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_replication(Bucket, region=None, key=None, keyid=None, profile=None): ''' Delete the replication config from the given bucket Returns {deleted: true} if replication configuration was deleted and returns {deleted: False} if replication configuration was not deleted. CLI Exampl...
<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_tagging(Bucket, region=None, key=None, keyid=None, profile=None): ''' Delete the tags from the given bucket Returns {deleted: true} if tags were deleted and returns {deleted: False} if tags were not deleted. CLI Example: .. code-block:: bash salt myminion boto_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 delete_website(Bucket, region=None, key=None, keyid=None, profile=None): ''' Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: ....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def user_is_blacklisted(self, user): ''' Takes a username as a string and returns a boolean. True indicates that the provided user has been blacklisted ''' return not salt.utils.stringutils.check_whitelist_blacklist(user, blacklist=self.blacklist.get('users', []))
<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(profile='pagerduty', subdomain=None, api_key=None, **kwargs): ''' Ensure that a pagerduty escalation policy exists. Will create or update as needed. This method accepts as args everything defined in https://developer.pagerduty.com/documentation/rest/escalation_policies/create. In addit...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _escalation_rules_to_string(escalation_rules): 'convert escalation_rules dict to a string for comparison' result = '' for rule in escalation_rules: result += 'escalation_delay_in_minutes: {0} '.format(rule['escalation_delay_in_minutes']) for target in rule['targets']: result ...
<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_perms_changes(name, newperms, runas=None, existing=None): ''' Check whether Rabbitmq user's permissions need to be changed. ''' if not newperms: return False if existing is None: try: existing = __salt__['rabbitmq.list_user_permissions'](name, runas=runas) ...
<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_current_tags(name, runas=None): ''' Whether Rabbitmq user's tags need to be changed ''' try: return list(__salt__['rabbitmq.list_users'](runas=runas)[name]) except CommandExecutionError as err: log.error('Error: %s', err) return []
<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(name, runas=None): ''' Ensure the named user is absent name The name of the user to remove runas User to run the command ''' ret = {'name': name, 'result': False, 'comment': '', 'changes': {}} try: user_exists = __salt__['rabbitmq.user_exists']...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def pause(jid, state_id=None, duration=None): ''' Set up a state id pause, this instructs a running state to pause at a given state id. This needs to pass in the jid of the running state and can optionally pass in a duration in seconds. ''' minion = salt.minion.MasterMinion(__opts__) minion....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def resume(jid, state_id=None): ''' Remove a pause from a jid, allowing it to continue ''' minion = salt.minion.MasterMinion(__opts__) minion.functions['state.resume'](jid, state_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 orchestrate_show_sls(mods, saltenv='base', test=None, queue=False, pillar=None, pillarenv=None, pillar_enc=None): ''' Display the state data from a specific 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 add_distinguished_name(list_name, item_name): ''' Adds a distinguished name to a distinguished name list. list_name(str): The name of the specific policy distinguished name list to append to. item_name(str): The distinguished name to append. CLI Example: .. code-block:: bash sal...
<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_distinguished_name_list(list_name): ''' Add a list of policy distinguished names. list_name(str): The name of the specific policy distinguished name list to add. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.add_distinguished_name_list MyDistinguishedList ''' ...
<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_domain_name(list_name, item_name): ''' Adds a domain name to a domain name list. list_name(str): The name of the specific policy domain name list to append to. item_name(str): The domain name to append. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.add_domain_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 add_domain_name_list(list_name): ''' Add a list of policy domain names. list_name(str): The name of the specific policy domain name list to add. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.add_domain_name_list MyDomainNameList ''' payload = {"jsonrpc": "2.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 add_ip_address(list_name, item_name): ''' Add an IP address to an IP address list. list_name(str): The name of the specific policy IP address list to append to. item_name(str): The IP address to append to the list. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.add_ip_...
<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_ip_address_list(list_name): ''' Retrieves a list of all IP address lists. list_name(str): The name of the specific IP address list to add. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.add_ip_address_list MyIPAddressList ''' payload = {"jsonrpc": "2.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 get_distinguished_name_list(list_name): ''' Retrieves a specific policy distinguished name list. list_name(str): The name of the specific policy distinguished name list to retrieve. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.get_distinguished_name_list MyDistinguishedLi...
<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_domain_list(list_name): ''' Retrieves a specific policy domain name list. list_name(str): The name of the specific policy domain name list to retrieve. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.get_domain_list MyDomainNameList ''' payload = {"jsonrpc": "2....
<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_ip_address_list(list_name): ''' Retrieves a specific IP address list. list_name(str): The name of the specific policy IP address list to retrieve. CLI Example: .. code-block:: bash salt '*' bluecoat_sslv.get_ip_address_list MyIPAddressList ''' payload = {"jsonrpc": "2.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 runas_unpriv(cmd, username, password, cwd=None): ''' Runas that works for non-priviledged users ''' # Create a pipe to set as stdout in the child. The write handle needs to be # inheritable. c2pread, c2pwrite = salt.platform.win.CreatePipe( inherit_read=False, inherit_write=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 match(tgt, functions=None, opts=None): ''' Match based on the local data store on the minion ''' if not opts: opts = __opts__ if functions is None: utils = salt.loader.utils(opts) functions = salt.loader.minion_mods(opts, utils=utils) comps = tgt.split(':') if len...
<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_record(table, sys_id): ''' Delete an existing record :param table: The table name, e.g. sys_user :type table: ``str`` :param sys_id: The unique ID of the record :type sys_id: ``str`` CLI Example: .. code-block:: bash salt myminion servicenow.delete_record sys_co...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def update_record_field(table, sys_id, field, value): ''' Update the value of a record's field in a servicenow table :param table: The table name, e.g. sys_user :type table: ``str`` :param sys_id: The unique ID of the record :type sys_id: ``str`` :param field: The new value :type 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 _parse_pkg_string(pkg): ''' Parse pkg string and return a tuple of package name, separator, and package version. Cabal support install package with following format: * foo-1.0 * foo < 1.2 * foo > 1.3 For the sake of simplicity only the first form is supported, support for othe...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def removed(name, user=None, env=None): ''' Verify that given package is not installed. ''' ret = {'name': name, 'result': None, 'comment': '', 'changes': {}} try: installed_pkgs = __salt__['cabal.list']( user=user, installed=True, env=env) except (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 beacon(config): ''' Scan for the configured services and fire events Example Config .. code-block:: yaml beacons: service: - services: salt-master: {} mysql: {} The config above sets up beacons to check for the salt-master and...
<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_issue(project, summary, description, template_engine='jinja', context=None, defaults=None, saltenv='base', issuetype='Bug', priority='Normal', labels=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 assign_issue(issue_key, assignee, server=None, username=None, password=None): ''' Assign the issue to an existing user. Return ``True`` when the issue has been properly assigned. issue_key The JIRA ID of the ticket to manip...
<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_comment(issue_key, comment, visibility=None, is_internal=False, server=None, username=None, password=None): ''' Add a comment to an existing ticket. Return ``True`` when it successfully added the comment....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def issue_closed(issue_key, server=None, username=None, password=None): ''' Check if the issue is closed. issue_key The JIRA iD of the ticket to close. Returns: - ``True``: the ticket exists and it is closed. - ``False``: the ticket e...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _remove_complex_types(dictionary): ''' Linode-python is now returning some complex types that are not serializable by msgpack. Kill those. ''' for k, v in six.iteritems(dictionary): if isinstance(v, dict): dictionary[k] = _remove_complex_types(v) elif hasattr(v, 'to_...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def run(**kwargs): ''' Run a single module function or a range of module functions in a batch. Supersedes ``module.run`` function, which requires ``m_`` prefix to function-specific parameters. :param returner: Specify a common returner for the whole batch to send the return data :param...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _call_function(name, returner=None, **kwargs): ''' Calls a function from the specified module. :param name: :param kwargs: :return: ''' argspec = salt.utils.args.get_function_argspec(__salt__[name]) # func_kw is initialized to a dictionary of keyword arguments the function to be ru...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def match(tgt, opts=None): ''' Determines if this host is on the list ''' if not opts: opts = __opts__ try: if ',' + opts['id'] + ',' in tgt \ or tgt.startswith(opts['id'] + ',') \ or tgt.endswith(',' + opts['id']): return True # t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def db_list(user=None, password=None, host=None, port=None): ''' List all InfluxDB databases user The user to connect as password The password of the user host The host to connect to port The port to connect to CLI 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 db_exists(name, user=None, password=None, host=None, port=None): ''' Checks if a database exists in Influxdb name Database name to create user The user to connect as password The password of the user host The host to connect to port The port t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def db_create(name, user=None, password=None, host=None, port=None): ''' Create a database name Database name to create user The user to connect as password The password of the user host The host to connect to port The port to connect to CLI ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def db_remove(name, user=None, password=None, host=None, port=None): ''' Remove a database name Database name to remove user The user to connect as password The password of the user host The host to connect to port The port to connect to CLI ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def user_list(database=None, user=None, password=None, host=None, port=None): ''' List cluster admins or database users. If a database is specified: it will return database users list. If a database is not specified: it will return cluster admins list. database The database to list the use...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def user_exists(name, database=None, user=None, password=None, host=None, port=None): ''' Checks if a cluster admin or database user exists. If a database is specified: it will check for database user existence. If a database is not specified: it will check for cluster admin existence. 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 user_create(name, passwd, database=None, user=None, password=None, host=None, port=None): ''' Create a cluster admin or a database user. If a database is specified: it will create database user. If a dat...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def user_chpass(name, passwd, database=None, user=None, password=None, host=None, port=None): ''' Change password for a cluster admin or a database user. If a database is specified: it will update database user ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def user_remove(name, database=None, user=None, password=None, host=None, port=None): ''' Remove a cluster admin or a database user. If a database is specified: it will remove the database user. If a database is not specifi...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def retention_policy_exists(database, name, user=None, password=None, host=None, port=None): ''' Check if a retention policy exists. database The database to o...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def retention_policy_add(database, name, duration, replication, default=False, user=None, password=None, host=None, port...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def retention_policy_alter(database, name, duration, replication, default=False, user=None, password=None, host=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 sync_with_handlers(self, handlers=()): ''' Sync the stored log records to the provided log handlers. ''' if not handlers: return while self.__messages: record = self.__messages.pop(0) for handler in handlers: if handler.lev...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def handleError(self, record): ''' Override the default error handling mechanism for py3 Deal with syslog os errors when the log file does not exist ''' handled = False if sys.stderr and sys.version_info >= (3, 5, 4): t, v, tb = sys.exc_info() if t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def handleError(self, record): ''' Override the default error handling mechanism Deal with log file rotation errors due to log file in use more softly. ''' handled = False # Can't use "salt.utils.platform.is_windows()" in this file if (sys.platform.start...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def beacon(config): ''' Return status for requested information ''' log.debug(config) ctime = datetime.datetime.utcnow().isoformat() if not config: config = [{ 'loadavg': ['all'], 'cpustats': ['all'], 'meminfo': ['all'], 'vmstats': ['all']...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def opts(): ''' Return the minion configuration settings ''' if __opts__.get('grain_opts', False) or \ (isinstance(__pillar__, dict) and __pillar__.get('grain_opts', False)): return __opts__ return {}
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _wrapper(orig, pre='', post='', err_=None, run_args=None, **kwargs): ''' Helper function that wraps the execution of freebsd-update command. orig: Originating function that called _wrapper(). pre: String that will be prepended to freebsd-update command. post: String th...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def uninstalled(name): ''' Ensure that the named package is not installed. Args: name (str): The flatpak package. Returns: dict: The ``result`` and ``output``. Example: .. code-block:: yaml uninstall_package: flatpack.uninstalled: - name: gimp ...
<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_nictags(include_etherstubs=True): ''' List all nictags include_etherstubs : boolean toggle include of etherstubs CLI Example: .. code-block:: bash salt '*' nictagadm.list ''' ret = {} cmd = 'nictagadm list -d "|" -p{0}'.format( ' -L' if not include_et...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def vms(nictag): ''' List all vms connect to nictag nictag : string name of nictag CLI Example: .. code-block:: bash salt '*' nictagadm.vms admin ''' ret = {} cmd = 'nictagadm vms {0}'.format(nictag) res = __salt__['cmd.run_all'](cmd) retcode = res['retcode'] ...
<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(*nictag, **kwargs): ''' Check if nictags exists nictag : string one or more nictags to check verbose : boolean return list of nictags CLI Example: .. code-block:: bash salt '*' nictagadm.exists admin ''' ret = {} if not nictag: return {'...
<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(name, mac, mtu=1500): ''' Add a new nictag name : string name of new nictag mac : string mac of parent interface or 'etherstub' to create a ether stub mtu : int MTU (ignored for etherstubs) CLI Example: .. code-block:: bash salt '*' nictagadm.add 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 update(name, mac=None, mtu=None): ''' Update a nictag name : string name of nictag mac : string optional new mac for nictag mtu : int optional new MTU for nictag CLI Example: .. code-block:: bash salt '*' nictagadm.update trunk mtu=9000 ''' ret...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def _query(lamp_id, state, action='', method='GET'): ''' Query the URI :return: ''' # Because salt.utils.query is that dreadful... :( err = None url = "{0}/lights{1}".format(CONFIG['uri'], lamp_id and '/{0}'.format(lamp_id) or '') \ + (action and ...
<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(lamp_id, state, method="state"): ''' Set state to the device by ID. :param lamp_id: :param state: :return: ''' try: res = _query(lamp_id, state, action=method, method='PUT') except Exception as err: raise CommandExecutionError(err) res = len(res) > 1 and re...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def call_lights(*args, **kwargs): ''' Get info about all available lamps. Options: * **id**: Specifies a device ID. Can be a comma-separated values. All, if omitted. CLI Example: .. code-block:: bash salt '*' hue.lights salt '*' hue.lights id=1 salt '*' hue.lights 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 call_blink(*args, **kwargs): ''' Blink a lamp. If lamp is ON, then blink ON-OFF-ON, otherwise OFF-ON-OFF. Options: * **id**: Specifies a device ID. Can be a comma-separated values. All, if omitted. * **pause**: Time in seconds. Can be less than 1, i.e. 0.7, 0.5 sec. CLI Example: .. 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 call_ping(*args, **kwargs): ''' Ping the lamps by issuing a short inversion blink to all available devices. CLI Example: .. code-block:: bash salt '*' hue.ping ''' errors = dict() for dev_id, dev_status in call_blink().items(): if not dev_status['result']: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def call_status(*args, **kwargs): ''' Return the status of the lamps. Options: * **id**: Specifies a device ID. Can be a comma-separated values. All, if omitted. CLI Example: .. code-block:: bash salt '*' hue.status salt '*' hue.status id=1 salt '*' hue.status id=1,2...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def call_rename(*args, **kwargs): ''' Rename a device. Options: * **id**: Specifies a device ID. Only one device at a time. * **title**: Title of the device. CLI Example: .. code-block:: bash salt '*' hue.rename id=1 title='WC for cats' ''' dev_id = _get_devices(kwargs) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def call_color(*args, **kwargs): ''' Set a color to the lamp. Options: * **id**: Specifies a device ID. Can be a comma-separated values. All, if omitted. * **color**: Fixed color. Values are: red, green, blue, orange, pink, white, yellow, daylight, purple. Default white. * **t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def call_brightness(*args, **kwargs): ''' Set an effect to the lamp. Arguments: * **value**: 0~255 brightness of the lamp. Options: * **id**: Specifies a device ID. Can be a comma-separated values. All, if omitted. * **transition**: Transition 0~200. Default 0. CLI Example: .. ...
<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_branch(repo, name): ''' Find the requested branch in the specified repo ''' try: return [x for x in _all_branches(repo) if x[0] == name][0] except IndexError: return False
<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_bookmark(repo, name): ''' Find the requested bookmark in the specified repo ''' try: return [x for x in _all_bookmarks(repo) if x[0] == name][0] except IndexError: return False
<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_tag(repo, name): ''' Find the requested tag in the specified repo ''' try: return [x for x in _all_tags(repo) if x[0] == name][0] except IndexError: return False
<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_ref(repo, name): ''' Return ref tuple if ref is in the repo. ''' if name == 'base': name = repo['base'] if name == repo['base'] or name in envs(): if repo['branch_method'] == 'branches': return _get_branch(repo['repo'], name) \ or _get_tag(repo['r...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def update(): ''' Execute an hg pull on all of the repos ''' # data for the fileserver event data = {'changed': False, 'backend': 'hgfs'} # _clear_old_remotes runs init(), so use the value from there to avoid a # second init() data['changed'], repos = _clear_old_remotes() ...
<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_file_list(load): ''' Get a list of all files on the file server in a specified environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'saltenv' not in load or load['saltenv'] not in envs(): return [] ret = set() for rep...
<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_dir_list(load): ''' Get a list of all directories on the master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'saltenv' not in load or load['saltenv'] not in envs(): return [] ret = set() for repo in init(): repo['...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def factory(opts, **kwargs): ''' Creates and returns the cache class. If memory caching is enabled by opts MemCache class will be instantiated. If not Cache class will be returned. ''' if opts.get('memcache_expire_seconds', 0): cls = MemCache else: cls = Cache return cls(...