INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
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
conversion takes a while as BTRFS filesystem needs to be properly re... | 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.
General options:
* **type**: Possible types are s[ubvol], f[ilesystem], i[node] and d[evice].
* **force**: Force overwrite existing filesystem on the disk
... | 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`.
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
directory, if given will be in /dest/name
qgroupids
... | 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
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 the implication
on the transactions, and when the subvolume is re... | 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
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 | 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
''... |
Get the default subvolume of the filesystem path
path
Mount point for the subvolume
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_get_default /var/volumes/tmp | def subvolume_get_default(path):
'''
Get the default subvolume of the filesystem path
path
Mount point for the subvolume
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_get_default /var/volumes/tmp
'''
cmd = ['btrfs', 'subvolume', 'get-default', path]
res... |
Helper for the line parser.
If key is a prefix of line, will remove ir from the line and will
extract the value (space separation), and the rest of the line.
If use_rest is True, the value will be the rest of the line.
Return a tuple with the value and the rest of the line. | def _pop(line, key, use_rest):
'''
Helper for the line parser.
If key is a prefix of line, will remove ir from the line and will
extract the value (space separation), and the rest of the line.
If use_rest is True, the value will be the rest of the line.
Return a tuple with the value and the r... |
Set the subvolume as default
subvolid
ID of the new default subvolume
path
Mount point for the filesystem
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_set_default 257 /var/volumes/tmp | def subvolume_set_default(subvolid, path):
'''
Set the subvolume as default
subvolid
ID of the new default subvolume
path
Mount point for the filesystem
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_set_default 257 /var/volumes/tmp
'''
cmd = ['b... |
Show information of a given subvolume
path
Mount point for the filesystem
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_show /var/volumes/tmp | def subvolume_show(path):
'''
Show information of a given subvolume
path
Mount point for the filesystem
CLI Example:
.. code-block:: bash
salt '*' btrfs.subvolume_show /var/volumes/tmp
'''
cmd = ['btrfs', 'subvolume', 'show', path]
res = __salt__['cmd.run_all'](cmd)... |
Create a snapshot of a source subvolume
source
Source subvolume from where to create the snapshot
dest
If only dest is given, the subvolume will be named as the
basename of the source
name
Name of the snapshot
read_only
Create a read only snapshot
CLI Exam... | def subvolume_snapshot(source, dest=None, name=None, read_only=False):
'''
Create a snapshot of a source subvolume
source
Source subvolume from where to create the snapshot
dest
If only dest is given, the subvolume will be named as the
basename of the source
name
Na... |
Wait until given subvolume are completely removed from the
filesystem after deletion.
path
Mount point for the filesystem
subvolids
List of IDs of subvolumes to wait for
sleep
Sleep N seconds betwenn checks (default: 1)
CLI Example:
.. code-block:: bash
salt... | def subvolume_sync(path, subvolids=None, sleep=None):
'''
Wait until given subvolume are completely removed from the
filesystem after deletion.
path
Mount point for the filesystem
subvolids
List of IDs of subvolumes to wait for
sleep
Sleep N seconds betwenn checks (def... |
Add a user to the minion.
Args:
name (str): User name
password (str, optional): User's password in plain text.
fullname (str, optional): The user's full name.
description (str, optional): A brief description of the user account.
groups (str, optional): A list of groups t... | def add(name,
password=None,
fullname=None,
description=None,
groups=None,
home=None,
homedrive=None,
profile=None,
logonscript=None):
'''
Add a user to the minion.
Args:
name (str): User name
password (str, optional): User's ... |
Updates settings for the windows user. Name is the only required parameter.
Settings will only be changed if the parameter is passed a value.
.. versionadded:: 2015.8.0
Args:
name (str): The user name to update.
password (str, optional): New user password in plain text.
fullname ... | def update(name,
password=None,
fullname=None,
description=None,
home=None,
homedrive=None,
logonscript=None,
profile=None,
expiration_date=None,
expired=None,
account_disabled=None,
unlock_account=N... |
Remove a user from the minion
Args:
name (str): The name of the user to delete
purge (bool, optional): Boolean value indicating that the user profile
should also be removed when the user account is deleted. If set to
True the profile will be removed. Default is False.
... | def delete(name,
purge=False,
force=False):
'''
Remove a user from the minion
Args:
name (str): The name of the user to delete
purge (bool, optional): Boolean value indicating that the user profile
should also be removed when the user account is deleted. I... |
Get the Security ID for the user
Args:
username (str): The user name for which to look up the SID
Returns:
str: The user SID
CLI Example:
.. code-block:: bash
salt '*' user.getUserSid jsnuffy | def getUserSid(username):
'''
Get the Security ID for the user
Args:
username (str): The user name for which to look up the SID
Returns:
str: The user SID
CLI Example:
.. code-block:: bash
salt '*' user.getUserSid jsnuffy
'''
if six.PY2:
username = _t... |
Add user to a group
Args:
name (str): The user name to add to the group
group (str): The name of the group to which to add the user
Returns:
bool: True if successful, otherwise False
CLI Example:
.. code-block:: bash
salt '*' user.addgroup jsnuffy 'Power Users' | def addgroup(name, group):
'''
Add user to a group
Args:
name (str): The user name to add to the group
group (str): The name of the group to which to add the user
Returns:
bool: True if successful, otherwise False
CLI Example:
.. code-block:: bash
salt '*' u... |
Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
Args:
name (str): The name of the user whose home directory you wish to change
home (str): The new location of the home directory
Returns:
bool: Tr... | def chhome(name, home, **kwargs):
'''
Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
Args:
name (str): The name of the user whose home directory you wish to change
home (str): The new location of the... |
Change the groups this user belongs to, add append=False to make the user a
member of only the specified groups
Args:
name (str): The user name for which to change groups
groups (str, list): A single group or a list of groups to assign to the
user. For multiple groups this can be a... | def chgroups(name, groups, append=True):
'''
Change the groups this user belongs to, add append=False to make the user a
member of only the specified groups
Args:
name (str): The user name for which to change groups
groups (str, list): A single group or a list of groups to assign to th... |
Return user information
Args:
name (str): Username for which to display information
Returns:
dict: A dictionary containing user information
- fullname
- username
- SID
- passwd (will always return None)
- comment (same as description,... | def info(name):
'''
Return user information
Args:
name (str): Username for which to display information
Returns:
dict: A dictionary containing user information
- fullname
- username
- SID
- passwd (will always return None)
- c... |
In case net user doesn't return the userprofile we can get it from the
registry
Args:
user (str): The user name, used in debug message
sid (str): The sid to lookup in the registry
Returns:
str: Profile directory | def _get_userprofile_from_registry(user, sid):
'''
In case net user doesn't return the userprofile we can get it from the
registry
Args:
user (str): The user name, used in debug message
sid (str): The sid to lookup in the registry
Returns:
str: Profile directory
'''
... |
Return a list of groups the named user belongs to
Args:
name (str): The user name for which to list groups
Returns:
list: A list of groups to which the user belongs
CLI Example:
.. code-block:: bash
salt '*' user.list_groups foo | def list_groups(name):
'''
Return a list of groups the named user belongs to
Args:
name (str): The user name for which to list groups
Returns:
list: A list of groups to which the user belongs
CLI Example:
.. code-block:: bash
salt '*' user.list_groups foo
'''
... |
Return the list of all info for all users
Args:
refresh (bool, optional): Refresh the cached user information. Useful
when used from within a state function. Default is False.
Returns:
dict: A dictionary containing information about all users on the system
CLI Example:
..... | def getent(refresh=False):
'''
Return the list of all info for all users
Args:
refresh (bool, optional): Refresh the cached user information. Useful
when used from within a state function. Default is False.
Returns:
dict: A dictionary containing information about all users ... |
Change the username for a named user
Args:
name (str): The user name to change
new_name (str): The new name for the current user
Returns:
bool: True if successful, otherwise False
CLI Example:
.. code-block:: bash
salt '*' user.rename jsnuffy jshmoe | def rename(name, new_name):
'''
Change the username for a named user
Args:
name (str): The user name to change
new_name (str): The new name for the current user
Returns:
bool: True if successful, otherwise False
CLI Example:
.. code-block:: bash
salt '*' use... |
Return a list of all users on Windows
Returns:
list: A list of all users on the system
CLI Example:
.. code-block:: bash
salt '*' user.list_users | def list_users():
'''
Return a list of all users on Windows
Returns:
list: A list of all users on the system
CLI Example:
.. code-block:: bash
salt '*' user.list_users
'''
res = 0
user_list = []
dowhile = True
try:
while res or dowhile:
dow... |
Get the username that salt-minion is running under. If salt-minion is
running as a service it should return the Local System account. If salt is
running from a command prompt it should return the username that started the
command prompt.
.. versionadded:: 2015.5.6
Args:
sam (bool, optional... | def current(sam=False):
'''
Get the username that salt-minion is running under. If salt-minion is
running as a service it should return the Local System account. If salt is
running from a command prompt it should return the username that started the
command prompt.
.. versionadded:: 2015.5.6
... |
Validates a mac address | def mac(addr):
'''
Validates a mac address
'''
valid = re.compile(r'''
(^([0-9A-F]{1,2}[-]){5}([0-9A-F]{1,2})$
|^([0-9A-F]{1,2}[:]){5}([0-9A-F]{1,2})$
|^([0-9A-F]{1,2}[.]){5}([0-9A-F]{1,2})$)
''',
... |
Returns True if the IP address (and optional subnet) are valid, otherwise
returns False. | def __ip_addr(addr, address_family=socket.AF_INET):
'''
Returns True if the IP address (and optional subnet) are valid, otherwise
returns False.
'''
mask_max = '32'
if address_family == socket.AF_INET6:
mask_max = '128'
try:
if '/' not in addr:
addr = '{addr}/{ma... |
Returns True if the value passed is a valid netmask, otherwise return False | def netmask(mask):
'''
Returns True if the value passed is a valid netmask, otherwise return False
'''
if not isinstance(mask, string_types):
return False
octets = mask.split('.')
if not len(octets) == 4:
return False
return ipv4_addr(mask) and octets == sorted(octets, reve... |
Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values. | def _connect(host=DEFAULT_HOST, port=DEFAULT_PORT):
'''
Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values.
'''
if six.text_type(port).isdigit():
return memcache.Client(['{0}:{1}'.format(host, port)], debug=0)
raise SaltInvocationError... |
Get memcached status
CLI Example:
.. code-block:: bash
salt '*' memcached.status | def status(host=DEFAULT_HOST, port=DEFAULT_PORT):
'''
Get memcached status
CLI Example:
.. code-block:: bash
salt '*' memcached.status
'''
conn = _connect(host, port)
try:
stats = _check_stats(conn)[0]
except (CommandExecutionError, IndexError):
return False
... |
Retrieve value for a key
CLI Example:
.. code-block:: bash
salt '*' memcached.get <key> | def get(key, host=DEFAULT_HOST, port=DEFAULT_PORT):
'''
Retrieve value for a key
CLI Example:
.. code-block:: bash
salt '*' memcached.get <key>
'''
conn = _connect(host, port)
_check_stats(conn)
return conn.get(key) |
Set a key on the memcached server, overwriting the value if it exists.
CLI Example:
.. code-block:: bash
salt '*' memcached.set <key> <value> | def set_(key,
value,
host=DEFAULT_HOST,
port=DEFAULT_PORT,
time=DEFAULT_TIME,
min_compress_len=DEFAULT_MIN_COMPRESS_LEN):
'''
Set a key on the memcached server, overwriting the value if it exists.
CLI Example:
.. code-block:: bash
salt '*' memcache... |
Delete a key from memcache server
CLI Example:
.. code-block:: bash
salt '*' memcached.delete <key> | def delete(key,
host=DEFAULT_HOST,
port=DEFAULT_PORT,
time=DEFAULT_TIME):
'''
Delete a key from memcache server
CLI Example:
.. code-block:: bash
salt '*' memcached.delete <key>
'''
if not isinstance(time, six.integer_types):
raise SaltInvocati... |
Replace a key on the memcached server. This only succeeds if the key
already exists. This is the opposite of :mod:`memcached.add
<salt.modules.memcached.add>`
CLI Example:
.. code-block:: bash
salt '*' memcached.replace <key> <value> | def replace(key,
value,
host=DEFAULT_HOST,
port=DEFAULT_PORT,
time=DEFAULT_TIME,
min_compress_len=DEFAULT_MIN_COMPRESS_LEN):
'''
Replace a key on the memcached server. This only succeeds if the key
already exists. This is the opposite of :mod:`memc... |
Increment the value of a key
CLI Example:
.. code-block:: bash
salt '*' memcached.increment <key>
salt '*' memcached.increment <key> 2 | def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
'''
Increment the value of a key
CLI Example:
.. code-block:: bash
salt '*' memcached.increment <key>
salt '*' memcached.increment <key> 2
'''
conn = _connect(host, port)
_check_stats(conn)
cur = get(ke... |
Publish a command "from the minion out to other minions". In reality, the
minion does not execute this function, it is executed by the master. Thus,
no access control is enabled, as minions cannot initiate publishes
themselves.
Salt-ssh publishes will default to whichever roster was used for the
in... | def _publish(tgt,
fun,
arg=None,
tgt_type='glob',
returner='',
timeout=None,
form='clean',
roster=None):
'''
Publish a command "from the minion out to other minions". In reality, the
minion does not execute this funct... |
Publish a command "from the minion out to other minions". In reality, the
minion does not execute this function, it is executed by the master. Thus,
no access control is enabled, as minions cannot initiate publishes
themselves.
Salt-ssh publishes will default to whichever roster was used for the
i... | def publish(tgt,
fun,
arg=None,
tgt_type='glob',
returner='',
timeout=5,
roster=None):
'''
Publish a command "from the minion out to other minions". In reality, the
minion does not execute this function, it is executed by the master. Th... |
Execute a runner on the master and return the data from the runnr function
CLI Example:
.. code-block:: bash
salt-ssh '*' publish.runner jobs.lookup_jid 20140916125524463507 | def runner(fun, arg=None, timeout=5):
'''
Execute a runner on the master and return the data from the runnr function
CLI Example:
.. code-block:: bash
salt-ssh '*' publish.runner jobs.lookup_jid 20140916125524463507
'''
# Form args as list
if not isinstance(arg, list):
arg... |
Create RackSpace Queue. | def create(self, qname):
'''
Create RackSpace Queue.
'''
try:
if self.exists(qname):
log.error('Queues "%s" already exists. Nothing done.', qname)
return True
self.conn.create(qname)
return True
except pyrax.ex... |
Delete an existings RackSpace Queue. | def delete(self, qname):
'''
Delete an existings RackSpace Queue.
'''
try:
q = self.exists(qname)
if not q:
return False
queue = self.show(qname)
if queue:
queue.delete()
except pyrax.exceptions as er... |
Check to see if a Queue exists. | def exists(self, qname):
'''
Check to see if a Queue exists.
'''
try:
# First if not exists() -> exit
if self.conn.queue_exists(qname):
return True
return False
except pyrax.exceptions as err_msg:
log.error('RackSpac... |
Show information about Queue | def show(self, qname):
'''
Show information about Queue
'''
try:
# First if not exists() -> exit
if not self.conn.queue_exists(qname):
return {}
# If exist, search the queue to return the Queue Object
for queue in self.conn.... |
Return a list of startup dirs | def _get_dirs(user_dir, startup_dir):
'''
Return a list of startup dirs
'''
try:
users = os.listdir(user_dir)
except WindowsError: # pylint: disable=E0602
users = []
full_dirs = []
for user in users:
full_dir = os.path.join(user_dir, user, startup_dir)
if os... |
Get a list of automatically running programs
CLI Example:
.. code-block:: bash
salt '*' autoruns.list | def list_():
'''
Get a list of automatically running programs
CLI Example:
.. code-block:: bash
salt '*' autoruns.list
'''
autoruns = {}
# Find autoruns in registry
keys = ['HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run',
'HKLM\\Software\\Microsoft\\Windows\... |
Get pillar data from Vault for the configuration ``conf``. | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
conf,
nesting_key=None):
'''
Get pillar data from Vault for the configuration ``conf``.
'''
comps = conf.split()
paths = [comp for comp in comps if comp.startswith('path=... |
Export a file or directory from an SVN repository
name
Address and path to the file or directory to be exported.
target
Name of the target directory where the checkout will put the working
directory
rev : None
The name revision number to checkout. Enable "force" if the dir... | def export(name,
target=None,
rev=None,
user=None,
username=None,
password=None,
force=False,
overwrite=False,
externals=True,
trust=False,
trust_failures=None):
'''
Export a file or directory from an S... |
Determine if the working directory has been changed. | def dirty(name,
target,
user=None,
username=None,
password=None,
ignore_unversioned=False):
'''
Determine if the working directory has been changed.
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
return _fail(ret, 'This functi... |
Compile pillar data | def ext_pillar(minion_id, pillar, *args, **kwargs):
'''
Compile pillar data
'''
# Node definitions path will be retrieved from args (or set to default),
# then added to 'salt_data' dict that is passed to the 'get_pillars'
# function. The dictionary contains:
# - __opts__
# - __sa... |
Ensures a container is present.
:param name: Container name
:type name: ``str``
:param profile: The profile key
:type profile: ``str`` | def container_present(name, profile):
'''
Ensures a container is present.
:param name: Container name
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
'''
containers = __salt__['libcloud_storage.list_containers'](profile)
match = [z for z in containers i... |
Ensures a object is presnt.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str``
:param profile: The profile key
:type profile: ``str`` | def object_present(container, name, path, profile):
'''
Ensures a object is presnt.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str``
:param profile: The profile k... |
Ensures a object is absent.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param profile: The profile key
:type profile: ``str`` | def object_absent(container, name, profile):
'''
Ensures a object is absent.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
'''
existing_object = __salt__... |
Ensures a object is downloaded locally.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str``
:param profile: The profile key
:type profile: ``str``
:param overwrite... | def file_present(container, name, path, profile, overwrite_existing=False):
'''
Ensures a object is downloaded locally.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str`... |
Get grains for minion.
.. code-block: bash
salt '*' nxos.cmd grains | def grains(**kwargs):
'''
Get grains for minion.
.. code-block: bash
salt '*' nxos.cmd grains
'''
import __main__ as main # pylint: disable=unused-import
if not DEVICE_DETAILS['grains_cache']:
data = sendline('show version')
if CONNECTION == 'nxapi':
data =... |
Required.
Initialize device connection using ssh or nxapi connection type. | def init(opts=None):
'''
Required.
Initialize device connection using ssh or nxapi connection type.
'''
global CONNECTION
if __opts__.get('proxy').get('connection') is not None:
CONNECTION = __opts__.get('proxy').get('connection')
if CONNECTION == 'ssh':
log.info('NXOS PROXY... |
Send arbitrary show or config commands to the NX-OS device.
command
The command to be sent.
method:
``cli_show_ascii``: Return raw test or unstructured output.
``cli_show``: Return structured output.
``cli_conf``: Send configuration commands to the device.
Defaults to `... | def sendline(command, method='cli_show_ascii', **kwargs):
'''
Send arbitrary show or config commands to the NX-OS device.
command
The command to be sent.
method:
``cli_show_ascii``: Return raw test or unstructured output.
``cli_show``: Return structured output.
``cli_co... |
Send configuration commands over SSH or NX-API
commands
List of configuration commands
no_save_config
If True, don't save configuration commands to startup configuration.
If False, save configuration to startup configuration.
Default: False
.. code-block: bash
sal... | def proxy_config(commands, **kwargs):
'''
Send configuration commands over SSH or NX-API
commands
List of configuration commands
no_save_config
If True, don't save configuration commands to startup configuration.
If False, save configuration to startup configuration.
De... |
Open a connection to the NX-OS switch over SSH. | def _init_ssh(opts):
'''
Open a connection to the NX-OS switch over SSH.
'''
if opts is None:
opts = __opts__
try:
this_prompt = None
if 'prompt_regex' in opts['proxy']:
this_prompt = opts['proxy']['prompt_regex']
elif 'prompt_name' in opts['proxy']:
... |
Helper method to parse command output for error information | def _parse_output_for_errors(data, command, **kwargs):
'''
Helper method to parse command output for error information
'''
if re.search('% Invalid', data):
raise CommandExecutionError({
'rejected_input': command,
'message': 'CLI excution error',
'code': '400',... |
Open a connection to the NX-OS switch over NX-API.
As the communication is HTTP(S) based, there is no connection to maintain,
however, in order to test the connectivity and make sure we are able to
bring up this Minion, we are executing a very simple command (``show clock``)
which doesn't come with muc... | def _init_nxapi(opts):
'''
Open a connection to the NX-OS switch over NX-API.
As the communication is HTTP(S) based, there is no connection to maintain,
however, in order to test the connectivity and make sure we are able to
bring up this Minion, we are executing a very simple command (``show clock... |
Executes an nxapi_request request over NX-API.
commands
The exec or config commands to be sent.
method: ``cli_show``
``cli_show_ascii``: Return raw test or unstructured output.
``cli_show``: Return structured output.
``cli_conf``: Send configuration commands to the device.
... | def _nxapi_request(commands, method='cli_conf', **kwargs):
'''
Executes an nxapi_request request over NX-API.
commands
The exec or config commands to be sent.
method: ``cli_show``
``cli_show_ascii``: Return raw test or unstructured output.
``cli_show``: Return structured output... |
.. versionadded:: 2019.2.0
Create or update an availability set.
:param name: The availability set to create.
:param resource_group: The resource group name assigned to the
availability set.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.availability_set_create_or... | def availability_set_create_or_update(name, resource_group, **kwargs): # pylint: disable=invalid-name
'''
.. versionadded:: 2019.2.0
Create or update an availability set.
:param name: The availability set to create.
:param resource_group: The resource group name assigned to the
availabil... |
.. versionadded:: 2019.2.0
Delete an availability set.
:param name: The availability set to delete.
:param resource_group: The resource group name assigned to the
availability set.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.availability_set_delete testset test... | def availability_set_delete(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Delete an availability set.
:param name: The availability set to delete.
:param resource_group: The resource group name assigned to the
availability set.
CLI Example:
.. code-block:: bash... |
.. versionadded:: 2019.2.0
Get a dictionary representing an availability set's properties.
:param name: The availability set to get.
:param resource_group: The resource group name assigned to the
availability set.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.ava... | def availability_set_get(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Get a dictionary representing an availability set's properties.
:param name: The availability set to get.
:param resource_group: The resource group name assigned to the
availability set.
CLI Exam... |
.. versionadded:: 2019.2.0
List all availability sets within a resource group.
:param resource_group: The resource group name to list availability
sets within.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.availability_sets_list testgroup | def availability_sets_list(resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
List all availability sets within a resource group.
:param resource_group: The resource group name to list availability
sets within.
CLI Example:
.. code-block:: bash
salt-call azurearm_comp... |
.. versionadded:: 2019.2.0
List all available virtual machine sizes that can be used to
to create a new virtual machine in an existing availability set.
:param name: The availability set name to list available
virtual machine sizes within.
:param resource_group: The resource group name to lis... | def availability_sets_list_available_sizes(name, resource_group, **kwargs): # pylint: disable=invalid-name
'''
.. versionadded:: 2019.2.0
List all available virtual machine sizes that can be used to
to create a new virtual machine in an existing availability set.
:param name: The availability set... |
.. versionadded:: 2019.2.0
Captures the VM by copying virtual hard disks of the VM and outputs
a template that can be used to create similar VMs.
:param name: The name of the virtual machine.
:param destination_name: The destination container name.
:param resource_group: The resource group name ... | def virtual_machine_capture(name, destination_name, resource_group, prefix='capture-', overwrite=False, **kwargs):
'''
.. versionadded:: 2019.2.0
Captures the VM by copying virtual hard disks of the VM and outputs
a template that can be used to create similar VMs.
:param name: The name of the virt... |
.. versionadded:: 2019.2.0
Retrieves information about the model view or the instance view of a
virtual machine.
:param name: The name of the virtual machine.
:param resource_group: The resource group name assigned to the
virtual machine.
CLI Example:
.. code-block:: bash
s... | def virtual_machine_get(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Retrieves information about the model view or the instance view of a
virtual machine.
:param name: The name of the virtual machine.
:param resource_group: The resource group name assigned to the
vi... |
.. versionadded:: 2019.2.0
Converts virtual machine disks from blob-based to managed disks. Virtual
machine must be stop-deallocated before invoking this operation.
:param name: The name of the virtual machine to convert.
:param resource_group: The resource group name assigned to the
virtual ... | def virtual_machine_convert_to_managed_disks(name, resource_group, **kwargs): # pylint: disable=invalid-name
'''
.. versionadded:: 2019.2.0
Converts virtual machine disks from blob-based to managed disks. Virtual
machine must be stop-deallocated before invoking this operation.
:param name: The na... |
.. versionadded:: 2019.2.0
Set the state of a virtual machine to 'generalized'.
:param name: The name of the virtual machine.
:param resource_group: The resource group name assigned to the
virtual machine.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.virtual_mac... | def virtual_machine_generalize(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Set the state of a virtual machine to 'generalized'.
:param name: The name of the virtual machine.
:param resource_group: The resource group name assigned to the
virtual machine.
CLI Exampl... |
.. versionadded:: 2019.2.0
List all virtual machines within a resource group.
:param resource_group: The resource group name to list virtual
machines within.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.virtual_machines_list testgroup | def virtual_machines_list(resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
List all virtual machines within a resource group.
:param resource_group: The resource group name to list virtual
machines within.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute... |
.. versionadded:: 2019.2.0
List all virtual machines within a subscription.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.virtual_machines_list_all | def virtual_machines_list_all(**kwargs):
'''
.. versionadded:: 2019.2.0
List all virtual machines within a subscription.
CLI Example:
.. code-block:: bash
salt-call azurearm_compute.virtual_machines_list_all
'''
result = {}
compconn = __utils__['azurearm.get_client']('comput... |
.. versionadded:: 2019.2.0
Lists all available virtual machine sizes to which the specified virtual
machine can be resized.
:param name: The name of the virtual machine.
:param resource_group: The resource group name assigned to the
virtual machine.
CLI Example:
.. code-block:: bash... | def virtual_machines_list_available_sizes(name, resource_group, **kwargs): # pylint: disable=invalid-name
'''
.. versionadded:: 2019.2.0
Lists all available virtual machine sizes to which the specified virtual
machine can be resized.
:param name: The name of the virtual machine.
:param resou... |
Print out YAML using the block mode | def output(data, **kwargs): # pylint: disable=unused-argument
'''
Print out YAML using the block mode
'''
params = {}
if 'output_indent' not in __opts__:
# default indentation
params.update(default_flow_style=False)
elif __opts__['output_indent'] >= 0:
# custom indent
... |
Convert an AutoYAST file to an SLS file | def mksls(src, dst=None):
'''
Convert an AutoYAST file to an SLS file
'''
with salt.utils.files.fopen(src, 'r') as fh_:
ps_opts = xml.to_dict(ET.fromstring(fh_.read()))
if dst is not None:
with salt.utils.files.fopen(dst, 'w') as fh_:
salt.utils.yaml.safe_dump(ps_opts, f... |
Return the color theme to use | def get_color_theme(theme):
'''
Return the color theme to use
'''
# Keep the heavy lifting out of the module space
import salt.utils.data
import salt.utils.files
import salt.utils.yaml
if not os.path.isfile(theme):
log.warning('The named theme %s if not available', theme)
tr... |
Return the colors as an easy to use dict. Pass `False` to deactivate all
colors by setting them to empty strings. Pass a string containing only the
name of a single color to be used in place of all colors. Examples:
.. code-block:: python
colors = get_colors() # enable all colors
no_color... | def get_colors(use=True, theme=None):
'''
Return the colors as an easy to use dict. Pass `False` to deactivate all
colors by setting them to empty strings. Pass a string containing only the
name of a single color to be used in place of all colors. Examples:
.. code-block:: python
colors = ... |
Creates new user group.
NOTE: This function accepts all standard user group properties: keyword argument names differ depending on your
zabbix version, see:
https://www.zabbix.com/documentation/2.0/manual/appendix/api/usergroup/definitions#user_group
.. versionadded:: 2016.3.0
:param name: name of... | def present(name, **kwargs):
'''
Creates new user group.
NOTE: This function accepts all standard user group properties: keyword argument names differ depending on your
zabbix version, see:
https://www.zabbix.com/documentation/2.0/manual/appendix/api/usergroup/definitions#user_group
.. versiona... |
Ensures that the user group does not exist, eventually delete user group.
.. versionadded:: 2016.3.0
:param name: name of the user group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (... | def absent(name, **kwargs):
'''
Ensures that the user group does not exist, eventually delete user group.
.. versionadded:: 2016.3.0
:param name: name of the user group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connectio... |
Return configuration | def _get_config(**kwargs):
'''
Return configuration
'''
config = {
'filter_id_regex': ['.*!doc_skip'],
'filter_function_regex': [],
'replace_text_regex': {},
'proccesser': 'highstate_doc.proccesser_markdown',
'max_render_file_size': 10000,
'note': None
... |
output the contents of a file:
this is a workaround if the cp.push module does not work.
https://github.com/saltstack/salt/issues/37133
help the master output the contents of a document
that might be saved on the minions filesystem.
.. code-block:: python
#!/bin/python
import os
... | def read_file(name):
'''
output the contents of a file:
this is a workaround if the cp.push module does not work.
https://github.com/saltstack/salt/issues/37133
help the master output the contents of a document
that might be saved on the minions filesystem.
.. code-block:: python
... |
Render highstate to a text format (default Markdown)
if `jinja_template_text` is not set, `jinja_template_function` is used.
jinja_template_text: jinja text that the render uses to create the document.
jinja_template_function: a salt module call that returns template text.
options:
hig... | def render(jinja_template_text=None, jinja_template_function='highstate_doc.markdown_default_jinja_template', **kwargs):
'''
Render highstate to a text format (default Markdown)
if `jinja_template_text` is not set, `jinja_template_function` is used.
jinja_template_text: jinja text that the render uses... |
return proccessed lowstate data that was not blacklisted
render_module_function is used to provide your own.
defaults to from_lowstate | def proccess_lowstates(**kwargs):
'''
return proccessed lowstate data that was not blacklisted
render_module_function is used to provide your own.
defaults to from_lowstate
'''
states = []
config = _get_config(**kwargs)
proccesser = config.get('proccesser')
ls = __salt__['state.show... |
return a data dict in yaml string format. | def _state_data_to_yaml_string(data, whitelist=None, blacklist=None):
'''
return a data dict in yaml string format.
'''
y = {}
if blacklist is None:
# TODO: use salt defined STATE_REQUISITE_IN_KEYWORDS STATE_RUNTIME_KEYWORDS STATE_INTERNAL_KEYWORDS
blacklist = ['__env__', '__id__',... |
format requisite as a link users can click | def _format_markdown_requisite(state, stateid, makelink=True):
'''
format requisite as a link users can click
'''
fmt_id = '{0}: {1}'.format(state, stateid)
if makelink:
return ' * [{0}](#{1})\n'.format(fmt_id, _format_markdown_link(fmt_id))
else:
return ' * `{0}`\n'.format(fmt_i... |
Takes low state data and returns a dict of proccessed data
that is by default used in a jinja template when rendering a markdown highstate_doc.
This `lowstate_item_markdown` given a lowstate item, returns a dict like:
.. code-block:: yaml
vars: # the raw lowstate_item that was proccessed
... | def proccesser_markdown(lowstate_item, config, **kwargs):
'''
Takes low state data and returns a dict of proccessed data
that is by default used in a jinja template when rendering a markdown highstate_doc.
This `lowstate_item_markdown` given a lowstate item, returns a dict like:
.. code-block:: ya... |
Helper function to return the results of the GetVersionExW Windows API call.
It is a ctypes Structure that contains Windows OS Version information.
Returns:
class: An instance of a class containing version info | def os_version_info_ex():
'''
Helper function to return the results of the GetVersionExW Windows API call.
It is a ctypes Structure that contains Windows OS Version information.
Returns:
class: An instance of a class containing version info
'''
if not HAS_WIN32:
return
clas... |
Gets information about the domain/workgroup. This will tell you if the
system is joined to a domain or a workgroup
.. version-added:: 2018.3.4
Returns:
dict: A dictionary containing the domain/workgroup and it's status | def get_join_info():
'''
Gets information about the domain/workgroup. This will tell you if the
system is joined to a domain or a workgroup
.. version-added:: 2018.3.4
Returns:
dict: A dictionary containing the domain/workgroup and it's status
'''
info = win32net.NetGetJoinInformat... |
Run a dscl -create command | def _dscl(cmd, ctype='create'):
'''
Run a dscl -create command
'''
if __grains__['osrelease_info'] < (10, 8):
source, noderoot = '.', ''
else:
source, noderoot = 'localhost', '/Local/Default'
if noderoot:
cmd[0] = noderoot + cmd[0]
return __salt__['cmd.run_all'](
... |
Add a user to the minion
CLI Example:
.. code-block:: bash
salt '*' user.add name <uid> <gid> <groups> <home> <shell> | def add(name,
uid=None,
gid=None,
groups=None,
home=None,
shell=None,
fullname=None,
createhome=True,
**kwargs):
'''
Add a user to the minion
CLI Example:
.. code-block:: bash
salt '*' user.add name <uid> <gid> <groups> <home> <s... |
Remove a user from the minion
CLI Example:
.. code-block:: bash
salt '*' user.delete name remove=True force=True | def delete(name, remove=False, force=False):
'''
Remove a user from the minion
CLI Example:
.. code-block:: bash
salt '*' user.delete name remove=True force=True
'''
if salt.utils.stringutils.contains_whitespace(name):
raise SaltInvocationError('Username cannot contain whitesp... |
Return the list of all info for all users
CLI Example:
.. code-block:: bash
salt '*' user.getent | def getent(refresh=False):
'''
Return the list of all info for all users
CLI Example:
.. code-block:: bash
salt '*' user.getent
'''
if 'user.getent' in __context__ and not refresh:
return __context__['user.getent']
ret = []
for data in pwd.getpwall():
ret.appe... |
Change the uid for a named user
CLI Example:
.. code-block:: bash
salt '*' user.chuid foo 4376 | def chuid(name, uid):
'''
Change the uid for a named user
CLI Example:
.. code-block:: bash
salt '*' user.chuid foo 4376
'''
if not isinstance(uid, int):
raise SaltInvocationError('uid must be an integer')
pre_info = info(name)
if not pre_info:
raise CommandExe... |
Change the default group of the user
CLI Example:
.. code-block:: bash
salt '*' user.chgid foo 4376 | def chgid(name, gid):
'''
Change the default group of the user
CLI Example:
.. code-block:: bash
salt '*' user.chgid foo 4376
'''
if not isinstance(gid, int):
raise SaltInvocationError('gid must be an integer')
pre_info = info(name)
if not pre_info:
raise Comma... |
Change the default shell of the user
CLI Example:
.. code-block:: bash
salt '*' user.chshell foo /bin/zsh | def chshell(name, shell):
'''
Change the default shell of the user
CLI Example:
.. code-block:: bash
salt '*' user.chshell foo /bin/zsh
'''
pre_info = info(name)
if not pre_info:
raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
if shell == pre_in... |
Change the home directory of the user
CLI Example:
.. code-block:: bash
salt '*' user.chhome foo /Users/foo | def chhome(name, home, **kwargs):
'''
Change the home directory of the user
CLI Example:
.. code-block:: bash
salt '*' user.chhome foo /Users/foo
'''
kwargs = salt.utils.args.clean_kwargs(**kwargs)
persist = kwargs.pop('persist', False)
if kwargs:
salt.utils.args.inval... |
Change the user's Full Name
CLI Example:
.. code-block:: bash
salt '*' user.chfullname foo 'Foo Bar' | def chfullname(name, fullname):
'''
Change the user's Full Name
CLI Example:
.. code-block:: bash
salt '*' user.chfullname foo 'Foo Bar'
'''
fullname = salt.utils.data.decode(fullname)
pre_info = info(name)
if not pre_info:
raise CommandExecutionError('User \'{0}\' doe... |
Change the groups to which the user belongs. Note that the user's primary
group does not have to be one of the groups passed, membership in the
user's primary group is automatically assumed.
groups
Groups to which the user should belong, can be passed either as a
python list or a comma-sepa... | def chgroups(name, groups, append=False):
'''
Change the groups to which the user belongs. Note that the user's primary
group does not have to be one of the groups passed, membership in the
user's primary group is automatically assumed.
groups
Groups to which the user should belong, can be ... |
Return user information in a pretty way | def _format_info(data):
'''
Return user information in a pretty way
'''
return {'gid': data.pw_gid,
'groups': list_groups(data.pw_name),
'home': data.pw_dir,
'name': data.pw_name,
'shell': data.pw_shell,
'uid': data.pw_uid,
'fullnam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.