INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
.. versionadded:: 2018.3.0
Removes ZFS label information from the specified device
device : string
Device name; must not be part of an active pool configuration.
force : boolean
Treat exported or foreign devices as inactive
CLI Example:
.. code-block:: bash
salt '*' zpo... | def labelclear(device, force=False):
'''
.. versionadded:: 2018.3.0
Removes ZFS label information from the specified device
device : string
Device name; must not be part of an active pool configuration.
force : boolean
Treat exported or foreign devices as inactive
CLI Example... |
Clears device errors in a pool.
.. warning::
The device must not be part of an active pool configuration.
zpool : string
name of storage pool
device : string
(optional) specific device to clear
.. versionadded:: 2018.3.1
CLI Example:
.. code-block:: bash
sa... | def clear(zpool, device=None):
'''
Clears device errors in a pool.
.. warning::
The device must not be part of an active pool configuration.
zpool : string
name of storage pool
device : string
(optional) specific device to clear
.. versionadded:: 2018.3.1
CLI Exa... |
Generates a new unique identifier for the pool
.. warning::
You must ensure that all devices in this pool are online and healthy
before performing this action.
zpool : string
name of storage pool
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt ... | def reguid(zpool):
'''
Generates a new unique identifier for the pool
.. warning::
You must ensure that all devices in this pool are online and healthy
before performing this action.
zpool : string
name of storage pool
.. versionadded:: 2016.3.0
CLI Example:
.. c... |
.. versionadded:: 2016.3.0
Enables all supported features on the given pool
zpool : string
Optional storage pool, applies to all otherwize
version : int
Version to upgrade to, if unspecified upgrade to the highest possible
.. warning::
Once this is done, the pool will no long... | def upgrade(zpool=None, version=None):
'''
.. versionadded:: 2016.3.0
Enables all supported features on the given pool
zpool : string
Optional storage pool, applies to all otherwize
version : int
Version to upgrade to, if unspecified upgrade to the highest possible
.. warning... |
.. versionadded:: 2016.3.0
Displays the command history of the specified pools, or all pools if no
pool is specified
zpool : string
Optional storage pool
internal : boolean
Toggle display of internally logged ZFS events
verbose : boolean
Toggle display of the user name, t... | def history(zpool=None, internal=False, verbose=False):
'''
.. versionadded:: 2016.3.0
Displays the command history of the specified pools, or all pools if no
pool is specified
zpool : string
Optional storage pool
internal : boolean
Toggle display of internally logged ZFS even... |
Ensure that the user is present with the specified properties
name
The name of the user to manage
passwd
The password of the user to manage
user
MongoDB user with sufficient privilege to create the user
password
Password for the admin user specified with the ``user`` ... | def present(name,
passwd,
database="admin",
user=None,
password=None,
host="localhost",
port=27017,
authdb=None,
roles=None):
'''
Ensure that the user is present with the specified properties
name
The na... |
Ensure that the named user is absent
name
The name of the user to remove
user
MongoDB user with sufficient privilege to create the user
password
Password for the admin user specified by the ``user`` parameter
host
The hostname/IP address of the MongoDB server
por... | def absent(name,
user=None,
password=None,
host=None,
port=None,
database="admin",
authdb=None):
'''
Ensure that the named user is absent
name
The name of the user to remove
user
MongoDB user with sufficient privilege to... |
Check to see if an autoscale group exists.
CLI example::
salt myminion boto_asg.exists myasg region=us-east-1 | def exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if an autoscale group exists.
CLI example::
salt myminion boto_asg.exists myasg region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
retries = 30
while True:
... |
Get the configuration for an autoscale group.
CLI example::
salt myminion boto_asg.get_config myasg region=us-east-1 | def get_config(name, region=None, key=None, keyid=None, profile=None):
'''
Get the configuration for an autoscale group.
CLI example::
salt myminion boto_asg.get_config myasg region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
retries = 30
wh... |
Create an autoscale group.
CLI example::
salt myminion boto_asg.create myasg mylc '["us-east-1a", "us-east-1e"]' 1 10 load_balancers='["myelb", "myelb2"]' tags='[{"key": "Name", value="myasg", "propagate_at_launch": True}]' | def create(name, launch_config_name, availability_zones, min_size, max_size,
desired_capacity=None, load_balancers=None, default_cooldown=None,
health_check_type=None, health_check_period=None,
placement_group=None, vpc_zone_identifier=None, tags=None,
termination_policies=No... |
Update an autoscale group.
CLI example::
salt myminion boto_asg.update myasg mylc '["us-east-1a", "us-east-1e"]' 1 10 load_balancers='["myelb", "myelb2"]' tags='[{"key": "Name", value="myasg", "propagate_at_launch": True}]' | def update(name, launch_config_name, availability_zones, min_size, max_size,
desired_capacity=None, load_balancers=None, default_cooldown=None,
health_check_type=None, health_check_period=None,
placement_group=None, vpc_zone_identifier=None, tags=None,
termination_policies=No... |
helper function to create scaling policies | def _create_scaling_policies(conn, as_name, scaling_policies):
'helper function to create scaling policies'
if scaling_policies:
for policy in scaling_policies:
policy = autoscale.policy.ScalingPolicy(
name=policy["name"],
as_name=as_name,
adju... |
Helper function to create scheduled actions | def _create_scheduled_actions(conn, as_name, scheduled_actions):
'''
Helper function to create scheduled actions
'''
if scheduled_actions:
for name, action in six.iteritems(scheduled_actions):
if 'start_time' in action and isinstance(action['start_time'], six.string_types):
... |
Get a mime multipart encoded string from a cloud-init dict. Currently
supports boothooks, scripts and cloud-config.
CLI Example:
.. code-block:: bash
salt myminion boto.get_cloud_init_mime <cloud init> | def get_cloud_init_mime(cloud_init):
'''
Get a mime multipart encoded string from a cloud-init dict. Currently
supports boothooks, scripts and cloud-config.
CLI Example:
.. code-block:: bash
salt myminion boto.get_cloud_init_mime <cloud init>
'''
if isinstance(cloud_init, six.stri... |
Check for a launch configuration's existence.
CLI example::
salt myminion boto_asg.launch_configuration_exists mylc | def launch_configuration_exists(name, region=None, key=None, keyid=None,
profile=None):
'''
Check for a launch configuration's existence.
CLI example::
salt myminion boto_asg.launch_configuration_exists mylc
'''
conn = _get_conn(region=region, key=key, keyid... |
Fetch and return all Launch Configuration with details.
CLI example::
salt myminion boto_asg.get_all_launch_configurations | def get_all_launch_configurations(region=None, key=None, keyid=None,
profile=None):
'''
Fetch and return all Launch Configuration with details.
CLI example::
salt myminion boto_asg.get_all_launch_configurations
'''
conn = _get_conn(region=region, key=key, ... |
List all Launch Configurations.
CLI example::
salt myminion boto_asg.list_launch_configurations | def list_launch_configurations(region=None, key=None, keyid=None,
profile=None):
'''
List all Launch Configurations.
CLI example::
salt myminion boto_asg.list_launch_configurations
'''
ret = get_all_launch_configurations(region, key, keyid, profile)
retu... |
Create a launch configuration.
CLI example::
salt myminion boto_asg.create_launch_configuration mylc image_id=ami-0b9c9f62 key_name='mykey' security_groups='["mygroup"]' instance_type='c3.2xlarge' | def create_launch_configuration(name, image_id, key_name=None,
vpc_id=None, vpc_name=None,
security_groups=None, user_data=None,
instance_type='m1.small', kernel_id=None,
ramdisk_id=None, bloc... |
Delete a launch configuration.
CLI example::
salt myminion boto_asg.delete_launch_configuration mylc | def delete_launch_configuration(name, region=None, key=None, keyid=None,
profile=None):
'''
Delete a launch configuration.
CLI example::
salt myminion boto_asg.delete_launch_configuration mylc
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile... |
Return the arn for a scaling policy in a specific autoscale group or None
if not found. Mainly used as a helper method for boto_cloudwatch_alarm, for
linking alarms to scaling policies.
CLI Example::
salt '*' boto_asg.get_scaling_policy_arn mygroup mypolicy | def get_scaling_policy_arn(as_group, scaling_policy_name, region=None,
key=None, keyid=None, profile=None):
'''
Return the arn for a scaling policy in a specific autoscale group or None
if not found. Mainly used as a helper method for boto_cloudwatch_alarm, for
linking alarms ... |
Return all AutoScale Groups visible in the account
(as a list of boto.ec2.autoscale.group.AutoScalingGroup).
.. versionadded:: 2016.11.0
CLI example:
.. code-block:: bash
salt-call boto_asg.get_all_groups region=us-east-1 --output yaml | def get_all_groups(region=None, key=None, keyid=None, profile=None):
'''
Return all AutoScale Groups visible in the account
(as a list of boto.ec2.autoscale.group.AutoScalingGroup).
.. versionadded:: 2016.11.0
CLI example:
.. code-block:: bash
salt-call boto_asg.get_all_groups region... |
Return all AutoScale Groups visible in the account
(as a list of names).
.. versionadded:: 2016.11.0
CLI example:
.. code-block:: bash
salt-call boto_asg.list_groups region=us-east-1 | def list_groups(region=None, key=None, keyid=None, profile=None):
'''
Return all AutoScale Groups visible in the account
(as a list of names).
.. versionadded:: 2016.11.0
CLI example:
.. code-block:: bash
salt-call boto_asg.list_groups region=us-east-1
'''
return [a.name for... |
return attribute of all instances in the named autoscale group.
CLI example::
salt-call boto_asg.get_instances my_autoscale_group_name | def get_instances(name, lifecycle_state="InService", health_status="Healthy",
attribute="private_ip_address", attributes=None, region=None,
key=None, keyid=None, profile=None):
'''
return attribute of all instances in the named autoscale group.
CLI example::
sal... |
Exit desired instances from StandBy mode
.. versionadded:: 2016.11.0
CLI example::
salt-call boto_asg.exit_standby my_autoscale_group_name '["i-xxxxxx"]' | def exit_standby(name, instance_ids, should_decrement_desired_capacity=False,
region=None, key=None, keyid=None, profile=None):
'''
Exit desired instances from StandBy mode
.. versionadded:: 2016.11.0
CLI example::
salt-call boto_asg.exit_standby my_autoscale_group_name '["i... |
List SCSI devices, with details
CLI Examples:
.. code-block:: bash
salt '*' scsi.ls
salt '*' scsi.ls get_size=False
get_size : True
Get the size information for scsi devices. This option
should be set to False for older OS distributions (RHEL6 and older)
due to l... | def ls_(get_size=True):
'''
List SCSI devices, with details
CLI Examples:
.. code-block:: bash
salt '*' scsi.ls
salt '*' scsi.ls get_size=False
get_size : True
Get the size information for scsi devices. This option
should be set to False for older OS distribution... |
List scsi devices
CLI Example:
.. code-block:: bash
salt '*' scsi.rescan_all 0 | def rescan_all(host):
'''
List scsi devices
CLI Example:
.. code-block:: bash
salt '*' scsi.rescan_all 0
'''
if os.path.isdir('/sys/class/scsi_host/host{0}'.format(host)):
cmd = 'echo "- - -" > /sys/class/scsi_host/host{0}/scan'.format(host)
else:
return 'Host {0} ... |
Retrieves the vsan_datastore | def _get_vsan_datastore(si, cluster_name):
'''Retrieves the vsan_datastore'''
log.trace('Retrieving vsan datastore')
vsan_datastores = [ds for ds in
__salt__['vsphere.list_datastores_via_proxy'](
service_instance=si)
if ds['type'] == ... |
Configures a cluster. Creates a new cluster, if it doesn't exist on the
vCenter or reconfigures it if configured differently
Supported proxies: esxdatacenter, esxcluster
name
Name of the state. If the state is run in by an ``esxdatacenter``
proxy, it will be the name of the cluster.
c... | def cluster_configured(name, cluster_config):
'''
Configures a cluster. Creates a new cluster, if it doesn't exist on the
vCenter or reconfigures it if configured differently
Supported proxies: esxdatacenter, esxcluster
name
Name of the state. If the state is run in by an ``esxdatacenter``... |
Configures the cluster's VSAN datastore
WARNING: The VSAN datastore is created automatically after the first
ESXi host is added to the cluster; the state assumes that the datastore
exists and errors if it doesn't. | def vsan_datastore_configured(name, datastore_name):
'''
Configures the cluster's VSAN datastore
WARNING: The VSAN datastore is created automatically after the first
ESXi host is added to the cluster; the state assumes that the datastore
exists and errors if it doesn't.
'''
cluster_name, d... |
Configures licenses on the cluster entity
Checks if each license exists on the server:
- if it doesn't, it creates it
Check if license is assigned to the cluster:
- if it's not assigned to the cluster:
- assign it to the cluster if there is space
- error if there's no sp... | def licenses_configured(name, licenses=None):
'''
Configures licenses on the cluster entity
Checks if each license exists on the server:
- if it doesn't, it creates it
Check if license is assigned to the cluster:
- if it's not assigned to the cluster:
- assign it to the clus... |
Get system encoding. Most of this code is a part of salt/__init__.py | def get_system_encoding():
'''
Get system encoding. Most of this code is a part of salt/__init__.py
'''
# This is the most trustworthy source of the system encoding, though, if
# salt is being imported after being daemonized, this information is lost
# and reset to None
encoding = None
... |
Salt thin needs to be deployed - prep the target directory and emit the
delimiter and exit code that signals a required deployment. | def need_deployment():
'''
Salt thin needs to be deployed - prep the target directory and emit the
delimiter and exit code that signals a required deployment.
'''
if os.path.exists(OPTIONS.saltdir):
shutil.rmtree(OPTIONS.saltdir)
old_umask = os.umask(0o077) # pylint: disable=blacklisted... |
Generate a hash digest string for a file. | def get_hash(path, form='sha1', chunk_size=4096):
'''
Generate a hash digest string for a file.
'''
try:
hash_type = getattr(hashlib, form)
except AttributeError:
raise ValueError('Invalid hash type: {0}'.format(form))
with open(path, 'rb') as ifile:
hash_obj = hash_type(... |
Unpack the Salt thin archive. | def unpack_thin(thin_path):
'''
Unpack the Salt thin archive.
'''
tfile = tarfile.TarFile.gzopen(thin_path)
old_umask = os.umask(0o077) # pylint: disable=blacklisted-function
tfile.extractall(path=OPTIONS.saltdir)
tfile.close()
os.umask(old_umask) # pylint: disable=blacklisted-function... |
Signal that external modules need to be deployed. | def need_ext():
'''
Signal that external modules need to be deployed.
'''
sys.stdout.write("{0}\next_mods\n".format(OPTIONS.delimiter))
sys.exit(EX_MOD_DEPLOY) |
Unpack the external modules. | def unpack_ext(ext_path):
'''
Unpack the external modules.
'''
modcache = os.path.join(
OPTIONS.saltdir,
'running_data',
'var',
'cache',
'salt',
'minion',
'extmods')
tfile = tarfile.TarFile.gzopen(ext_path)
old_u... |
Reset atime/mtime on all files to prevent systemd swipes only part of the files in the /tmp. | def reset_time(path='.', amt=None):
'''
Reset atime/mtime on all files to prevent systemd swipes only part of the files in the /tmp.
'''
if not amt:
amt = int(time.time())
for fname in os.listdir(path):
fname = os.path.join(path, fname)
if os.path.isdir(fname):
re... |
Find executable which matches supported python version in the thin | def get_executable():
'''
Find executable which matches supported python version in the thin
'''
pymap = {}
with open(os.path.join(OPTIONS.saltdir, 'supported-versions')) as _fp:
for line in _fp.readlines():
ns, v_maj, v_min = line.strip().split(':')
pymap[ns] = (int(... |
Main program body | def main(argv): # pylint: disable=W0613
'''
Main program body
'''
thin_path = os.path.join(OPTIONS.saltdir, THIN_ARCHIVE)
if os.path.isfile(thin_path):
if OPTIONS.checksum != get_hash(thin_path, OPTIONS.hashfunc):
need_deployment()
unpack_thin(thin_path)
# Salt t... |
Mount the device in a temporary place. | def _mount(device):
'''
Mount the device in a temporary place.
'''
dest = tempfile.mkdtemp()
res = __states__['mount.mounted'](dest, device=device, fstype='btrfs',
opts='subvol=/', persist=False)
if not res['result']:
log.error('Cannot mount device %... |
Check if the subvolume is the current default. | def _is_default(path, dest, name):
'''
Check if the subvolume is the current default.
'''
subvol_id = __salt__['btrfs.subvolume_show'](path)[name]['subvolume id']
def_id = __salt__['btrfs.subvolume_get_default'](dest)['id']
return subvol_id == def_id |
Set the subvolume as the current default. | def _set_default(path, dest, name):
'''
Set the subvolume as the current default.
'''
subvol_id = __salt__['btrfs.subvolume_show'](path)[name]['subvolume id']
return __salt__['btrfs.subvolume_set_default'](subvol_id, dest) |
Check if the subvolume is copy on write | def _is_cow(path):
'''
Check if the subvolume is copy on write
'''
dirname = os.path.dirname(path)
return 'C' not in __salt__['file.lsattr'](dirname)[path] |
Small decorator to makes sure that the mount and umount happends in
a transactional way. | def __mount_device(action):
'''
Small decorator to makes sure that the mount and umount happends in
a transactional way.
'''
@functools.wraps(action)
def wrapper(*args, **kwargs):
name = kwargs['name']
device = kwargs['device']
ret = {
'name': name,
... |
Makes sure that a btrfs subvolume is present.
name
Name of the subvolume to add
device
Device where to create the subvolume
qgroupids
Add the newly created subcolume to a qgroup. This parameter
is a list
set_default
If True, this new subvolume will be set as... | def subvolume_created(name, device, qgroupids=None, set_default=False,
copy_on_write=True, force_set_default=True,
__dest=None):
'''
Makes sure that a btrfs subvolume is present.
name
Name of the subvolume to add
device
Device where to create... |
Makes sure that a btrfs subvolume is removed.
name
Name of the subvolume to remove
device
Device where to remove the subvolume
commit
Wait until the transaction is over | def subvolume_deleted(name, device, commit=False, __dest=None):
'''
Makes sure that a btrfs subvolume is removed.
name
Name of the subvolume to remove
device
Device where to remove the subvolume
commit
Wait until the transaction is over
'''
ret = {
'name':... |
Execute a command and read the output as YAML | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
command):
'''
Execute a command and read the output as YAML
'''
try:
command = command.replace('%s', minion_id)
output = __salt__['cmd.run_stdout'](command, python_shell=True... |
.. versionadded:: Fluorine
Ensure a DNS zone exists.
:param name:
Name of the DNS zone (without a terminating dot).
:param resource_group:
The resource group assigned to the DNS zone.
:param etag:
The etag of the zone. `Etags <https://docs.microsoft.com/en-us/azure/dns/dns-zo... | def zone_present(name, resource_group, etag=None, if_match=None, if_none_match=None,
registration_virtual_networks=None, resolution_virtual_networks=None,
tags=None, zone_type='Public', connection_auth=None, **kwargs):
'''
.. versionadded:: Fluorine
Ensure a DNS zone exist... |
.. versionadded:: Fluorine
Ensure a DNS zone does not exist in the resource group.
:param name:
Name of the DNS zone.
:param resource_group:
The resource group assigned to the DNS zone.
:param connection_auth:
A dict with subscription and authentication parameters to be used ... | def zone_absent(name, resource_group, connection_auth=None):
'''
.. versionadded:: Fluorine
Ensure a DNS zone does not exist in the resource group.
:param name:
Name of the DNS zone.
:param resource_group:
The resource group assigned to the DNS zone.
:param connection_auth:
... |
.. versionadded:: Fluorine
Ensure a record set exists in a DNS zone.
:param name:
The name of the record set, relative to the name of the zone.
:param zone_name:
Name of the DNS zone (without a terminating dot).
:param resource_group:
The resource group assigned to the DNS zo... | def record_set_present(name, zone_name, resource_group, record_type, if_match=None, if_none_match=None,
etag=None, metadata=None, ttl=None, arecords=None, aaaa_records=None, mx_records=None,
ns_records=None, ptr_records=None, srv_records=None, txt_records=None, cname_record... |
.. versionadded:: Fluorine
Ensure a record set does not exist in the DNS zone.
:param name:
Name of the record set.
:param zone_name:
Name of the DNS zone.
:param resource_group:
The resource group assigned to the DNS zone.
:param connection_auth:
A dict with sub... | def record_set_absent(name, zone_name, resource_group, connection_auth=None):
'''
.. versionadded:: Fluorine
Ensure a record set does not exist in the DNS zone.
:param name:
Name of the record set.
:param zone_name:
Name of the DNS zone.
:param resource_group:
The res... |
Parse the given atom, allowing access to its parts
Success does not mean that the atom exists, just that it
is in the correct format.
Returns none if the atom is invalid. | def _get_config_file(conf, atom):
'''
Parse the given atom, allowing access to its parts
Success does not mean that the atom exists, just that it
is in the correct format.
Returns none if the atom is invalid.
'''
if '*' in atom:
parts = portage.dep.Atom(atom, allow_wildcard=True)
... |
add version to category/package
@cp - name of package in format category/name
@installed - boolean value, if False, function returns cpv
for latest available package | def _get_cpv(cp, installed=True):
'''
add version to category/package
@cp - name of package in format category/name
@installed - boolean value, if False, function returns cpv
for latest available package
'''
if installed:
return _get_portage().db[portage.root]['vartree'].dep_bestmatc... |
Merge /etc/portage/package.keywords and
/etc/portage/package.accept_keywords. | def _unify_keywords():
'''
Merge /etc/portage/package.keywords and
/etc/portage/package.accept_keywords.
'''
old_path = BASE_PATH.format('keywords')
if os.path.exists(old_path):
if os.path.isdir(old_path):
for triplet in salt.utils.path.os_walk(old_path):
for ... |
Convert a config file to a config directory. | def _package_conf_file_to_dir(file_name):
'''
Convert a config file to a config directory.
'''
if file_name in SUPPORTED_CONFS:
path = BASE_PATH.format(file_name)
if os.path.exists(path):
if os.path.isdir(path):
return False
else:
o... |
Move entries in the correct file. | def _package_conf_ordering(conf, clean=True, keep_backup=False):
'''
Move entries in the correct file.
'''
if conf in SUPPORTED_CONFS:
rearrange = []
path = BASE_PATH.format(conf)
backup_files = []
for triplet in salt.utils.path.os_walk(path):
for file_name ... |
check compatibility of accept_keywords | def _check_accept_keywords(approved, flag):
'''check compatibility of accept_keywords'''
if flag in approved:
return False
elif (flag.startswith('~') and flag[1:] in approved) \
or ('~'+flag in approved):
return False
else:
return True |
Merges multiple lists of flags removing duplicates and resolving conflicts
giving priority to lasts lists. | def _merge_flags(new_flags, old_flags=None, conf='any'):
'''
Merges multiple lists of flags removing duplicates and resolving conflicts
giving priority to lasts lists.
'''
if not old_flags:
old_flags = []
args = [old_flags, new_flags]
if conf == 'accept_keywords':
tmp = new_f... |
Append a string or a list of flags for a given package or DEPEND atom to a
given configuration file.
CLI Example:
.. code-block:: bash
salt '*' portage_config.append_to_package_conf use string="app-admin/salt ldap -libvirt"
salt '*' portage_config.append_to_package_conf use atom="> = app-... | def append_to_package_conf(conf, atom='', flags=None, string='', overwrite=False):
'''
Append a string or a list of flags for a given package or DEPEND atom to a
given configuration file.
CLI Example:
.. code-block:: bash
salt '*' portage_config.append_to_package_conf use string="app-admi... |
Append a list of use flags for a given package or DEPEND atom
CLI Example:
.. code-block:: bash
salt '*' portage_config.append_use_flags "app-admin/salt[ldap, -libvirt]"
salt '*' portage_config.append_use_flags ">=app-admin/salt-0.14.1" "['ldap', '-libvirt']" | def append_use_flags(atom, uses=None, overwrite=False):
'''
Append a list of use flags for a given package or DEPEND atom
CLI Example:
.. code-block:: bash
salt '*' portage_config.append_use_flags "app-admin/salt[ldap, -libvirt]"
salt '*' portage_config.append_use_flags ">=app-admin/s... |
Get flags for a given package or DEPEND atom.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*' portage_config.get_flags_from_package_conf license salt | def get_flags_from_package_conf(conf, atom):
'''
Get flags for a given package or DEPEND atom.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*' portage_config.get_flag... |
Verify if the given package or DEPEND atom has the given flag.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*' portage_config.has_flag license salt Apache-2.0 | def has_flag(conf, atom, flag):
'''
Verify if the given package or DEPEND atom has the given flag.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*' portage_config.has_... |
Find out which of the given flags are currently not set.
CLI Example:
.. code-block:: bash
salt '*' portage_config.get_missing_flags use salt "['ldap', '-libvirt', 'openssl']" | def get_missing_flags(conf, atom, flags):
'''
Find out which of the given flags are currently not set.
CLI Example:
.. code-block:: bash
salt '*' portage_config.get_missing_flags use salt "['ldap', '-libvirt', 'openssl']"
'''
new_flags = []
for flag in flags:
if not has_fla... |
Tell if a given package or DEPEND atom is present in the configuration
files tree.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*' portage_config.is_present unmask salt | def is_present(conf, atom):
'''
Tell if a given package or DEPEND atom is present in the configuration
files tree.
Warning: This only works if the configuration files tree is in the correct
format (the one enforced by enforce_nice_config)
CLI Example:
.. code-block:: bash
salt '*'... |
.. versionadded:: 2015.8.0
Gets the current IUSE flags from the tree.
@type: cpv: string
@param cpv: cat/pkg
@rtype list
@returns [] or the list of IUSE flags | def get_iuse(cp):
'''
.. versionadded:: 2015.8.0
Gets the current IUSE flags from the tree.
@type: cpv: string
@param cpv: cat/pkg
@rtype list
@returns [] or the list of IUSE flags
'''
cpv = _get_cpv(cp)
try:
# aux_get might return dupes, so run them through set() to re... |
.. versionadded:: 2015.8.0
Gets the installed USE flags from the VARDB.
@type: cp: string
@param cp: cat/pkg
@type use: string
@param use: 1 of ["USE", "PKGUSE"]
@rtype list
@returns [] or the list of IUSE flags | def get_installed_use(cp, use="USE"):
'''
.. versionadded:: 2015.8.0
Gets the installed USE flags from the VARDB.
@type: cp: string
@param cp: cat/pkg
@type use: string
@param use: 1 of ["USE", "PKGUSE"]
@rtype list
@returns [] or the list of IUSE flags
'''
portage = _get_p... |
.. versionadded:: 2015.8.0
Filter function to remove hidden or otherwise not normally
visible USE flags from a list.
@type use: list
@param use: the USE flag list to be filtered.
@type use_expand_hidden: list
@param use_expand_hidden: list of flags hidden.
@type usemasked: list
@param... | def filter_flags(use, use_expand_hidden, usemasked, useforced):
'''
.. versionadded:: 2015.8.0
Filter function to remove hidden or otherwise not normally
visible USE flags from a list.
@type use: list
@param use: the USE flag list to be filtered.
@type use_expand_hidden: list
@param u... |
.. versionadded:: 2015.8.0
Uses portage to determine final USE flags and settings for an emerge.
@type cp: string
@param cp: eg cat/pkg
@rtype: lists
@return use, use_expand_hidden, usemask, useforce | def get_all_cpv_use(cp):
'''
.. versionadded:: 2015.8.0
Uses portage to determine final USE flags and settings for an emerge.
@type cp: string
@param cp: eg cat/pkg
@rtype: lists
@return use, use_expand_hidden, usemask, useforce
'''
cpv = _get_cpv(cp)
portage = _get_portage()
... |
.. versionadded:: 2015.8.0
Uses portage for compare use flags which is used for installing package
and use flags which now exist int /etc/portage/package.use/
@type cp: string
@param cp: eg cat/pkg
@rtype: tuple
@rparam: tuple with two lists - list of used flags and
list of flags which wil... | def get_cleared_flags(cp):
'''
.. versionadded:: 2015.8.0
Uses portage for compare use flags which is used for installing package
and use flags which now exist int /etc/portage/package.use/
@type cp: string
@param cp: eg cat/pkg
@rtype: tuple
@rparam: tuple with two lists - list of use... |
.. versionadded:: 2015.8.0
Uses portage for determine if the use flags of installed package
is compatible with use flags in portage configs.
@type cp: string
@param cp: eg cat/pkg | def is_changed_uses(cp):
'''
.. versionadded:: 2015.8.0
Uses portage for determine if the use flags of installed package
is compatible with use flags in portage configs.
@type cp: string
@param cp: eg cat/pkg
'''
cpv = _get_cpv(cp)
i_flags, conf_flags = get_cleared_flags(cpv)
f... |
List existing device-mapper device details. | def active():
'''
List existing device-mapper device details.
'''
ret = {}
# TODO: This command should be extended to collect more information, such as UUID.
devices = __salt__['cmd.run_stdout']('dmsetup ls --target crypt')
out_regex = re.compile(r'(?P<devname>\w+)\W+\((?P<major>\d+), (?P<mi... |
List the contents of the crypttab
CLI Example:
.. code-block:: bash
salt '*' cryptdev.crypttab | def crypttab(config='/etc/crypttab'):
'''
List the contents of the crypttab
CLI Example:
.. code-block:: bash
salt '*' cryptdev.crypttab
'''
ret = {}
if not os.path.isfile(config):
return ret
with salt.utils.files.fopen(config) as ifile:
for line in ifile:
... |
Remove the named mapping from the crypttab. If the described entry does not
exist, nothing is changed, but the command succeeds by returning
``'absent'``. If a line is removed, it returns ``'change'``.
CLI Example:
.. code-block:: bash
salt '*' cryptdev.rm_crypttab foo | def rm_crypttab(name, config='/etc/crypttab'):
'''
Remove the named mapping from the crypttab. If the described entry does not
exist, nothing is changed, but the command succeeds by returning
``'absent'``. If a line is removed, it returns ``'change'``.
CLI Example:
.. code-block:: bash
... |
Verify that this device is represented in the crypttab, change the device to
match the name passed, or add the name if it is not present.
CLI Example:
.. code-block:: bash
salt '*' cryptdev.set_crypttab foo /dev/sdz1 mypassword swap,size=256 | def set_crypttab(
name,
device,
password='none',
options='',
config='/etc/crypttab',
test=False,
match_on='name'):
'''
Verify that this device is represented in the crypttab, change the device to
match the name passed, or add the name if it is not pres... |
Open a crypt device using ``cryptsetup``. The ``keyfile`` must not be
``None`` or ``'none'``, because ``cryptsetup`` will otherwise ask for the
password interactively.
CLI Example:
.. code-block:: bash
salt '*' cryptdev.open foo /dev/sdz1 /path/to/keyfile | def open(name, device, keyfile):
'''
Open a crypt device using ``cryptsetup``. The ``keyfile`` must not be
``None`` or ``'none'``, because ``cryptsetup`` will otherwise ask for the
password interactively.
CLI Example:
.. code-block:: bash
salt '*' cryptdev.open foo /dev/sdz1 /path/to/... |
Ensure domain exists and is up-to-date
name
Name of the domain
domain
The name or id of the domain
enabled
Boolean to control if domain is enabled
description
An arbitrary description of the domain
password
The user password
email
The users e... | def present(name, auth=None, **kwargs):
'''
Ensure domain exists and is up-to-date
name
Name of the domain
domain
The name or id of the domain
enabled
Boolean to control if domain is enabled
description
An arbitrary description of the domain
password
... |
Ensure that the named service is present.
name
The LVS server name
protocol
The service protocol
service_address
The LVS service address
server_address
The real server address.
packet_forward_method
The LVS packet forwarding method(``dr`` for direct routi... | def present(name,
protocol=None,
service_address=None,
server_address=None,
packet_forward_method='dr',
weight=1
):
'''
Ensure that the named service is present.
name
The LVS server name
protocol
The service protoco... |
Ensure the LVS Real Server in specified service is absent.
name
The name of the LVS server.
protocol
The service protocol(only support ``tcp``, ``udp`` and ``fwmark`` service).
service_address
The LVS service address.
server_address
The LVS real server address. | def absent(name, protocol=None, service_address=None, server_address=None):
'''
Ensure the LVS Real Server in specified service is absent.
name
The name of the LVS server.
protocol
The service protocol(only support ``tcp``, ``udp`` and ``fwmark`` service).
service_address
... |
Ensure that the cluster admin or database user is present.
name
The name of the user to manage
passwd
The password of the user
database
The database to create the user in
user
The user to connect as (must be able to create the user)
password
The password ... | def present(name,
passwd,
database=None,
user=None,
password=None,
host=None,
port=None):
'''
Ensure that the cluster admin or database user is present.
name
The name of the user to manage
passwd
The password of th... |
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs | def list_pkgs(versions_as_list=False, **kwargs):
'''
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(versions_as_list)
# not yet imple... |
Install the passed package
Return a dict containing the new package names and versions::
{'<package>': {'old': '<old-version>',
'new': '<new-version>'}}
CLI Example, Install one package:
.. code-block:: bash
salt '*' pkg.install <package name>
CLI Example, In... | def install(name=None, pkgs=None, sources=None, **kwargs):
'''
Install the passed package
Return a dict containing the new package names and versions::
{'<package>': {'old': '<old-version>',
'new': '<new-version>'}}
CLI Example, Install one package:
.. code-block::... |
Remove a single package with pkg_delete
Multiple Package Options:
pkgs
A list of packages to delete. Must be passed as a python list. The
``name`` parameter will be ignored if this option is passed.
.. versionadded:: 0.16.0
Returns a dict containing the changes.
CLI Example:
... | def remove(name=None, pkgs=None, purge=False, **kwargs):
'''
Remove a single package with pkg_delete
Multiple Package Options:
pkgs
A list of packages to delete. Must be passed as a python list. The
``name`` parameter will be ignored if this option is passed.
.. versionadded:: 0.1... |
Remove a package and extra configuration files.
name
The name of the package to be deleted.
Multiple Package Options:
pkgs
A list of packages to delete. Must be passed as a python list. The
``name`` parameter will be ignored if this option is passed.
.. versionadded:: 0.16.0... | def purge(name=None, pkgs=None, **kwargs):
'''
Remove a package and extra configuration files.
name
The name of the package to be deleted.
Multiple Package Options:
pkgs
A list of packages to delete. Must be passed as a python list. The
``name`` parameter will be ignored ... |
Run a full package upgrade (``pkg_add -u``), or upgrade a specific package
if ``name`` or ``pkgs`` is provided.
``name`` is ignored when ``pkgs`` is specified.
Returns a dictionary containing the changes:
.. versionadded:: 2019.2.0
.. code-block:: python
{'<package>': {'old': '<old-versi... | def upgrade(name=None,
pkgs=None,
**kwargs):
'''
Run a full package upgrade (``pkg_add -u``), or upgrade a specific package
if ``name`` or ``pkgs`` is provided.
``name`` is ignored when ``pkgs`` is specified.
Returns a dictionary containing the changes:
.. versionadded:... |
Ensure the data pipeline exists with matching definition.
name
Name of the service to ensure a data pipeline exists for.
pipeline_objects
Pipeline objects to use. Will override objects read from pillars.
pipeline_objects_from_pillars
The pillar key to use for lookup.
paramete... | def present(name, pipeline_objects=None,
pipeline_objects_from_pillars='boto_datapipeline_pipeline_objects',
parameter_objects=None,
parameter_objects_from_pillars='boto_datapipeline_parameter_objects',
parameter_values=None,
parameter_values_from_pillars='bot... |
Return true if the pipeline exists and the definition matches.
name
The name of the pipeline.
expected_pipeline_objects
Pipeline objects that must match the definition.
expected_parameter_objects
Parameter objects that must match the definition.
expected_parameter_values
... | def _pipeline_present_with_definition(name, expected_pipeline_objects,
expected_parameter_objects,
expected_parameter_values, region, key,
keyid, profile):
'''
Return true if the pipeline exists and... |
Return standardized pipeline objects to be used for comparing
Remove year, month, and day components of the startDateTime so that data
pipelines with the same time of day but different days are considered
equal. | def _cleaned(_pipeline_objects):
"""Return standardized pipeline objects to be used for comparing
Remove year, month, and day components of the startDateTime so that data
pipelines with the same time of day but different days are considered
equal.
"""
pipeline_objects = copy.deepcopy(_pipeline_... |
Return v1 == v2. Compares list, dict, recursively. | def _recursive_compare(v1, v2):
'''
Return v1 == v2. Compares list, dict, recursively.
'''
if isinstance(v1, list):
if v2 is None:
v2 = []
if len(v1) != len(v2):
return False
v1.sort(key=_id_or_key)
v2.sort(key=_id_or_key)
for x, y in zip(v... |
Return the value at key 'id' or 'key'. | def _id_or_key(list_item):
'''
Return the value at key 'id' or 'key'.
'''
if isinstance(list_item, dict):
if 'id' in list_item:
return list_item['id']
if 'key' in list_item:
return list_item['key']
return list_item |
Return string diff of pipeline definitions. | def _diff(old_pipeline_definition, new_pipeline_definition):
'''
Return string diff of pipeline definitions.
'''
old_pipeline_definition.pop('ResponseMetadata', None)
new_pipeline_definition.pop('ResponseMetadata', None)
diff = salt.utils.data.decode(difflib.unified_diff(
salt.utils.jso... |
Return standardized format for lists/dictionaries.
Lists of dictionaries are sorted by the value of the dictionary at
its primary key ('id' or 'key'). OrderedDict's are converted to
basic dictionaries. | def _standardize(structure):
'''
Return standardized format for lists/dictionaries.
Lists of dictionaries are sorted by the value of the dictionary at
its primary key ('id' or 'key'). OrderedDict's are converted to
basic dictionaries.
'''
def mutating_helper(structure):
if isinstanc... |
Return a list of pipeline objects that compose the pipeline
pipeline_objects_from_pillars
The pillar key to use for lookup
pipeline_object_overrides
Pipeline objects to use. Will override objects read from pillars. | def _pipeline_objects(pipeline_objects_from_pillars, pipeline_object_overrides):
'''
Return a list of pipeline objects that compose the pipeline
pipeline_objects_from_pillars
The pillar key to use for lookup
pipeline_object_overrides
Pipeline objects to use. Will override objects read ... |
Return a list of parameter objects that configure the pipeline
parameter_objects_from_pillars
The pillar key to use for lookup
parameter_object_overrides
Parameter objects to use. Will override objects read from pillars. | def _parameter_objects(parameter_objects_from_pillars, parameter_object_overrides):
'''
Return a list of parameter objects that configure the pipeline
parameter_objects_from_pillars
The pillar key to use for lookup
parameter_object_overrides
Parameter objects to use. Will override obje... |
Return a dictionary of parameter values that configure the pipeline
parameter_values_from_pillars
The pillar key to use for lookup
parameter_value_overrides
Parameter values to use. Will override values read from pillars. | def _parameter_values(parameter_values_from_pillars, parameter_value_overrides):
'''
Return a dictionary of parameter values that configure the pipeline
parameter_values_from_pillars
The pillar key to use for lookup
parameter_value_overrides
Parameter values to use. Will override value... |
Convert a dictionary to a list of dictionaries, where each element has
a key value pair {'id': key}. This makes it easy to override pillar values
while still satisfying the boto api. | def _dict_to_list_ids(objects):
'''
Convert a dictionary to a list of dictionaries, where each element has
a key value pair {'id': key}. This makes it easy to override pillar values
while still satisfying the boto api.
'''
list_with_ids = []
for key, value in six.iteritems(objects):
... |
Transforms dictionary into pipeline object properties.
The output format conforms to boto's specification.
Example input:
{
'a': '1',
'b': {
'ref': '2'
},
}
Example output:
[
{
'key': 'a',
... | def _properties_from_dict(d, key_name='key'):
'''
Transforms dictionary into pipeline object properties.
The output format conforms to boto's specification.
Example input:
{
'a': '1',
'b': {
'ref': '2'
},
}
Example output:
... |
Ensure a pipeline with the service_name does not exist
name
Name of the service to ensure a data pipeline does not exist for.
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and keyid, o... | def absent(name, region=None, key=None, keyid=None, profile=None):
'''
Ensure a pipeline with the service_name does not exist
name
Name of the service to ensure a data pipeline does not exist for.
region
Region to connect to.
key
Secret key to be used.
keyid
A... |
Deserialize any string or stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower json/simplejson module. | def deserialize(stream_or_string, **options):
'''
Deserialize any string or stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower json/simplejson module.
'''
try:
if not isinstance(stream_or_str... |
Serialize Python data to JSON.
:param obj: the data structure to serialize
:param options: options given to lower json/simplejson module. | def serialize(obj, **options):
'''
Serialize Python data to JSON.
:param obj: the data structure to serialize
:param options: options given to lower json/simplejson module.
'''
try:
if 'fp' in options:
return salt.utils.json.dump(obj, _json_module=_json, **options)
... |
Ensure that the named database is present with the specified properties
name
The name of the database to manage | def present(name, character_set=None, collate=None, **connection_args):
'''
Ensure that the named database is present with the specified properties
name
The name of the database to manage
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': 'Da... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.