INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
.. versionadded:: 2016. 3. 0
def get(zpool, prop=None, show_source=False, parsable=True): ''' .. versionadded:: 2016.3.0 Retrieves the given list of properties zpool : string Name of storage pool prop : string Optional name of property to retrieve show_source : boolean Show source of property ...
Sets the given property on the specified pool
def set(zpool, prop, value): ''' Sets the given property on the specified pool zpool : string Name of storage pool prop : string Name of property to set value : string Value to set for the specified property .. versionadded:: 2016.3.0 CLI Example: .. code-bl...
Check if a ZFS storage pool is active
def exists(zpool): ''' Check if a ZFS storage pool is active zpool : string Name of storage pool CLI Example: .. code-block:: bash salt '*' zpool.exists myzpool ''' # list for zpool # NOTE: retcode > 0 if zpool does not exists res = __salt__['cmd.run_all']( ...
Destroys a storage pool
def destroy(zpool, force=False): ''' Destroys a storage pool zpool : string Name of storage pool force : boolean Force destroy of pool CLI Example: .. code-block:: bash salt '*' zpool.destroy myzpool ''' # destroy zpool res = __salt__['cmd.run_all']( ...
Scrub a storage pool
def scrub(zpool, stop=False, pause=False): ''' Scrub a storage pool zpool : string Name of storage pool stop : boolean If ``True``, cancel ongoing scrub pause : boolean If ``True``, pause ongoing scrub .. versionadded:: 2018.3.0 .. note:: Pau...
.. versionadded:: 2015. 5. 0
def create(zpool, *vdevs, **kwargs): ''' .. versionadded:: 2015.5.0 Create a simple zpool, a mirrored zpool, a zpool having nested VDEVs, a hybrid zpool with cache, spare and log drives or a zpool with RAIDZ-1, RAIDZ-2 or RAIDZ-3 zpool : string Name of storage pool vdevs : string ...
Add the specified vdev \ s to the given storage pool
def add(zpool, *vdevs, **kwargs): ''' Add the specified vdev\'s to the given storage pool zpool : string Name of storage pool vdevs : string One or more devices force : boolean Forces use of device CLI Example: .. code-block:: bash salt '*' zpool.add myz...
Attach specified device to zpool
def attach(zpool, device, new_device, force=False): ''' Attach specified device to zpool zpool : string Name of storage pool device : string Existing device name too new_device : string New device name (to be attached to ``device``) force : boolean Forces use ...
Detach specified device to zpool
def detach(zpool, device): ''' Detach specified device to zpool zpool : string Name of storage pool device : string Device to detach CLI Example: .. code-block:: bash salt '*' zpool.detach myzpool /path/to/vdev1 ''' ## Update storage pool res = __salt__[...
.. versionadded:: 2018. 3. 0
def split(zpool, newzpool, **kwargs): ''' .. versionadded:: 2018.3.0 Splits devices off pool creating newpool. .. note:: All vdevs in pool must be mirrors. At the time of the split, ``newzpool`` will be a replica of ``zpool``. After splitting, do not forget to import the new...
Replaces old_device with new_device
def replace(zpool, old_device, new_device=None, force=False): ''' Replaces ``old_device`` with ``new_device`` .. note:: This is equivalent to attaching ``new_device``, waiting for it to resilver, and then detaching ``old_device``. The size of ``new_device`` must be greater than or...
Creates file based virtual devices for a zpool
def create_file_vdev(size, *vdevs): ''' Creates file based virtual devices for a zpool CLI Example: .. code-block:: bash salt '*' zpool.create_file_vdev 7G /path/to/vdev1 [/path/to/vdev2] [...] .. note:: Depending on file size, the above command may take a while to return. ...
.. versionadded:: 2015. 5. 0
def export(*pools, **kwargs): ''' .. versionadded:: 2015.5.0 Export storage pools pools : string One or more storage pools to export force : boolean Force export of storage pools CLI Example: .. code-block:: bash salt '*' zpool.export myzpool ... [force=True|Fal...
.. versionadded:: 2015. 5. 0
def import_(zpool=None, new_name=None, **kwargs): ''' .. versionadded:: 2015.5.0 Import storage pools or list pools available for import zpool : string Optional name of storage pool new_name : string Optional new name for the storage pool mntopts : string Comma-separa...
.. versionadded:: 2015. 5. 0
def online(zpool, *vdevs, **kwargs): ''' .. versionadded:: 2015.5.0 Ensure that the specified devices are online zpool : string name of storage pool vdevs : string one or more devices expand : boolean Expand the device to use all available space. .. note:: ...
.. versionadded:: 2015. 5. 0
def offline(zpool, *vdevs, **kwargs): ''' .. versionadded:: 2015.5.0 Ensure that the specified devices are offline .. warning:: By default, the ``OFFLINE`` state is persistent. The device remains offline when the system is rebooted. To temporarily take a device offline, use ``...
.. versionadded:: 2018. 3. 0
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.
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
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
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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 ).
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 ).
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.
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
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
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
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
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
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
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.
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.
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
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
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
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
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
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.
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
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 )
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 )
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:
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 )
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
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
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
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
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
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
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
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.
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.
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.
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
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.
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.
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.
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::
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
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
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.
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.
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:...