INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Return the value of key at path in vault or entire secret | def read_secret(path, key=None):
'''
Return the value of key at path in vault, or entire secret
Jinja Example:
.. code-block:: jinja
my-secret: {{ salt['vault'].read_secret('secret/my/secret', 'some-key') }}
.. code-block:: jinja
{% set supersecret = salt['vault'].read_secret('s... |
Set secret at the path in vault. The vault policy used must allow this. | def write_secret(path, **kwargs):
'''
Set secret at the path in vault. The vault policy used must allow this.
CLI Example:
.. code-block:: bash
salt '*' vault.write_secret "secret/my/secret" user="foo" password="bar"
'''
log.debug('Writing vault secrets for %s at %s', __grains__['... |
Set raw data at the path in vault. The vault policy used must allow this. | def write_raw(path, raw):
'''
Set raw data at the path in vault. The vault policy used must allow this.
CLI Example:
.. code-block:: bash
salt '*' vault.write_raw "secret/my/secret" '{"user":"foo","password": "bar"}'
'''
log.debug('Writing vault secrets for %s at %s', __grains__['... |
Verify that the raid is present | def present(name,
level,
devices,
**kwargs):
'''
Verify that the raid is present
.. versionchanged:: 2014.7.0
name
The name of raid device to be created
level
The RAID level to use when creating the raid.
devices
A list of d... |
Accepts HJSON as a string or as a file object and runs it through the HJSON parser. | def render(hjson_data, saltenv='base', sls='', **kws):
'''
Accepts HJSON as a string or as a file object and runs it through the HJSON
parser.
:rtype: A Python data structure
'''
if not isinstance(hjson_data, six.string_types):
hjson_data = hjson_data.read()
if hjson_data.startswit... |
Ensure function exists. | def function_present(name, FunctionName, Runtime, Role, Handler, ZipFile=None,
S3Bucket=None, S3Key=None, S3ObjectVersion=None,
Description='', Timeout=3, MemorySize=128,
Permissions=None, RoleRetries=5, region=None, key=None,
keyid=Non... |
Ensure alias exists. | def alias_present(name, FunctionName, Name, FunctionVersion, Description='',
region=None, key=None, keyid=None, profile=None):
'''
Ensure alias exists.
name
The name of the state definition.
FunctionName
Name of the function for which you want to create an alias.
... |
Ensure event source mapping exists. | def event_source_mapping_present(name, EventSourceArn, FunctionName,
StartingPosition, Enabled=True, BatchSize=100,
region=None, key=None, keyid=None,
profile=None):
'''
Ensure event source mapping exists.
na... |
Ensure event source mapping with passed properties is absent. | def event_source_mapping_absent(name, EventSourceArn, FunctionName,
region=None, key=None, keyid=None, profile=None):
'''
Ensure event source mapping with passed properties is absent.
name
The name of the state definition.
EventSourceArn
ARN of the event... |
Return a list of load balancers. | def list_balancers(profile, **libcloud_kwargs):
'''
Return a list of load balancers.
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_balancers method
:type libcloud_kwargs: ``dict``
CLI Example:
.. code-block:: ba... |
Return a list of supported protocols. | def list_protocols(profile, **libcloud_kwargs):
'''
Return a list of supported protocols.
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_protocols method
:type libcloud_kwargs: ``dict``
:return: a list of supported pr... |
Create a new load balancer instance | def create_balancer(name, port, protocol, profile, algorithm=None, members=None, **libcloud_kwargs):
'''
Create a new load balancer instance
:param name: Name of the new load balancer (required)
:type name: ``str``
:param port: Port the load balancer should listen on, defaults to 80
:type po... |
Destroy a load balancer | def destroy_balancer(balancer_id, profile, **libcloud_kwargs):
'''
Destroy a load balancer
:param balancer_id: LoadBalancer ID which should be used
:type balancer_id: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's ... |
Get the details for a load balancer by name | def get_balancer_by_name(name, profile, **libcloud_kwargs):
'''
Get the details for a load balancer by name
:param name: Name of a load balancer you want to fetch
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the d... |
Add a new member to the load balancer | def balancer_attach_member(balancer_id, ip, port, profile, extra=None, **libcloud_kwargs):
'''
Add a new member to the load balancer
:param balancer_id: id of a load balancer you want to fetch
:type balancer_id: ``str``
:param ip: IP address for the new member
:type ip: ``str``
:param p... |
Add a new member to the load balancer | def balancer_detach_member(balancer_id, member_id, profile, **libcloud_kwargs):
'''
Add a new member to the load balancer
:param balancer_id: id of a load balancer you want to fetch
:type balancer_id: ``str``
:param ip: IP address for the new member
:type ip: ``str``
:param port: Port f... |
List the members of a load balancer | def list_balancer_members(balancer_id, profile, **libcloud_kwargs):
'''
List the members of a load balancer
:param balancer_id: id of a load balancer you want to fetch
:type balancer_id: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra argumen... |
Call an extended method on the driver | def extra(method, profile, **libcloud_kwargs):
'''
Call an extended method on the driver
:param method: Driver's method name
:type method: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's method
:type libcloud_k... |
Install new alternative for defined <name > | def install(name, link, path, priority):
'''
Install new alternative for defined <name>
name
is the master name for this link group
(e.g. pager)
link
is the symlink pointing to /etc/alternatives/<name>.
(e.g. /usr/bin/pager)
path
is the location of the new ... |
Removes installed alternative for defined <name > and <path > or fallback to default alternative if some defined before. | def remove(name, path):
'''
Removes installed alternative for defined <name> and <path>
or fallback to default alternative, if some defined before.
name
is the master name for this link group
(e.g. pager)
path
is the location of one of the alternative target files.
... |
.. versionadded:: 0. 17. 0 | def auto(name):
'''
.. versionadded:: 0.17.0
Instruct alternatives to use the highest priority
path for <name>
name
is the master name for this link group
(e.g. pager)
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
... |
.. versionadded:: 0. 17. 0 | def set_(name, path):
'''
.. versionadded:: 0.17.0
Sets alternative for <name> to <path>, if <path> is defined
as an alternative for <name>.
name
is the master name for this link group
(e.g. pager)
path
is the location of one of the alternative target files.
(e... |
Ensure that a data source is present. | def present(name,
type,
url,
access=None,
user=None,
password=None,
database=None,
basic_auth=None,
basic_auth_user=None,
basic_auth_password=None,
tls_auth=None,
json_data=None,
... |
Ensure that a data source is present. | def absent(name, orgname=None, profile='grafana'):
'''
Ensure that a data source is present.
name
Name of the data source to remove.
orgname
Name of the organization from which the data source should be absent.
profile
Configuration profile used to connect to the Grafana i... |
Return the primary name associate with the load if an empty string is returned then the load does not match the function | def load_name(self, load):
'''
Return the primary name associate with the load, if an empty string
is returned then the load does not match the function
'''
if 'eauth' not in load:
return ''
fstr = '{0}.auth'.format(load['eauth'])
if fstr not in self.a... |
Return the token and set the cache data for use | def __auth_call(self, load):
'''
Return the token and set the cache data for use
Do not call this directly! Use the time_auth method to overcome timing
attacks
'''
if 'eauth' not in load:
return False
fstr = '{0}.auth'.format(load['eauth'])
if... |
Make sure that all failures happen in the same amount of time | def time_auth(self, load):
'''
Make sure that all failures happen in the same amount of time
'''
start = time.time()
ret = self.__auth_call(load)
if ret:
return ret
f_time = time.time() - start
if f_time > self.max_fail:
self.max_fa... |
Returns ACL for a specific user. Returns None if eauth doesn t provide any for the user. I. e. None means: use acl declared in master config. | def __get_acl(self, load):
'''
Returns ACL for a specific user.
Returns None if eauth doesn't provide any for the user. I. e. None means: use acl declared
in master config.
'''
if 'eauth' not in load:
return None
mod = self.opts['eauth_acl_module']
... |
Allows eauth module to modify the access list right before it ll be applied to the request. For example ldap auth module expands entries | def __process_acl(self, load, auth_list):
'''
Allows eauth module to modify the access list right before it'll be applied to the request.
For example ldap auth module expands entries
'''
if 'eauth' not in load:
return auth_list
fstr = '{0}.process_acl'.format(... |
Read in a load and return the groups a user is a member of by asking the appropriate provider | def get_groups(self, load):
'''
Read in a load and return the groups a user is a member of
by asking the appropriate provider
'''
if 'eauth' not in load:
return False
fstr = '{0}.groups'.format(load['eauth'])
if fstr not in self.auth:
retur... |
Return bool if requesting user is allowed to set custom expire | def _allow_custom_expire(self, load):
'''
Return bool if requesting user is allowed to set custom expire
'''
expire_override = self.opts.get('token_expire_user_override', False)
if expire_override is True:
return True
if isinstance(expire_override, collectio... |
Run time_auth and create a token. Return False or the token | def mk_token(self, load):
'''
Run time_auth and create a token. Return False or the token
'''
if not self.authenticate_eauth(load):
return {}
if self._allow_custom_expire(load):
token_expire = load.pop('token_expire', self.opts['token_expire'])
el... |
Return the name associated with the token or False if the token is not valid | def get_tok(self, tok):
'''
Return the name associated with the token, or False if the token is
not valid
'''
tdata = self.tokens["{0}.get_token".format(self.opts['eauth_tokens'])](self.opts, tok)
if not tdata:
return {}
rm_tok = False
if 'exp... |
Remove the given token from token storage. | def rm_token(self, tok):
'''
Remove the given token from token storage.
'''
self.tokens["{0}.rm_token".format(self.opts['eauth_tokens'])](self.opts, tok) |
Authenticate a user by the token specified in load. Return the token object or False if auth failed. | def authenticate_token(self, load):
'''
Authenticate a user by the token specified in load.
Return the token object or False if auth failed.
'''
token = self.get_tok(load['token'])
# Bail if the token is empty or if the eauth type specified is not allowed
if not ... |
Authenticate a user by the external auth module specified in load. Return True on success or False on failure. | def authenticate_eauth(self, load):
'''
Authenticate a user by the external auth module specified in load.
Return True on success or False on failure.
'''
if 'eauth' not in load:
log.warning('Authentication failure of type "eauth" occurred.')
return False
... |
Authenticate a user by the key passed in load. Return the effective user id ( name ) if it s different from the specified one ( for sudo ). If the effective user id is the same as the passed one return True on success or False on failure. | def authenticate_key(self, load, key):
'''
Authenticate a user by the key passed in load.
Return the effective user id (name) if it's different from the specified one (for sudo).
If the effective user id is the same as the passed one, return True on success or False on
failure.
... |
Retrieve access list for the user specified in load. The list is built by eauth module or from master eauth configuration. Return None if current configuration doesn t provide any ACL for the user. Return an empty list if the user has no rights to execute anything on this master and returns non - empty list if user is ... | def get_auth_list(self, load, token=None):
'''
Retrieve access list for the user specified in load.
The list is built by eauth module or from master eauth configuration.
Return None if current configuration doesn't provide any ACL for the user. Return an empty
list if the user ha... |
.. versionadded:: 2018. 3. 0 | def check_authentication(self, load, auth_type, key=None, show_username=False):
'''
.. versionadded:: 2018.3.0
Go through various checks to see if the token/eauth/user can be authenticated.
Returns a dictionary containing the following keys:
- auth_list
- username
... |
Gather and create the authorization data sets | def auth_data(self):
'''
Gather and create the authorization data sets
We're looking at several constructs here.
Standard eauth: allow jsmith to auth via pam, and execute any command
on server web1
external_auth:
pam:
jsmith:
- web1:
... |
Determine if token auth is valid and yield the adata | def token(self, adata, load):
'''
Determine if token auth is valid and yield the adata
'''
try:
token = self.loadauth.get_tok(load['token'])
except Exception as exc:
log.error('Exception occurred when generating auth token: %s', exc)
yield {}
... |
Determine if the given eauth is valid and yield the adata | def eauth(self, adata, load):
'''
Determine if the given eauth is valid and yield the adata
'''
for sub_auth in [adata]:
if load['eauth'] not in sub_auth:
continue
try:
name = self.loadauth.load_name(load)
if not ((n... |
Read in the access system to determine if the validated user has requested rights | def rights_check(self, form, sub_auth, name, load, eauth=None):
'''
Read in the access system to determine if the validated user has
requested rights
'''
if load.get('eauth'):
sub_auth = sub_auth[load['eauth']]
good = self.ckminions.any_auth(
f... |
Determine what type of authentication is being requested and pass authorization | def rights(self, form, load):
'''
Determine what type of authentication is being requested and pass
authorization
Note: this will check that the user has at least one right that will let
the user execute "load", this does not deal with conflicting rules
'''
adat... |
Execute the CLI options to fill in the extra data needed for the defined eauth system | def cli(self, eauth):
'''
Execute the CLI options to fill in the extra data needed for the
defined eauth system
'''
ret = {}
if not eauth:
print('External authentication system has not been specified')
return ret
fstr = '{0}.auth'.format(ea... |
Create the token from the CLI and request the correct data to authenticate via the passed authentication mechanism | def token_cli(self, eauth, load):
'''
Create the token from the CLI and request the correct data to
authenticate via the passed authentication mechanism
'''
load['cmd'] = 'mk_token'
load['eauth'] = eauth
tdata = self._send_token_request(load)
if 'token' no... |
Request a token from the master | def get_token(self, token):
'''
Request a token from the master
'''
load = {}
load['token'] = token
load['cmd'] = 'get_token'
tdata = self._send_token_request(load)
return tdata |
Returns a list of the requester s topics | def list_topics(region=None, key=None, keyid=None, profile=None):
'''
Returns a list of the requester's topics
CLI example::
salt myminion boto3_sns.list_topics
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
res = {}
NextToken = ''
while NextToken is... |
Returns details about a specific SNS topic specified by name or ARN. | def describe_topic(name, region=None, key=None, keyid=None, profile=None):
'''
Returns details about a specific SNS topic, specified by name or ARN.
CLI example::
salt my_favorite_client boto3_sns.describe_topic a_sns_topic_of_my_choice
'''
topics = list_topics(region=region, key=key, keyi... |
Check to see if an SNS topic exists. | def topic_exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if an SNS topic exists.
CLI example::
salt myminion boto3_sns.topic_exists mytopic region=us-east-1
'''
topics = list_topics(region=region, key=key, keyid=keyid, profile=profile)
return name in li... |
Create an SNS topic. | def create_topic(Name, region=None, key=None, keyid=None, profile=None):
'''
Create an SNS topic.
CLI example::
salt myminion boto3_sns.create_topic mytopic region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
ret = conn.create_topic(... |
Delete an SNS topic. | def delete_topic(TopicArn, region=None, key=None, keyid=None, profile=None):
'''
Delete an SNS topic.
CLI example::
salt myminion boto3_sns.delete_topic mytopic region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
conn.delete_topic(To... |
Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of the user. | def get_topic_attributes(TopicArn, region=None, key=None, keyid=None, profile=None):
'''
Returns all of the properties of a topic. Topic properties returned might differ based on the
authorization of the user.
CLI example::
salt myminion boto3_sns.get_topic_attributes someTopic region=us-west... |
Set an attribute of a topic to a new value. | def set_topic_attributes(TopicArn, AttributeName, AttributeValue, region=None, key=None, keyid=None,
profile=None):
'''
Set an attribute of a topic to a new value.
CLI example::
salt myminion boto3_sns.set_topic_attributes someTopic DisplayName myDisplayNameValue
'''
... |
Returns a list of the subscriptions to a specific topic | def list_subscriptions_by_topic(TopicArn, region=None, key=None, keyid=None, profile=None):
'''
Returns a list of the subscriptions to a specific topic
CLI example::
salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1
'''
conn = _get_conn(region=region, key=key, ke... |
Returns all of the properties of a subscription. | def get_subscription_attributes(SubscriptionArn, region=None, key=None, keyid=None, profile=None):
'''
Returns all of the properties of a subscription.
CLI example::
salt myminion boto3_sns.get_subscription_attributes somesubscription region=us-west-1
'''
conn = _get_conn(region=region, ke... |
Subscribe to a Topic. | def subscribe(TopicArn=None, Protocol=None, Endpoint=None,
region=None, key=None, keyid=None, profile=None, **kwargs):
'''
Subscribe to a Topic.
CLI example::
salt myminion boto3_sns.subscribe mytopic https https://www.example.com/sns-endpoint
'''
conn = _get_conn(region=regi... |
Unsubscribe a specific SubscriptionArn of a topic. | def unsubscribe(SubscriptionArn, region=None, key=None, keyid=None, profile=None):
'''
Unsubscribe a specific SubscriptionArn of a topic.
CLI Example:
.. code-block:: bash
salt myminion boto3_sns.unsubscribe my_subscription_arn region=us-east-1
'''
if not SubscriptionArn.startswith('a... |
Determines if the system needs to be rebooted. | def needs_reboot():
'''
Determines if the system needs to be rebooted.
Returns:
bool: True if the system requires a reboot, False if not
CLI Examples:
.. code-block:: bash
import salt.utils.win_update
salt.utils.win_update.needs_reboot()
'''
# Initialize the Py... |
Create a dictionary with the details for the updates in the collection. | def list(self):
'''
Create a dictionary with the details for the updates in the collection.
Returns:
dict: Details about each update
.. code-block:: cfg
List of Updates:
{'<GUID>': {'Title': <title>,
'KB': <KB>,
... |
Create a dictionary with a summary of the updates in the collection. | def summary(self):
'''
Create a dictionary with a summary of the updates in the collection.
Returns:
dict: Summary of the contents of the collection
.. code-block:: cfg
Summary of Updates:
{'Total': <total number of updates returned>,
'... |
Get the contents of _updates ( all updates ) and puts them in an Updates class to expose the list and summary functions. | def updates(self):
'''
Get the contents of ``_updates`` (all updates) and puts them in an
Updates class to expose the list and summary functions.
Returns:
Updates: An instance of the Updates class with all updates for the
system.
.. code-block:: python
... |
Refresh the contents of the _updates collection. This gets all updates in the Windows Update system and loads them into the collection. This is the part that is slow. | def refresh(self):
'''
Refresh the contents of the ``_updates`` collection. This gets all
updates in the Windows Update system and loads them into the collection.
This is the part that is slow.
Code Example:
.. code-block:: python
import salt.utils.win_upda... |
Gets a list of all updates available on the system that match the passed criteria. | def available(self,
skip_hidden=True,
skip_installed=True,
skip_mandatory=False,
skip_reboot=False,
software=True,
drivers=True,
categories=None,
severities=None):
'''
... |
Search for either a single update or a specific list of updates. GUIDs are searched first then KB numbers and finally Titles. | def search(self, search_string):
'''
Search for either a single update or a specific list of updates. GUIDs
are searched first, then KB numbers, and finally Titles.
Args:
search_string (str, list): The search string to use to find the
update. This can be the GUI... |
Download the updates passed in the updates collection. Load the updates collection using search or available | def download(self, updates):
'''
Download the updates passed in the updates collection. Load the updates
collection using ``search`` or ``available``
Args:
updates (Updates): An instance of the Updates class containing a
the updates to be downloaded.
Re... |
Install the updates passed in the updates collection. Load the updates collection using the search or available functions. If the updates need to be downloaded use the download function. | def install(self, updates):
'''
Install the updates passed in the updates collection. Load the updates
collection using the ``search`` or ``available`` functions. If the
updates need to be downloaded, use the ``download`` function.
Args:
updates (Updates): An instan... |
Uninstall the updates passed in the updates collection. Load the updates collection using the search or available functions. | def uninstall(self, updates):
'''
Uninstall the updates passed in the updates collection. Load the updates
collection using the ``search`` or ``available`` functions.
.. note:: Starting with Windows 10 the Windows Update Agent is unable to
uninstall updates. An ``Uninstall Not A... |
Internal function for running commands. Used by the uninstall function. | def _run(self, cmd):
'''
Internal function for running commands. Used by the uninstall function.
Args:
cmd (str, list): The command to run
Returns:
str: The stdout of the command
'''
if isinstance(cmd, six.string_types):
cmd = salt.u... |
Accepts YAML as a string or as a file object and runs it through the YAML parser. | def render(yaml_data, saltenv='base', sls='', argline='', **kws):
'''
Accepts YAML as a string or as a file object and runs it through the YAML
parser.
:rtype: A Python data structure
'''
if not isinstance(yaml_data, string_types):
yaml_data = yaml_data.read()
with warnings.catch_wa... |
Write a default to the system | def write(domain, key, value, type='string', user=None):
'''
Write a default to the system
CLI Example:
.. code-block:: bash
salt '*' macdefaults.write com.apple.CrashReporter DialogType Server
salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool
domain
... |
Write a default to the system | def read(domain, key, user=None):
'''
Write a default to the system
CLI Example:
.. code-block:: bash
salt '*' macdefaults.read com.apple.CrashReporter DialogType
salt '*' macdefaults.read NSGlobalDomain ApplePersistence
domain
The name of the domain to read from
ke... |
Delete a default from the system | def delete(domain, key, user=None):
'''
Delete a default from the system
CLI Example:
.. code-block:: bash
salt '*' macdefaults.delete com.apple.CrashReporter DialogType
salt '*' macdefaults.delete NSGlobalDomain ApplePersistence
domain
The name of the domain to delete f... |
Manage the computer s description field | def computer_desc(name):
'''
Manage the computer's description field
name
The desired computer description
'''
# Just in case someone decides to enter a numeric description
name = six.text_type(name)
ret = {'name': name,
'changes': {},
'result': True,
... |
Manage the computer s name | def computer_name(name):
'''
Manage the computer's name
name
The desired computer name
'''
# Just in case someone decides to enter a numeric description
name = six.text_type(name)
ret = {'name': name,
'changes': {},
'result': True,
'comment': 'Compu... |
.. versionadded:: 2016. 3. 0 | def hostname(name):
'''
.. versionadded:: 2016.3.0
Manage the hostname of the computer
name
The hostname to set
'''
ret = {
'name': name,
'changes': {},
'result': True,
'comment': ''
}
current_hostname = __salt__['system.get_hostname']()
if... |
.. versionadded:: 2019. 2. 0 | def workgroup(name):
'''
.. versionadded:: 2019.2.0
Manage the workgroup of the computer
name
The workgroup to set
Example:
.. code-block:: yaml
set workgroup:
system.workgroup:
- name: local
'''
ret = {'name': name.upper(), 'result': False, 'ch... |
Checks if a computer is joined to the Domain. If the computer is not in the Domain it will be joined. | def join_domain(name,
username=None,
password=None,
account_ou=None,
account_exists=False,
restart=False):
'''
Checks if a computer is joined to the Domain. If the computer is not in the
Domain, it will be joined.
Args:
... |
Reboot the computer | def reboot(name, message=None, timeout=5, force_close=True, in_seconds=False,
only_on_pending_reboot=True):
'''
Reboot the computer
:param str message:
An optional message to display to users. It will also be used as a
comment in the event log entry.
The default value is... |
Shutdown the computer | def shutdown(name, message=None, timeout=5, force_close=True, reboot=False,
in_seconds=False, only_on_pending_reboot=False):
'''
Shutdown the computer
:param str message:
An optional message to display to users. It will also be used as a
comment in the event log entry.
... |
Send a message to a Slack channel. | def post_message(name,
channel,
from_name,
message,
api_key=None,
icon=None):
'''
Send a message to a Slack channel.
.. code-block:: yaml
slack-message:
slack.post_message:
- channel: '#gener... |
Parse BTRFS device info data. | def _parse_btrfs_info(data):
'''
Parse BTRFS device info data.
'''
ret = {}
for line in [line for line in data.split("\n") if line][:-1]:
if line.startswith("Label:"):
line = re.sub(r"Label:\s+", "", line)
label, uuid_ = [tkn.strip() for tkn in line.split("uuid:")]
... |
Get BTRFS filesystem information. | def info(device):
'''
Get BTRFS filesystem information.
CLI Example:
.. code-block:: bash
salt '*' btrfs.info /dev/sda1
'''
out = __salt__['cmd.run_all']("btrfs filesystem show {0}".format(device))
salt.utils.fsutils._verify_run(out)
return _parse_btrfs_info(out['stdout']) |
Get known BTRFS formatted devices on the system. | def devices():
'''
Get known BTRFS formatted devices on the system.
CLI Example:
.. code-block:: bash
salt '*' btrfs.devices
'''
out = __salt__['cmd.run_all']("blkid -o export")
salt.utils.fsutils._verify_run(out)
return salt.utils.fsutils._blkid_output(out['stdout'], fs_type... |
Defragment only one BTRFS mountpoint. | def _defragment_mountpoint(mountpoint):
'''
Defragment only one BTRFS mountpoint.
'''
out = __salt__['cmd.run_all']("btrfs filesystem defragment -f {0}".format(mountpoint))
return {
'mount_point': mountpoint,
'passed': not out['stderr'],
'log': out['stderr'] or False,
... |
Defragment mounted BTRFS filesystem. In order to defragment a filesystem device should be properly mounted and writable. | def defragment(path):
'''
Defragment mounted BTRFS filesystem.
In order to defragment a filesystem, device should be properly mounted and writable.
If passed a device name, then defragmented whole filesystem, mounted on in.
If passed a moun tpoint of the filesystem, then only this mount point is de... |
List currently available BTRFS features. | def features():
'''
List currently available BTRFS features.
CLI Example:
.. code-block:: bash
salt '*' btrfs.mkfs_features
'''
out = __salt__['cmd.run_all']("mkfs.btrfs -O list-all")
salt.utils.fsutils._verify_run(out)
ret = {}
for line in [re.sub(r"\s+", " ", line) for ... |
Parse usage/ overall. | def _usage_overall(raw):
'''
Parse usage/overall.
'''
data = {}
for line in raw.split("\n")[1:]:
keyset = [item.strip() for item in re.sub(r"\s+", " ", line).split(":", 1) if item.strip()]
if len(keyset) == 2:
key = re.sub(r"[()]", "", keyset[0]).replace(" ", "_").lower()... |
Parse usage/ specific. | def _usage_specific(raw):
'''
Parse usage/specific.
'''
get_key = lambda val: dict([tuple(val.split(":")), ])
raw = raw.split("\n")
section, size, used = raw[0].split(" ")
section = section.replace(",", "_").replace(":", "").lower()
data = {}
data[section] = {}
for val in [size... |
Parse usage/ unallocated. | def _usage_unallocated(raw):
'''
Parse usage/unallocated.
'''
ret = {}
for line in raw.split("\n")[1:]:
keyset = re.sub(r"\s+", " ", line.strip()).split(" ")
if len(keyset) == 2:
ret[keyset[0]] = keyset[1]
return ret |
Show in which disk the chunks are allocated. | def usage(path):
'''
Show in which disk the chunks are allocated.
CLI Example:
.. code-block:: bash
salt '*' btrfs.usage /your/mountpoint
'''
out = __salt__['cmd.run_all']("btrfs filesystem usage {0}".format(path))
salt.utils.fsutils._verify_run(out)
ret = {}
for section ... |
Create a file system on the specified device. By default wipes out with force. | def mkfs(*devices, **kwargs):
'''
Create a file system on the specified device. By default wipes out with force.
General options:
* **allocsize**: Specify the BTRFS offset from the start of the device.
* **bytecount**: Specify the size of the resultant filesystem.
* **nodesize**: Node size.
... |
Resize filesystem. | def resize(mountpoint, size):
'''
Resize filesystem.
General options:
* **mountpoint**: Specify the BTRFS mountpoint to resize.
* **size**: ([+/-]<newsize>[kKmMgGtTpPeE]|max) Specify the new size of the target.
CLI Example:
.. code-block:: bash
salt '*' btrfs.resize /mountpoint ... |
Convert ext2/ 3/ 4 to BTRFS. Device should be mounted. | def convert(device, permanent=False, keeplf=False):
'''
Convert ext2/3/4 to BTRFS. Device should be mounted.
Filesystem can be converted temporarily so the further processing and rollback is possible,
or permanently, where previous extended filesystem image gets deleted. Please note, permanent
conv... |
Restripe BTRFS: add or remove devices from the particular mounted filesystem. | def _restripe(mountpoint, direction, *devices, **kwargs):
'''
Restripe BTRFS: add or remove devices from the particular mounted filesystem.
'''
fs_log = []
if salt.utils.fsutils._is_device(mountpoint):
raise CommandExecutionError(
"Mountpount expected, while device \"{0}\" speci... |
Parse properties list. | def _parse_proplist(data):
'''
Parse properties list.
'''
out = {}
for line in data.split("\n"):
line = re.split(r"\s+", line, 1)
if len(line) == 2:
out[line[0]] = line[1]
return out |
List properties for given btrfs object. The object can be path of BTRFS device mount point or any directories/ files inside the BTRFS filesystem. | def properties(obj, type=None, set=None):
'''
List properties for given btrfs object. The object can be path of BTRFS device,
mount point, or any directories/files inside the BTRFS filesystem.
General options:
* **type**: Possible types are s[ubvol], f[ilesystem], i[node] and d[evice].
* **for... |
Create subvolume name in dest. | def subvolume_create(name, dest=None, qgroupids=None):
'''
Create subvolume `name` in `dest`.
Return True if the subvolume is created, False is the subvolume is
already there.
name
Name of the new subvolume
dest
If not given, the subvolume will be created in the current
... |
Delete the subvolume ( s ) from the filesystem | def subvolume_delete(name=None, names=None, commit=None):
'''
Delete the subvolume(s) from the filesystem
The user can remove one single subvolume (name) or multiple of
then at the same time (names). One of the two parameters needs to
specified.
Please, refer to the documentation to understand... |
List the recently modified files in a subvolume | def subvolume_find_new(name, last_gen):
'''
List the recently modified files in a subvolume
name
Name of the subvolume
last_gen
Last transid marker from where to compare
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_find_new /var/volumes/tmp 1024
''... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.