INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Return a dict containing the file lists for files and dirs | def _file_lists(self, load, form):
'''
Return a dict containing the file lists for files and dirs
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not os.path.isdir(self.file_list_cachedir):
try:
... |
Return a dict of all symlinks based on a given path in the repo | def symlink_list(self, load):
'''
Return a dict of all symlinks based on a given path in the repo
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not salt.utils.stringutils.is_hex(load['saltenv']) \
and lo... |
Checkout the targeted branches/tags from the git_pillar remotes | def checkout(self):
'''
Checkout the targeted branches/tags from the git_pillar remotes
'''
self.pillar_dirs = OrderedDict()
self.pillar_linked_dirs = []
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
... |
Ensure that the mountpoint is present in the correct location and
points at the correct path | def link_mountpoint(self, repo):
'''
Ensure that the mountpoint is present in the correct location and
points at the correct path
'''
lcachelink = salt.utils.path.join(repo.linkdir, repo._mountpoint)
lcachedest = salt.utils.path.join(repo.cachedir, repo.root()).rstrip(os.... |
Checkout the targeted branches/tags from the winrepo remotes | def checkout(self):
'''
Checkout the targeted branches/tags from the winrepo remotes
'''
self.winrepo_dirs = {}
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
self.winrepo_dirs[repo.id] = cachedir |
Check if the minion is exposed, based on the whitelist and blacklist | def _is_exposed(minion):
'''
Check if the minion is exposed, based on the whitelist and blacklist
'''
return salt.utils.stringutils.check_whitelist_blacklist(
minion,
whitelist=__opts__['minionfs_whitelist'],
blacklist=__opts__['minionfs_blacklist']
) |
Search the environment for the relative path | def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Search the environment for the relative path
'''
fnd = {'path': '', 'rel': ''}
if os.path.isabs(path):
return fnd
if tgt_env not in envs():
return fnd
if os.path.basename(path) == 'top.sls':
l... |
When we are asked to update (regular interval) lets reap the cache | def update():
'''
When we are asked to update (regular interval) lets reap the cache
'''
try:
salt.fileserver.reap_fileserver_cache_dir(
os.path.join(__opts__['cachedir'], 'minionfs/hash'),
find_file)
except os.error:
# Hash file won't exist if no files have y... |
Return a file hash, the hash type is set in the master config file | def file_hash(load, fnd):
'''
Return a file hash, the hash type is set in the master config file
'''
path = fnd['path']
ret = {}
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if load['saltenv'] not in envs():
return {}
# if the file... |
Return a list of all files on the file server in a specified environment | def file_list(load):
'''
Return 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 load['saltenv'] not in envs():
return []
mountpoint = salt.utils.url.strip_proto(__opts__['... |
Function to standardize the subprocess call | def _subprocess(cmd):
'''
Function to standardize the subprocess call
'''
log.debug('Running: "%s"', ' '.join(cmd))
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ret = salt.utils.stringutils.to_unicode(proc.communicate()[0]).strip()
retcode = proc.wait()
... |
Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down
and immediately restarts the Traffic Server node.
drain
This option modifies the restart behavior such that traffic_server
is not shut down until the number of active client connections
drops to the number given... | def bounce_local(drain=False):
'''
Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down
and immediately restarts the Traffic Server node.
drain
This option modifies the restart behavior such that traffic_server
is not shut down until the number of active client co... |
Restart the traffic_manager and traffic_server processes on the local node.
drain
This option modifies the restart behavior such that
``traffic_server`` is not shut down until the number of
active client connections drops to the number given by the
``proxy.config.restart.active_clie... | def restart_local(drain=False):
'''
Restart the traffic_manager and traffic_server processes on the local node.
drain
This option modifies the restart behavior such that
``traffic_server`` is not shut down until the number of
active client connections drops to the number given by th... |
Display the current values of all metrics whose names match the
given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_metric regex | def match_metric(regex):
'''
Display the current values of all metrics whose names match the
given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_metric regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('metric', 'match', regex... |
Display the current values of all configuration variables whose
names match the given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_config regex | def match_config(regex):
'''
Display the current values of all configuration variables whose
names match the given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_config regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('config'... |
Read Traffic Server configuration variable definitions.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out | def read_config(*args):
'''
Read Traffic Server configuration variable definitions.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out
'''
ret = {}
if _TRAFFICCTL:
cmd = _traffic_ctl('config', 'get')
... |
Set the value of a Traffic Server configuration variable.
variable
Name of a Traffic Server configuration variable.
value
The new value to set.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.set_config proxy.config.http.keep_alive_post_out 0 | def set_config(variable, value):
'''
Set the value of a Traffic Server configuration variable.
variable
Name of a Traffic Server configuration variable.
value
The new value to set.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.set_config pro... |
Mark a cache storage device as offline. The storage is identified by a path
which must match exactly a path specified in storage.config. This removes
the storage from the cache and redirects requests that would have used this
storage to other storage. This has exactly the same effect as a disk
failure f... | def offline(path):
'''
Mark a cache storage device as offline. The storage is identified by a path
which must match exactly a path specified in storage.config. This removes
the storage from the cache and redirects requests that would have used this
storage to other storage. This has exactly the same... |
Clear (acknowledge) an alarm event. The arguments are “all” for all current
alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier
(e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘).
.. code-block:: bash
salt '*' trafficserver.clear_alarms [all | #event | name] | def clear_alarms(alarm):
'''
Clear (acknowledge) an alarm event. The arguments are “all” for all current
alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier
(e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘).
.. code-block:: bash
salt '*' trafficserver.clear_alarms [all | #ev... |
Libcloud supported node states | def node_state(id_):
'''
Libcloud supported node states
'''
states_int = {
0: 'RUNNING',
1: 'REBOOTING',
2: 'TERMINATED',
3: 'PENDING',
4: 'UNKNOWN',
5: 'STOPPED',
6: 'SUSPENDED',
7: 'ERROR',
8: 'PAUSED'}
states_str = {
... |
Compare different libcloud versions | def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None):
'''
Compare different libcloud versions
'''
if not HAS_LIBCLOUD:
return False
if not isinstance(reqver, (list, tuple)):
raise RuntimeError(
'\'reqver\' needs to passed as a tuple or list, i.e., (0, 14... |
Return a libcloud node for the named VM | def get_node(conn, name):
'''
Return a libcloud node for the named VM
'''
nodes = conn.list_nodes()
for node in nodes:
if node.name == name:
__utils__['cloud.cache_node'](salt.utils.data.simple_types_filter(node.__dict__), __active_provider_name__, __opts__)
return no... |
Return a dict of all available VM locations on the cloud provider with
relevant data | def avail_locations(conn=None, call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the -... |
Return a dict of all available VM images on the cloud provider with
relevant data | def avail_images(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-ima... |
Return a dict of all available VM images on the cloud provider with
relevant data | def avail_sizes(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes... |
Return the location object to use | def get_location(conn, vm_):
'''
Return the location object to use
'''
locations = conn.list_locations()
vm_location = config.get_cloud_config_value('location', vm_, __opts__)
if not six.PY3:
vm_location = vm_location.encode(
'ascii', 'salt-cloud-force-ascii'
)
f... |
Return the image object to use | def get_image(conn, vm_):
'''
Return the image object to use
'''
images = conn.list_images()
vm_image = config.get_cloud_config_value('image', vm_, __opts__)
if not six.PY3:
vm_image = vm_image.encode('ascii', 'salt-cloud-force-ascii')
for img in images:
if isinstance(img.i... |
Return the VM's size object | def get_size(conn, vm_):
'''
Return the VM's size object
'''
sizes = conn.list_sizes()
vm_size = config.get_cloud_config_value('size', vm_, __opts__)
if not vm_size:
return sizes[0]
for size in sizes:
if vm_size and str(vm_size) in (str(size.id), str(size.name)): # pylint: ... |
Delete a single VM | def destroy(name, conn=None, call=None):
'''
Delete a single VM
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)
__utils__['cloud.fire_event'](
'event',
'destroy... |
Reboot a single VM | def reboot(name, conn=None):
'''
Reboot a single VM
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
node = get_node(conn, name)
if node is None:
log.error('Unable to find the VM %s', name)
log.info('Rebooting VM: %s', name)
ret = conn.reboot_node(node)
i... |
Return a list of the VMs that are on the provider | def list_nodes(conn=None, call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
if not conn:
conn = get_conn() # pylint: disable=E0... |
Return a list of the VMs that are on the provider, with all fields | def list_nodes_full(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with all fields
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
if not conn:
conn = get_co... |
Return a list of the VMs that are on the provider, with select fields | def list_nodes_select(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with select fields
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
return salt.utils.cloud.list_nodes_select(
list_nodes_full(conn, 'function'), __opts__['query.selection... |
Find if the provided connection object has a specific method | def conn_has_method(conn, method_name):
'''
Find if the provided connection object has a specific method
'''
if method_name in dir(conn):
return True
log.error('Method \'%s\' not yet supported!', method_name)
return False |
Checks if a database exists in InfluxDB.
name
Name of the database to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.db_exists <name> | def db_exists(name, **client_args):
'''
Checks if a database exists in InfluxDB.
name
Name of the database to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.db_exists <name>
'''
if name in [db['name'] for db in list_dbs(**client_args)]:
return True
... |
Create a database.
name
Name of the database to create.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_db <name> | def create_db(name, **client_args):
'''
Create a database.
name
Name of the database to create.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_db <name>
'''
if db_exists(name, **client_args):
log.info('DB \'%s\' already exists', name)
return Fa... |
Drop a database.
name
Name of the database to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_db <name> | def drop_db(name, **client_args):
'''
Drop a database.
name
Name of the database to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_db <name>
'''
if not db_exists(name, **client_args):
log.info('DB \'%s\' does not exist', name)
return False
... |
Get information about given user.
name
Name of the user for which to get information.
CLI Example:
.. code-block:: bash
salt '*' influxdb.user_info <name> | def user_info(name, **client_args):
'''
Get information about given user.
name
Name of the user for which to get information.
CLI Example:
.. code-block:: bash
salt '*' influxdb.user_info <name>
'''
matching_users = (user for user in list_users(**client_args)
... |
Create a user.
name
Name of the user to create.
passwd
Password of the new user.
admin : False
Whether the user should have cluster administration
privileges or not.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_user <name> <password>
... | def create_user(name, passwd, admin=False, **client_args):
'''
Create a user.
name
Name of the user to create.
passwd
Password of the new user.
admin : False
Whether the user should have cluster administration
privileges or not.
CLI Example:
.. code-block... |
Change password of a user.
name
Name of the user for whom to set the password.
passwd
New password of the user.
CLI Example:
.. code-block:: bash
salt '*' influxdb.set_user_password <name> <password> | def set_user_password(name, passwd, **client_args):
'''
Change password of a user.
name
Name of the user for whom to set the password.
passwd
New password of the user.
CLI Example:
.. code-block:: bash
salt '*' influxdb.set_user_password <name> <password>
'''
... |
Grant cluster administration privileges to a user.
name
Name of the user to whom admin privileges will be granted.
CLI Example:
.. code-block:: bash
salt '*' influxdb.grant_admin_privileges <name> | def grant_admin_privileges(name, **client_args):
'''
Grant cluster administration privileges to a user.
name
Name of the user to whom admin privileges will be granted.
CLI Example:
.. code-block:: bash
salt '*' influxdb.grant_admin_privileges <name>
'''
client = _client(*... |
Revoke cluster administration privileges from a user.
name
Name of the user from whom admin privileges will be revoked.
CLI Example:
.. code-block:: bash
salt '*' influxdb.revoke_admin_privileges <name> | def revoke_admin_privileges(name, **client_args):
'''
Revoke cluster administration privileges from a user.
name
Name of the user from whom admin privileges will be revoked.
CLI Example:
.. code-block:: bash
salt '*' influxdb.revoke_admin_privileges <name>
'''
client = _c... |
Remove a user.
name
Name of the user to remove
CLI Example:
.. code-block:: bash
salt '*' influxdb.remove_user <name> | def remove_user(name, **client_args):
'''
Remove a user.
name
Name of the user to remove
CLI Example:
.. code-block:: bash
salt '*' influxdb.remove_user <name>
'''
if not user_exists(name, **client_args):
log.info('User \'%s\' does not exist', name)
return... |
Get an existing retention policy.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get_retention_policy metrics default | def get_retention_policy(database, name, **client_args):
'''
Get an existing retention policy.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get... |
Check if retention policy with given name exists.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.retention_policy_exists metrics default | def retention_policy_exists(database, name, **client_args):
'''
Check if retention policy with given name exists.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy to check.
CLI Example:
.. code-block:: bash
... |
Drop a retention policy.
database
Name of the database for which the retention policy will be dropped.
name
Name of the retention policy to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_retention_policy mydb mypr | def drop_retention_policy(database, name, **client_args):
'''
Drop a retention policy.
database
Name of the database for which the retention policy will be dropped.
name
Name of the retention policy to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_re... |
Create a retention policy.
database
Name of the database for which the retention policy will be created.
name
Name of the new retention policy.
duration
Duration of the new retention policy.
Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported and mean
1 ... | def create_retention_policy(database,
name,
duration,
replication,
default=False,
**client_args):
'''
Create a retention policy.
database
Name of the database ... |
List privileges from a user.
name
Name of the user from whom privileges will be listed.
CLI Example:
.. code-block:: bash
salt '*' influxdb.list_privileges <name> | def list_privileges(name, **client_args):
'''
List privileges from a user.
name
Name of the user from whom privileges will be listed.
CLI Example:
.. code-block:: bash
salt '*' influxdb.list_privileges <name>
'''
client = _client(**client_args)
res = {}
for item ... |
Grant a privilege on a database to a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to grant the privilege to. | def grant_privilege(database, privilege, username, **client_args):
'''
Grant a privilege on a database to a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to gra... |
Revoke a privilege on a database from a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to grant the privilege to. | def revoke_privilege(database, privilege, username, **client_args):
'''
Revoke a privilege on a database from a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to... |
Check if continuous query with given name exists on the database.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.continuous_query_exists metrics... | def continuous_query_exists(database, name, **client_args):
'''
Check if continuous query with given name exists on the database.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to check.
CLI Example:
.. code... |
Get an existing continuous query.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to get.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get_continuous_query mydb cq_month | def get_continuous_query(database, name, **client_args):
'''
Get an existing continuous query.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to get.
CLI Example:
.. code-block:: bash
salt '*' influ... |
Create a continuous query.
database
Name of the database for which the continuous query will be
created on.
name
Name of the continuous query to create.
query
The continuous query string.
resample_time : None
Duration between continuous query resampling.
... | def create_continuous_query(database, name, query, resample_time=None, coverage_period=None, **client_args):
'''
Create a continuous query.
database
Name of the database for which the continuous query will be
created on.
name
Name of the continuous query to create.
query
... |
Drop a continuous query.
database
Name of the database for which the continuous query will
be drop from.
name
Name of the continuous query to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_continuous_query mydb my_cq | def drop_continuous_query(database, name, **client_args):
'''
Drop a continuous query.
database
Name of the database for which the continuous query will
be drop from.
name
Name of the continuous query to drop.
CLI Example:
.. code-block:: bash
salt '*' influx... |
Parses a ResultSet returned from InfluxDB into a dictionary of results,
grouped by series names and optional JSON-encoded grouping tags. | def _pull_query_results(resultset):
'''
Parses a ResultSet returned from InfluxDB into a dictionary of results,
grouped by series names and optional JSON-encoded grouping tags.
'''
_results = collections.defaultdict(lambda: {})
for _header, _values in resultset.items():
_header, _group_t... |
Execute a query.
database
Name of the database to query on.
query
InfluxQL query string. | def query(database, query, **client_args):
'''
Execute a query.
database
Name of the database to query on.
query
InfluxQL query string.
'''
client = _client(**client_args)
_result = client.query(query, database=database)
if isinstance(_result, collections.Sequence):
... |
Returns the recursive diff between dict values | def _get_recursive_difference(self, type):
'''Returns the recursive diff between dict values'''
if type == 'intersect':
return [recursive_diff(item['old'], item['new']) for item in self._intersect]
elif type == 'added':
return [recursive_diff({}, item) for item in self._a... |
Deletes an attribute from all of the intersect objects | def remove_diff(self, diff_key=None, diff_list='intersect'):
'''Deletes an attribute from all of the intersect objects'''
if diff_list == 'intersect':
for item in self._intersect:
item['old'].pop(diff_key, None)
item['new'].pop(diff_key, None)
if diff_... |
Returns a list of dictionaries with key value pairs.
The values are the differences between the items identified by the key. | def diffs(self):
'''
Returns a list of dictionaries with key value pairs.
The values are the differences between the items identified by the key.
'''
differences = []
for item in self._get_recursive_difference(type='all'):
if item.diffs:
if ite... |
Returns a string describing the changes | def changes_str(self):
'''Returns a string describing the changes'''
changes = ''
for item in self._get_recursive_difference(type='intersect'):
if item.diffs:
changes = ''.join([changes,
# Tabulate comment deeper, show the key attrib... |
Returns a string in a more compact format describing the changes.
The output better alligns with the one in recursive_diff. | def changes_str2(self, tab_string=' '):
'''
Returns a string in a more compact format describing the changes.
The output better alligns with the one in recursive_diff.
'''
changes = []
for item in self._get_recursive_difference(type='intersect'):
if item.dif... |
Returns the new values from the diff | def new_values(self):
'''Returns the new values from the diff'''
def get_new_values_and_key(item):
values = item.new_values
if item.past_dict:
values.update({self._key: item.past_dict[self._key]})
else:
# This is a new item as it has no... |
Returns the old values from the diff | def old_values(self):
'''Returns the old values from the diff'''
def get_old_values_and_key(item):
values = item.old_values
values.update({self._key: item.past_dict[self._key]})
return values
return [get_old_values_and_key(el)
for el in self._... |
Returns the list of changed values.
The key is added to each item.
selection
Specifies the desired changes.
Supported values are
``all`` - all changed items are included in the output
``intersect`` - changed items present in both lists are include... | def changed(self, selection='all'):
'''
Returns the list of changed values.
The key is added to each item.
selection
Specifies the desired changes.
Supported values are
``all`` - all changed items are included in the output
``inter... |
.. versionchanged:: 2018.3.0
Added ``with_pillar`` argument
Execute ``fun`` with the given ``args`` and ``kwargs``. Parameter ``fun``
should be the string :ref:`name <all-salt.modules>` of the execution module
to call.
.. note::
Execution modules will be loaded *every time* this funct... | def cmd(fun, *args, **kwargs):
'''
.. versionchanged:: 2018.3.0
Added ``with_pillar`` argument
Execute ``fun`` with the given ``args`` and ``kwargs``. Parameter ``fun``
should be the string :ref:`name <all-salt.modules>` of the execution module
to call.
.. note::
Execution mod... |
.. versionadded:: 2017.7.0
Execute ``fun`` on all minions matched by ``tgt`` and ``tgt_type``.
Parameter ``fun`` is the name of execution module function to call.
This function should mainly be used as a helper for runner modules,
in order to avoid redundant code.
For example, when inside a runner... | def execute(tgt,
fun,
arg=(),
timeout=None,
tgt_type='glob',
ret='',
jid='',
kwarg=None,
**kwargs):
'''
.. versionadded:: 2017.7.0
Execute ``fun`` on all minions matched by ``tgt`` and ``tgt_type``.
Paramete... |
Resolves the given symlink path to its real path, up to a maximum of the
`max_depth` parameter which defaults to 64.
If the path is not a symlink path, it is simply returned. | def _resolve_symlink(path, max_depth=64):
'''
Resolves the given symlink path to its real path, up to a maximum of the
`max_depth` parameter which defaults to 64.
If the path is not a symlink path, it is simply returned.
'''
if sys.getwindowsversion().major < 6:
raise SaltInvocationErro... |
Convert the group id to the group name on this system
Under Windows, because groups are just another ACL entity, this function
behaves the same as uid_to_user.
For maintaining Windows systems, this function is superfluous and only
exists for API compatibility with Unix. Use the uid_to_user function
... | def gid_to_group(gid):
'''
Convert the group id to the group name on this system
Under Windows, because groups are just another ACL entity, this function
behaves the same as uid_to_user.
For maintaining Windows systems, this function is superfluous and only
exists for API compatibility with Un... |
Convert the group to the gid on this system
Under Windows, because groups are just another ACL entity, this function
behaves the same as user_to_uid, except if None is given, '' is returned.
For maintaining Windows systems, this function is superfluous and only
exists for API compatibility with Unix. ... | def group_to_gid(group):
'''
Convert the group to the gid on this system
Under Windows, because groups are just another ACL entity, this function
behaves the same as user_to_uid, except if None is given, '' is returned.
For maintaining Windows systems, this function is superfluous and only
exi... |
Return the id of the primary group that owns a given file (Windows only)
This function will return the rarely used primary group of a file. This
generally has no bearing on permissions unless intentionally configured
and is most commonly used to provide Unix compatibility (e.g. Services
For Unix, NFS s... | def get_pgid(path, follow_symlinks=True):
'''
Return the id of the primary group that owns a given file (Windows only)
This function will return the rarely used primary group of a file. This
generally has no bearing on permissions unless intentionally configured
and is most commonly used to provide... |
Return the id of the group that owns a given file
Under Windows, this will return the uid of the file.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
configured and is only used to support Unix compatibility ... | def get_gid(path, follow_symlinks=True):
'''
Return the id of the group that owns a given file
Under Windows, this will return the uid of the file.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
confi... |
Return the group that owns a given file
Under Windows, this will return the user (owner) of the file.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
configured and is only used to support Unix compatibility f... | def get_group(path, follow_symlinks=True):
'''
Return the group that owns a given file
Under Windows, this will return the user (owner) of the file.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
conf... |
Convert user name to a uid
Args:
user (str): The user to lookup
Returns:
str: The user id of the user
CLI Example:
.. code-block:: bash
salt '*' file.user_to_uid myusername | def user_to_uid(user):
'''
Convert user name to a uid
Args:
user (str): The user to lookup
Returns:
str: The user id of the user
CLI Example:
.. code-block:: bash
salt '*' file.user_to_uid myusername
'''
if user is None:
user = salt.utils.user.get_use... |
Return the id of the user that owns a given file
Symlinks are followed by default to mimic Unix behavior. Specify
`follow_symlinks=False` to turn off this behavior.
Args:
path (str): The path to the file or directory
follow_symlinks (bool):
If the object specified by ``path`` ... | def get_uid(path, follow_symlinks=True):
'''
Return the id of the user that owns a given file
Symlinks are followed by default to mimic Unix behavior. Specify
`follow_symlinks=False` to turn off this behavior.
Args:
path (str): The path to the file or directory
follow_symlinks (bo... |
Return the user that owns a given file
Symlinks are followed by default to mimic Unix behavior. Specify
`follow_symlinks=False` to turn off this behavior.
Args:
path (str): The path to the file or directory
follow_symlinks (bool):
If the object specified by ``path`` is a symli... | def get_user(path, follow_symlinks=True):
'''
Return the user that owns a given file
Symlinks are followed by default to mimic Unix behavior. Specify
`follow_symlinks=False` to turn off this behavior.
Args:
path (str): The path to the file or directory
follow_symlinks (bool):
... |
Return the mode of a file
Right now we're just returning None because Windows' doesn't have a mode
like Linux
Args:
path (str): The path to the file or directory
Returns:
None
CLI Example:
.. code-block:: bash
salt '*' file.get_mode /etc/passwd | def get_mode(path):
'''
Return the mode of a file
Right now we're just returning None because Windows' doesn't have a mode
like Linux
Args:
path (str): The path to the file or directory
Returns:
None
CLI Example:
.. code-block:: bash
salt '*' file.get_mode /... |
Chown a file, pass the file the desired user and group without following any
symlinks.
Under Windows, the group parameter will be ignored.
This is because while files in Windows do have a 'primary group'
property, this is rarely used. It generally has no bearing on
permissions unless intentionall... | def lchown(path, user, group=None, pgroup=None):
'''
Chown a file, pass the file the desired user and group without following any
symlinks.
Under Windows, the group parameter will be ignored.
This is because while files in Windows do have a 'primary group'
property, this is rarely used. It ge... |
Chown a file, pass the file the desired user and group
Under Windows, the group parameter will be ignored.
This is because while files in Windows do have a 'primary group'
property, this is rarely used. It generally has no bearing on
permissions unless intentionally configured and is most commonly us... | def chown(path, user, group=None, pgroup=None, follow_symlinks=True):
'''
Chown a file, pass the file the desired user and group
Under Windows, the group parameter will be ignored.
This is because while files in Windows do have a 'primary group'
property, this is rarely used. It generally has no ... |
Change the group of a file
Under Windows, this will do nothing.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
configured and is only used to support Unix compatibility features (e.g.
Services For Unix, N... | def chgrp(path, group):
'''
Change the group of a file
Under Windows, this will do nothing.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
configured and is only used to support Unix compatibility fea... |
Return a dict containing the stats about a given file
Under Windows, `gid` will equal `uid` and `group` will equal `user`.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on permissions unless intentionally
configured and is only used to support... | def stats(path, hash_type='sha256', follow_symlinks=True):
'''
Return a dict containing the stats about a given file
Under Windows, `gid` will equal `uid` and `group` will equal `user`.
While a file in Windows does have a 'primary group', this rarely used
attribute generally has no bearing on perm... |
Return a dictionary object with the Windows
file attributes for a file.
Args:
path (str): The path to the file or directory
Returns:
dict: A dictionary of file attributes
CLI Example:
.. code-block:: bash
salt '*' file.get_attributes c:\\temp\\a.txt | def get_attributes(path):
'''
Return a dictionary object with the Windows
file attributes for a file.
Args:
path (str): The path to the file or directory
Returns:
dict: A dictionary of file attributes
CLI Example:
.. code-block:: bash
salt '*' file.get_attributes... |
Set file attributes for a file. Note that the normal attribute
means that all others are false. So setting it will clear all others.
Args:
path (str): The path to the file or directory
archive (bool): Sets the archive attribute. Default is None
hidden (bool): Sets the hidden attribute... | def set_attributes(path, archive=None, hidden=None, normal=None,
notIndexed=None, readonly=None, system=None, temporary=None):
'''
Set file attributes for a file. Note that the normal attribute
means that all others are false. So setting it will clear all others.
Args:
path... |
Set the mode of a file
This just calls get_mode, which returns None because we don't use mode on
Windows
Args:
path: The path to the file or directory
mode: The mode (not used)
Returns:
None
CLI Example:
.. code-block:: bash
salt '*' file.set_mode /etc/passw... | def set_mode(path, mode):
'''
Set the mode of a file
This just calls get_mode, which returns None because we don't use mode on
Windows
Args:
path: The path to the file or directory
mode: The mode (not used)
Returns:
None
CLI Example:
.. code-block:: bash
... |
Remove the named file or directory
Args:
path (str): The path to the file or directory to remove.
force (bool): Remove even if marked Read-Only. Default is False
Returns:
bool: True if successful, False if unsuccessful
CLI Example:
.. code-block:: bash
salt '*' file.... | def remove(path, force=False):
'''
Remove the named file or directory
Args:
path (str): The path to the file or directory to remove.
force (bool): Remove even if marked Read-Only. Default is False
Returns:
bool: True if successful, False if unsuccessful
CLI Example:
.... |
Create a symbolic link to a file
This is only supported with Windows Vista or later and must be executed by
a user with the SeCreateSymbolicLink privilege.
The behavior of this function matches the Unix equivalent, with one
exception - invalid symlinks cannot be created. The source path must exist.
... | def symlink(src, link):
'''
Create a symbolic link to a file
This is only supported with Windows Vista or later and must be executed by
a user with the SeCreateSymbolicLink privilege.
The behavior of this function matches the Unix equivalent, with one
exception - invalid symlinks cannot be cre... |
Check if the path is a symlink
This is only supported on Windows Vista or later.
Inline with Unix behavior, this function will raise an error if the path
is not a symlink, however, the error raised will be a SaltInvocationError,
not an OSError.
Args:
path (str): The path to a file or dire... | def is_link(path):
'''
Check if the path is a symlink
This is only supported on Windows Vista or later.
Inline with Unix behavior, this function will raise an error if the path
is not a symlink, however, the error raised will be a SaltInvocationError,
not an OSError.
Args:
path (s... |
Return the path that a symlink points to
This is only supported on Windows Vista or later.
Inline with Unix behavior, this function will raise an error if the path is
not a symlink, however, the error raised will be a SaltInvocationError, not
an OSError.
Args:
path (str): The path to the ... | def readlink(path):
'''
Return the path that a symlink points to
This is only supported on Windows Vista or later.
Inline with Unix behavior, this function will raise an error if the path is
not a symlink, however, the error raised will be a SaltInvocationError, not
an OSError.
Args:
... |
Ensure that the directory is available and permissions are set.
Args:
path (str):
The full path to the directory.
owner (str):
The owner of the directory. If not passed, it will be the account
that created the directory, likely SYSTEM
grant_perms (dict... | def mkdir(path,
owner=None,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
'''
Ensure that the directory is available and permissions are set.
Args:
path (str):
The full path to the directory.
owner (str):
... |
Ensure that the parent directory containing this path is available.
Args:
path (str):
The full path to the directory.
.. note::
The path must end with a trailing slash otherwise the
directory(s) will be created up to the parent directory. For
... | def makedirs_(path,
owner=None,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
'''
Ensure that the parent directory containing this path is available.
Args:
path (str):
The full path to the direct... |
Set owner and permissions for each directory created.
Args:
path (str):
The full path to the directory.
owner (str):
The owner of the directory. If not passed, it will be the account
that created the directory, likely SYSTEM.
grant_perms (dict):
... | def makedirs_perms(path,
owner=None,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=True):
'''
Set owner and permissions for each directory created.
Args:
path (str):
The full pat... |
Check owner and permissions for the passed directory. This function checks
the permissions and sets them, returning the changes made. Used by the file
state to populate the return dict
Args:
path (str):
The full path to the directory.
ret (dict):
A dictionary to ap... | def check_perms(path,
ret=None,
owner=None,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
'''
Check owner and permissions for the passed directory. This function checks
the permissions and se... |
Set permissions for the given path
Args:
path (str):
The full path to the directory.
grant_perms (dict):
A dictionary containing the user/group and the basic permissions to
grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
set the... | def set_perms(path,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
'''
Set permissions for the given path
Args:
path (str):
The full path to the directory.
grant_perms (dict):
A dictionary ... |
Validate the beacon configuration | def validate(config):
'''
Validate the beacon configuration
'''
if not isinstance(config, list):
return False, ('Configuration for haproxy beacon must '
'be a list.')
else:
_config = {}
list(map(_config.update, config))
if 'backends' not in _co... |
Check if current number of sessions of a server for a specific haproxy backend
is over a defined threshold.
.. code-block:: yaml
beacons:
haproxy:
- backends:
www-backend:
threshold: 45
servers:
- web1
... | def beacon(config):
'''
Check if current number of sessions of a server for a specific haproxy backend
is over a defined threshold.
.. code-block:: yaml
beacons:
haproxy:
- backends:
www-backend:
threshold: 45
server... |
Given a thing type name, check to see if the given thing type exists
Returns True if the given thing type exists and returns False if the
given thing type does not exist.
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt myminion boto_iot.thing_type_exists mythingtype | def thing_type_exists(thingTypeName,
region=None, key=None, keyid=None, profile=None):
'''
Given a thing type name, check to see if the given thing type exists
Returns True if the given thing type exists and returns False if the
given thing type does not exist.
.. versionadded:: 2016.1... |
Given a thing type name describe its properties.
Returns a dictionary of interesting properties.
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt myminion boto_iot.describe_thing_type mythingtype | def describe_thing_type(thingTypeName,
region=None, key=None, keyid=None, profile=None):
'''
Given a thing type name describe its properties.
Returns a dictionary of interesting properties.
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt myminion boto_iot.desc... |
Given a valid config, create a thing type.
Returns {created: true} if the thing type was created and returns
{created: False} if the thing type was not created.
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt myminion boto_iot.create_thing_type mythingtype \\
... | def create_thing_type(thingTypeName, thingTypeDescription,
searchableAttributesList, region=None, key=None,
keyid=None, profile=None):
'''
Given a valid config, create a thing type.
Returns {created: true} if the thing type was created and returns
{created: False} if the thing type was not crea... |
Given a thing type name, delete it.
Returns {deleted: true} if the thing type was deleted and returns
{deleted: false} if the thing type was not deleted.
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt myminion boto_iot.delete_thing_type mythingtype | def delete_thing_type(thingTypeName,
region=None, key=None, keyid=None, profile=None):
'''
Given a thing type name, delete it.
Returns {deleted: true} if the thing type was deleted and returns
{deleted: false} if the thing type was not deleted.
.. versionadded:: 2016.11.0
CLI Exam... |
Given a thing type name, deprecate it when undoDeprecate is False
and undeprecate it when undoDeprecate is True.
Returns {deprecated: true} if the thing type was deprecated and returns
{deprecated: false} if the thing type was not deprecated.
.. versionadded:: 2016.11.0
CLI Example:
.. code-... | def deprecate_thing_type(thingTypeName, undoDeprecate=False,
region=None, key=None, keyid=None, profile=None):
'''
Given a thing type name, deprecate it when undoDeprecate is False
and undeprecate it when undoDeprecate is True.
Returns {deprecated: true} if the thing type was deprecated and returns... |
Given a policy name, check to see if the given policy exists.
Returns True if the given policy exists and returns False if the given
policy does not exist.
CLI Example:
.. code-block:: bash
salt myminion boto_iot.policy_exists mypolicy | def policy_exists(policyName,
region=None, key=None, keyid=None, profile=None):
'''
Given a policy name, check to see if the given policy exists.
Returns True if the given policy exists and returns False if the given
policy does not exist.
CLI Example:
.. code-block:: bash
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.