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_file_systems(filesystemid=None,
keyid=None,
key=None,
profile=None,
region=None,
creation_token=None,
**kwargs):
'''
Get all EFS properties or a specific instance property
if... |
<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_mount_targets(filesystemid=None,
mounttargetid=None,
keyid=None,
key=None,
profile=None,
region=None,
**kwargs):
'''
Get all the EFS mount point properties for a specific 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 get_tags(filesystemid,
keyid=None,
key=None,
profile=None,
region=None,
**kwargs):
'''
Return the tags associated with an EFS instance.
filesystemid
(string) - ID of the file system whose tags to list
returns
(list) -... |
<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_security_groups(mounttargetid,
securitygroup,
keyid=None,
key=None,
profile=None,
region=None,
**kwargs):
'''
Modifies the set of security groups in effect for ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def installed(name, source):
'''
Ensure an update is installed on the minion
Args:
name(str):
Name of the Windows KB ("KB123456")
source (str):
Source of .msu file corresponding to the KB
Example:
.. code-block:: yaml
KB123456:
wusa.ins... |
<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 an update is uninstalled from the minion
Args:
name(str):
Name of the Windows KB ("KB123456")
Example:
.. code-block:: yaml
KB123456:
wusa.uninstalled
'''
ret = {'name': name,
'changes': {},
'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 list_cidr_ips(cidr):
'''
Get a list of IP addresses from a CIDR.
CLI example::
salt myminion netaddress.list_cidr_ips 192.168.0.0/20
'''
ips = netaddr.IPNetwork(cidr)
return [six.text_type(ip) for ip in list(ips)] |
<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_cidr_ips_ipv6(cidr):
'''
Get a list of IPv6 addresses from a CIDR.
CLI example::
salt myminion netaddress.list_cidr_ips_ipv6 192.168.0.0/20
'''
ips = netaddr.IPNetwork(cidr)
return [six.text_type(ip.ipv6()) for ip in list(ips)] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def cidr_netmask(cidr):
'''
Get the netmask address associated with a CIDR address.
CLI example::
salt myminion netaddress.cidr_netmask 192.168.0.0/20
'''
ips = netaddr.IPNetwork(cidr)
return six.text_type(ips.netmask) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def cidr_broadcast(cidr):
'''
Get the broadcast address associated with a CIDR address.
CLI example::
salt myminion netaddress.cidr_netmask 192.168.0.0/20
'''
ips = netaddr.IPNetwork(cidr)
return six.text_type(ips.broadcast) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def restart_service(service_name, minimum_running_time=None):
'''
Restart OpenStack service immediately, or only if it's running longer than
specified value
CLI Example:
.. code-block:: bash
salt '*' openstack_mng.restart_service neutron
salt '*' openstack_mng.restart_service neut... |
<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_serv(ret=None, commit=False):
'''
Return a mysql cursor
'''
_options = _get_options(ret)
connect = True
if __context__ and 'mysql_returner_conn' in __context__:
try:
log.debug('Trying to reuse MySQL connection pool')
conn = __context__['mysql_returner_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 returner(ret):
'''
Return data to a mysql server
'''
# if a minion is returning a standalone job, get a jobid
if ret['jid'] == 'req':
ret['jid'] = prep_jid(nocache=ret.get('nocache', False))
save_load(ret['jid'], ret)
try:
with _get_serv(ret, commit=True) as cur:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def event_return(events):
'''
Return event to mysql server
Requires that configuration be enabled via 'event_return'
option in master config.
'''
with _get_serv(events, commit=True) as cur:
for event in events:
tag = event.get('tag', '')
data = event.get('data', ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _verify_options(options):
'''
Verify options and log warnings
Returns True if all options can be verified,
otherwise False
'''
# sanity check all vals used for bitwise operations later
bitwise_args = [('level', options['level']),
('facility', options['facility'])
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def returner(ret):
'''
Return data to the local syslog
'''
_options = _get_options(ret)
if not _verify_options(_options):
return
# Get values from syslog module
level = getattr(syslog, _options['level'])
facility = getattr(syslog, _options['facility'])
# parse for syslog ... |
<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_running(self):
'''
Check if a pid file exists and if it is associated with
a running process.
'''
if self.check_pidfile():
pid = self.get_pidfile()
if not salt.utils.platform.is_windows():
if self.check_pidfile() and self.is_daem... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def coalesce(name, **kwargs):
'''
Manage coalescing settings of network device
name
Interface name to apply coalescing settings
.. code-block:: yaml
eth0:
ethtool.coalesce:
- name: eth0
- adaptive_rx: on
- adaptive_tx: on
- rx_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def datacenter_configured(name):
'''
Makes sure a datacenter exists.
If the state is run by an ``esxdatacenter`` minion, the name of the
datacenter is retrieved from the proxy details, otherwise the datacenter
has the same name as the state.
Supported proxies: esxdatacenter
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 _container_path(model,
key=None,
container=None,
delim=DEFAULT_TARGET_DELIM):
'''
Generate all the possible paths within an OpenConfig-like object.
This function returns a generator.
'''
if not key:
key = ''
if not container... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def defaults(model,
defaults_,
delim='//',
flipped_merge=False):
'''
Apply the defaults to a Python dictionary having the structure as described
in the OpenConfig standards.
model
The OpenConfig model to apply the defaults to.
defaults
The dic... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def installed(name,
features=None,
recurse=False,
restart=False,
source=None,
exclude=None):
'''
Install the windows feature. To install a single feature, use the ``name``
parameter. To install multiple features, use the ``features`` para... |
<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, features=None, remove_payload=False, restart=False):
'''
Remove the windows feature To remove a single feature, use the ``name``
parameter. To remove multiple features, use the ``features`` parameter.
Args:
name (str):
Short name of the feature (the right column in... |
<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_cors_origin(origin, allowed_origins):
'''
Check if an origin match cors allowed origins
'''
if isinstance(allowed_origins, list):
if origin in allowed_origins:
return origin
elif allowed_origins == '*':
return allowed_origins
elif allowed_origins == origin:... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def clean_by_request(self, request):
'''
Remove all futures that were waiting for request `request` since it is done waiting
'''
if request not in self.request_map:
return
for tag, matcher, future in self.request_map[request]:
# timeout the future
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _timeout_future(self, tag, matcher, future):
'''
Timeout a specific future
'''
if (tag, matcher) not in self.tag_map:
return
if not future.done():
future.set_exception(TimeoutException())
self.tag_map[(tag, matcher)].remove(future)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _handle_event_socket_recv(self, raw):
'''
Callback for events on the event sub socket
'''
mtag, data = self.event.unpack(raw, self.event.serial)
# see if we have any futures that need this info:
for (tag, matcher), futures in six.iteritems(self.tag_map):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _verify_client(self, low):
'''
Verify that the client is in fact one we have
'''
if 'client' not in low or low.get('client') not in self.saltclients:
self.set_status(400)
self.write("400 Invalid Client: Client not found in salt clients")
self.finis... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def initialize(self):
'''
Initialize the handler before requests are called
'''
if not hasattr(self.application, 'event_listener'):
log.debug('init a listener')
self.application.event_listener = EventListener(
self.application.mod_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 token(self):
'''
The token used for the request
'''
# find the token (cookie or headers)
if AUTH_TOKEN_HEADER in self.request.headers:
return self.request.headers[AUTH_TOKEN_HEADER]
else:
return self.get_cookie(AUTH_COOKIE_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 _verify_auth(self):
'''
Boolean whether the request is auth'd
'''
return self.token and bool(self.application.auth.get_tok(self.token)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def serialize(self, data):
'''
Serlialize the output based on the Accept header
'''
self.set_header('Content-Type', self.content_type)
return self.dumper(data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _form_loader(self, _):
'''
function to get the data from the urlencoded forms
ignore the data passed in and just get the args from wherever they are
'''
data = {}
for key in self.request.arguments:
val = self.get_arguments(key)
if len(val) == 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 deserialize(self, data):
'''
Deserialize the data based on request content type headers
'''
ct_in_map = {
'application/x-www-form-urlencoded': self._form_loader,
'application/json': salt.utils.json.loads,
'application/x-yaml': salt.utils.yaml.safe_... |
<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_lowstate(self):
'''
Format the incoming data into a lowstate object
'''
if not self.request.body:
return
data = self.deserialize(self.request.body)
self.request_payload = copy(data)
if data and 'arg' in data and not isinstance(data['arg'], li... |
<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_default_headers(self):
'''
Set default CORS headers
'''
mod_opts = self.application.mod_opts
if mod_opts.get('cors_origin'):
origin = self.request.headers.get('Origin')
allowed_origin = _check_cors_origin(origin, mod_opts['cors_origin'])
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def options(self, *args, **kwargs):
'''
Return CORS headers for preflight requests
'''
# Allow X-Auth-Token in requests
request_headers = self.request.headers.get('Access-Control-Request-Headers')
allowed_headers = request_headers.split(',')
# Filter allowed head... |
<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(self):
'''
All logins are done over post, this is a parked endpoint
.. http:get:: /login
:status 401: |401|
:status 406: |406|
**Example request:**
.. code-block:: bash
curl -i localhost:8000/login
.. code-block:: text
... |
<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(self):
'''
An endpoint to determine salt-api capabilities
.. http:get:: /
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|
:status 406: |406|
**Example request:**
.. code-block:: bash
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 disbatch(self):
'''
Disbatch all lowstates to the appropriate clients
'''
ret = []
# check clients before going, we want to throw 400 if one is bad
for low in self.lowstate:
if not self._verify_client(low):
return
# Make sure ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _disbatch_local_async(self, chunk):
'''
Disbatch local client_async commands
'''
f_call = self._format_call_run_job_async(chunk)
# fire a job off
pub_data = yield self.saltclients['local_async'](*f_call.get('args', ()), **f_call.get('kwargs', {}))
raise torna... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _disbatch_runner(self, chunk):
'''
Disbatch runner client commands
'''
full_return = chunk.pop('full_return', False)
pub_data = self.saltclients['runner'](chunk)
tag = pub_data['tag'] + '/ret'
try:
event = yield self.application.event_listener.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 _disbatch_runner_async(self, chunk):
'''
Disbatch runner client_async commands
'''
pub_data = self.saltclients['runner'](chunk)
raise tornado.gen.Return(pub_data) |
<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):
'''
Ensure user account is absent
name : string
username
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
# remove if needed
if name in __salt__['pdbedit.list'](False):
res = __salt__['pdbedit.delete']... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def managed(name, **kwargs):
'''
Manage user account
login : string
login name
password : string
password
password_hashed : boolean
set if password is a nt hash instead of plain text
domain : string
users domain
profile : string
profile path
scrip... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _write_proxy_conf(proxyfile):
'''
write to file
'''
msg = 'Invalid value for proxy file provided!, Supplied value = {0}' \
.format(proxyfile)
log.trace('Salt Proxy Module: write proxy conf')
if proxyfile:
log.debug('Writing proxy conf file')
with salt.utils.files.fo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _proxy_conf_file(proxyfile, test):
'''
Check if proxy conf exists and update
'''
changes_old = []
changes_new = []
success = True
if not os.path.exists(proxyfile):
try:
if not test:
changes_new.append(_write_proxy_conf(proxyfile))
msg =... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _is_proxy_running(proxyname):
'''
Check if proxy for this name is running
'''
cmd = ('ps ax | grep "salt-proxy --proxyid={0}" | grep -v grep'
.format(salt.ext.six.moves.shlex_quote(proxyname)))
cmdout = __salt__['cmd.run_all'](
cmd,
timeout=5,
python_shell=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 _proxy_process(proxyname, test):
'''
Check and execute proxy process
'''
changes_old = []
changes_new = []
if not _is_proxy_running(proxyname):
if not test:
__salt__['cmd.run_all'](
'salt-proxy --proxyid={0} -l info -d'.format(salt.ext.six.moves.shlex_quot... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def process_minion_update(self, event_data):
'''
Associate grains data with a minion and publish minion update
'''
tag = event_data['tag']
event_info = event_data['data']
mid = tag.split('/')[-1]
if not self.minions.get(mid, None):
self.minions[mid] ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def process_new_job_event(self, event_data):
'''
Creates a new job with properties from the event data
like jid, function, args, timestamp.
Also sets the initial state to started.
Minions that are participating in this job are also noted.
'''
job = 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 wait_for(func, timeout=10, step=1, default=None, func_args=(), func_kwargs=None):
'''
Call `func` at regular intervals and Waits until the given function returns
a truthy value within the given timeout and returns that value.
@param func:
@type func: function
@param timeout:
@type timeo... |
<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_enabled():
'''
Return a list of service that are enabled on boot
CLI Example:
.. code-block:: bash
salt '*' service.get_enabled
'''
prefix = '/etc/rc[S{0}].d/S'.format(_get_runlevel())
ret = set()
lines = glob.glob('{0}*'.format(prefix))
for line in lines:
... |
<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_kwargs(profile=None, **connection_args):
'''
get connection args
'''
if profile:
prefix = profile + ":keystone."
else:
prefix = "keystone."
def get(key, default=None):
'''
look in connection_args first, then default to config file
'''
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 api_version(profile=None, **connection_args):
'''
Returns the API version derived from endpoint's response.
CLI Example:
.. code-block:: bash
salt '*' keystone.api_version
'''
kwargs = _get_kwargs(profile=profile, **connection_args)
auth_url = kwargs.get('auth_url', kwargs.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 auth(profile=None, **connection_args):
'''
Set up keystone credentials. Only intended to be used within Keystone-enabled modules.
CLI Example:
.. code-block:: bash
salt '*' keystone.auth
'''
__utils__['versions.warn_until'](
'Neon',
(
'The keystone modu... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def ec2_credentials_create(user_id=None, name=None,
tenant_id=None, tenant=None,
profile=None, **connection_args):
'''
Create EC2-compatible credentials for user per tenant
CLI Examples:
.. code-block:: bash
salt '*' keystone.ec2_credentia... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def ec2_credentials_delete(user_id=None, name=None, access_key=None,
profile=None, **connection_args):
'''
Delete EC2-compatible credentials
CLI Examples:
.. code-block:: bash
salt '*' keystone.ec2_credentials_delete \
860f8c2c38ca4fab989f9bc56a061a64 access... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def endpoint_create(service, publicurl=None, internalurl=None, adminurl=None,
region=None, profile=None, url=None, interface=None, **connection_args):
'''
Create an endpoint for an Openstack service
CLI Examples:
.. code-block:: bash
salt 'v2' keystone.endpoint_create nova... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def endpoint_delete(service, region=None, profile=None, interface=None, **connection_args):
'''
Delete endpoints of an Openstack service
CLI Examples:
.. code-block:: bash
salt 'v2' keystone.endpoint_delete nova [region=RegionOne]
salt 'v3' keystone.endpoint_delete nova interface=adm... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def role_create(name, profile=None, **connection_args):
'''
Create a named role.
CLI Example:
.. code-block:: bash
salt '*' keystone.role_create admin
'''
kstone = auth(profile, **connection_args)
if 'Error' not in role_get(name=name, profile=profile, **connection_args):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def service_create(name, service_type, description=None, profile=None,
**connection_args):
'''
Add service to Keystone service catalog
CLI Examples:
.. code-block:: bash
salt '*' keystone.service_create nova compute \
'OpenStack Compute Service'
'''
kstone = auth(pr... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def service_delete(service_id=None, name=None, profile=None, **connection_args):
'''
Delete a service from Keystone service catalog
CLI Examples:
.. code-block:: bash
salt '*' keystone.service_delete c965f79c4f864eaaa9c3b41904e67082
salt '*' keystone.service_delete name=nova
'''
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def tenant_create(name, description=None, enabled=True, profile=None,
**connection_args):
'''
Create a keystone tenant
CLI Examples:
.. code-block:: bash
salt '*' keystone.tenant_create nova description='nova tenant'
salt '*' keystone.tenant_create test enabled=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 user_verify_password(user_id=None, name=None, password=None,
profile=None, **connection_args):
'''
Verify a user's password
CLI Examples:
.. code-block:: bash
salt '*' keystone.user_verify_password name=test password=foobar
salt '*' keystone.user_verify_pa... |
<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_ssh_config(lines):
'''
Parses lines from the SSH config to create roster targets.
:param lines: Individual lines from the ssh config file
:return: Dictionary of targets in similar style to the flat roster
'''
# transform the list of individual lines into a list of sublists where each
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def pack(self):
'''
Pack this exception into a serializable dictionary that is safe for
transport via msgpack
'''
if six.PY3:
return {'message': six.text_type(self), 'args': self.args}
return dict(message=self.__unicode__(), args=self.args) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def reactivate(domain_name):
'''
Try to reactivate the expired domain name
Returns the following information:
- Whether or not the domain was reactivated successfully
- The amount charged for reactivation
- The order ID
- The transaction ID
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 renew(domain_name, years, promotion_code=None):
'''
Try to renew the specified expiring domain name for a specified number of years
domain_name
The domain name to be renewed
years
Number of years to renew
Returns the following information:
- Whether or not the domain was ... |
<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(*domains_to_check):
'''
Checks the availability of domains
domains_to_check
array of strings List of domains to check
Returns a dictionary mapping the each domain name to a boolean denoting
whether or not it is available.
CLI Example:
.. code-block:: bash
salt... |
<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_info(domain_name):
'''
Returns information about the requested domain
returns a dictionary of information about the domain_name
domain_name
string Domain name to get information about
CLI Example:
.. code-block:: bash
salt 'my-minion' namecheap_domains.get_info my-d... |
<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_tld_list():
'''
Returns a list of TLDs as objects
CLI Example:
.. code-block:: bash
salt 'my-minion' namecheap_domains.get_tld_list
'''
response_xml = salt.utils.namecheap.get_request(salt.utils.namecheap.get_opts('namecheap.domains.gettldlist'))
if response_xml is 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 get_list(list_type=None,
search_term=None,
page=None,
page_size=None,
sort_by=None):
'''
Returns a list of domains for the particular user as a list of objects
offset by ``page`` length of ``page_size``
list_type : ALL
One of ``ALL``, ``EX... |
<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_status(m,
comment=INVALID_RESPONSE,
status=False,
out=None):
'''
Assign status data to a dict.
'''
m['out'] = out
m['status'] = status
m['logs'] = LOG.messages[:]
m['logs_by_level'] = LOG.by_level.copy()
outlog, outlog_by_level = '... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _invalid(m, comment=INVALID_RESPONSE, out=None):
'''
Return invalid status.
'''
return _set_status(m, status=False, comment=comment, out=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 _valid(m, comment=VALID_RESPONSE, out=None):
'''
Return valid status.
'''
return _set_status(m, status=True, comment=comment, out=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 _get_bootstrap_content(directory='.'):
'''
Get the current bootstrap.py script content
'''
try:
with salt.utils.files.fopen(os.path.join(
os.path.abspath(directory),
'bootstrap.py')) as fic:
oldcontent = salt.utils.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 _get_buildout_ver(directory='.'):
'''Check for buildout versions.
In any cases, check for a version pinning
Also check for buildout.dumppickedversions which is buildout1 specific
Also check for the version targeted by the local bootstrap file
Take as default buildout2
directory
dir... |
<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_bootstrap_url(directory):
'''
Get the most appropriate download URL for the bootstrap script.
directory
directory to execute in
'''
v = _get_buildout_ver(directory)
return _URL_VERSIONS.get(v, _URL_VERSIONS[DEFAULT_VER]) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def upgrade_bootstrap(directory='.',
onlyif=None,
unless=None,
runas=None,
env=(),
offline=False,
buildout_ver=None):
'''
Upgrade current bootstrap.py with the last released one.
... |
<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_buildout(directory='.',
config='buildout.cfg',
parts=None,
onlyif=None,
unless=None,
offline=False,
newest=True,
runas=None,
env=(),
verbose=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 buildout(directory='.',
config='buildout.cfg',
parts=None,
runas=None,
env=(),
buildout_ver=None,
test_release=False,
distribute=None,
new_st=None,
offline=False,
newest=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 ext_pillar(minion_id,
pillar,
*args,
**kwargs):
'''
Execute queries against SQLite3, merge and return as a dict
'''
return SQLite3ExtPillar().fetch(minion_id, pillar, *args, **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 ext_pillar(minion_id,
pillar, # pylint: disable=W0613
url,
with_grains=False):
'''
Read pillar data from HTTP response.
:param str url: Url to request.
:param bool with_grains: Whether to substitute strings in the url with their grain values.
:retu... |
<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_password(username, password, encrypted=False, **kwargs):
'''
Verify user password.
username
Username on which to perform password check
password
Password to check
encrypted
Whether or not the password is encrypted
Default: False
.. 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 get_roles(username, **kwargs):
'''
Get roles assigned to a username.
.. code-block: bash
salt '*' nxos.cmd get_roles username=admin
'''
user = get_user(username)
if not user:
return []
command = 'show user-account {0}'.format(username)
info = ''
info = show(comm... |
<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_user(username, **kwargs):
'''
Get username line from switch.
.. code-block: bash
salt '*' nxos.cmd get_user username=admin
'''
command = 'show run | include "^username {0} password 5 "'.format(username)
info = ''
info = show(command, **kwargs)
if isinstance(info, list):... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def show_ver(**kwargs):
'''
Shortcut to run `show version` on the NX-OS device.
.. code-block:: bash
salt '*' nxos.cmd show_ver
'''
command = 'show version'
info = ''
info = show(command, **kwargs)
if isinstance(info, list):
info = info[0]
return 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 show_run(**kwargs):
'''
Shortcut to run `show running-config` on the NX-OS device.
.. code-block:: bash
salt '*' nxos.cmd show_run
'''
command = 'show running-config'
info = ''
info = show(command, **kwargs)
if isinstance(info, list):
info = info[0]
return 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 delete_config(lines, **kwargs):
'''
Delete one or more config lines to the switch running config.
lines
Configuration lines to remove.
no_save_config
If True, don't save configuration commands to startup configuration.
If False, save configuration to startup configuration.
... |
<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_password(username,
password,
encrypted=False,
role=None,
crypt_salt=None,
algorithm='sha256',
**kwargs):
'''
Set users password on switch.
username
Username to configure
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 set_role(username, role, **kwargs):
'''
Assign role to username.
username
Username for role configuration
role
Configure role for username
no_save_config
If True, don't save configuration commands to startup configuration.
If False, save configuration to startu... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def unset_role(username, role, **kwargs):
'''
Remove role from username.
username
Username for role removal
role
Role to remove
no_save_config
If True, don't save configuration commands to startup configuration.
If False, save configuration to startup configuration... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _configure_device(commands, **kwargs):
'''
Helper function to send configuration commands to the device over a
proxy minion or native minion using NX-API or SSH.
'''
if salt.utils.platform.is_proxy():
return __proxy__['nxos.proxy_config'](commands, **kwargs)
else:
return _nxa... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _nxapi_config(commands, methods='cli_conf', bsb_arg=None, **kwargs):
'''
Helper function to send configuration commands using NX-API.
'''
api_kwargs = __salt__['config.get']('nxos', {})
api_kwargs.update(**kwargs)
if not isinstance(commands, list):
commands = [commands]
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 _nxapi_request(commands,
method='cli_conf',
**kwargs):
'''
Helper function to send exec and config requests over NX-API.
commands
The exec or config commands to be sent.
method: ``cli_show``
``cli_show_ascii``: Return raw test or unstructured 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 compress(data, compresslevel=9):
'''
Returns the data compressed at gzip level compression.
'''
buf = BytesIO()
with open_fileobj(buf, 'wb', compresslevel) as ogz:
if six.PY3 and not isinstance(data, bytes):
data = data.encode(__salt_system_encoding__)
ogz.write(data)... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _root(path, root):
'''
Relocate an absolute path to a new root directory.
'''
if root:
return os.path.join(root, os.path.relpath(path, os.path.sep))
else:
return path |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _canonical_unit_name(name):
'''
Build a canonical unit name treating unit names without one
of the valid suffixes as a service.
'''
if not isinstance(name, six.string_types):
name = six.text_type(name)
if any(name.endswith(suffix) for suffix in VALID_UNIT_TYPES):
return 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 _check_available(name):
'''
Returns boolean telling whether or not the named service is available
'''
_status = _systemctl_status(name)
sd_version = salt.utils.systemd.version(__context__)
if sd_version is not None and sd_version >= 231:
# systemd 231 changed the output of "systemctl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.