INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Return the backend list
def backends(self, back=None): ''' Return the backend list ''' if not back: back = self.opts['fileserver_backend'] else: if not isinstance(back, list): try: back = back.split(',') except AttributeError: ...
Clear the cache of all of the fileserver backends that support the clear_cache function or the named backend(s) only.
def clear_cache(self, back=None): ''' Clear the cache of all of the fileserver backends that support the clear_cache function or the named backend(s) only. ''' back = self.backends(back) cleared = [] errors = [] for fsb in back: fstr = '{0}.cle...
``remote`` can either be a dictionary containing repo configuration information, or a pattern. If the latter, then remotes for which the URL matches the pattern will be locked.
def lock(self, back=None, remote=None): ''' ``remote`` can either be a dictionary containing repo configuration information, or a pattern. If the latter, then remotes for which the URL matches the pattern will be locked. ''' back = self.backends(back) locked = [] ...
Clear the update lock for the enabled fileserver backends back Only clear the update lock for the specified backend(s). The default is to clear the lock for all enabled backends remote If specified, then any remotes which contain the passed string will h...
def clear_lock(self, back=None, remote=None): ''' Clear the update lock for the enabled fileserver backends back Only clear the update lock for the specified backend(s). The default is to clear the lock for all enabled backends remote If specified, t...
Update all of the enabled fileserver backends which support the update function, or
def update(self, back=None): ''' Update all of the enabled fileserver backends which support the update function, or ''' back = self.backends(back) for fsb in back: fstr = '{0}.update'.format(fsb) if fstr in self.servers: log.debug(...
Return the update intervals for all of the enabled fileserver backends which support variable update intervals.
def update_intervals(self, back=None): ''' Return the update intervals for all of the enabled fileserver backends which support variable update intervals. ''' back = self.backends(back) ret = {} for fsb in back: fstr = '{0}.update_intervals'.format(fsb...
Return the environments for the named backend or all backends
def envs(self, back=None, sources=False): ''' Return the environments for the named backend or all backends ''' back = self.backends(back) ret = set() if sources: ret = {} for fsb in back: fstr = '{0}.envs'.format(fsb) kwargs = ...
Return environments for all backends for requests from fileclient
def file_envs(self, load=None): ''' Return environments for all backends for requests from fileclient ''' if load is None: load = {} load.pop('cmd', None) return self.envs(**load)
Initialize the backend, only do so if the fs supports an init function
def init(self, back=None): ''' Initialize the backend, only do so if the fs supports an init function ''' back = self.backends(back) for fsb in back: fstr = '{0}.init'.format(fsb) if fstr in self.servers: self.servers[fstr]()
Convenience function for calls made using the RemoteClient
def _find_file(self, load): ''' Convenience function for calls made using the RemoteClient ''' path = load.get('path') if not path: return {'path': '', 'rel': ''} tgt_env = load.get('saltenv', 'base') return self.find_file(path, tgt...
Convenience function for calls made using the LocalClient
def file_find(self, load): ''' Convenience function for calls made using the LocalClient ''' path = load.get('path') if not path: return {'path': '', 'rel': ''} tgt_env = load.get('saltenv', 'base') return self.find_file(path, tgt_e...
Find the path and return the fnd structure, this structure is passed to other backend interfaces.
def find_file(self, path, saltenv, back=None): ''' Find the path and return the fnd structure, this structure is passed to other backend interfaces. ''' path = salt.utils.stringutils.to_unicode(path) saltenv = salt.utils.stringutils.to_unicode(saltenv) back = self...
Serve up a chunk of a file
def serve_file(self, load): ''' Serve up a chunk of a file ''' ret = {'data': '', 'dest': ''} if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'path' not in load or 'loc' not in load or 'saltenv' not in...
Common code for hashing and stating files
def __file_hash_and_stat(self, load): ''' Common code for hashing and stating files ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'path' not in load or 'saltenv' not in load: return '', None if not i...
Deletes the file_lists cache files
def clear_file_list_cache(self, load): ''' Deletes the file_lists cache files ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') saltenv = load.get('saltenv', []) if saltenv is not None: if not isinstance(sa...
Return a list of files from the dominant environment
def file_list(self, load): ''' Return a list of files from the dominant environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = set() if 'saltenv' not in load: return [] if not isinstanc...
Return a list of symlinked files and dirs
def symlink_list(self, load): ''' Return a list of symlinked files and dirs ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if 'saltenv' not in load: return {} if not isinstance(load['sal...
Emulate the channel send method, the tries and timeout are not used
def send(self, load, tries=None, timeout=None, raw=False): # pylint: disable=unused-argument ''' Emulate the channel send method, the tries and timeout are not used ''' if 'cmd' not in load: log.error('Malformed request, no cmd: %s', load) return {} cmd =...
Accepts DSON data as a string or as a file object and runs it through the JSON parser. :rtype: A Python data structure
def render(dson_input, saltenv='base', sls='', **kwargs): ''' Accepts DSON data as a string or as a file object and runs it through the JSON parser. :rtype: A Python data structure ''' if not isinstance(dson_input, six.string_types): dson_input = dson_input.read() log.debug('DSON i...
Return the targets from the flat yaml file, checks opts for location but defaults to /etc/salt/roster
def targets(tgt, tgt_type='glob', **kwargs): ''' Return the targets from the flat yaml file, checks opts for location but defaults to /etc/salt/roster ''' rmatcher = RosterMatcher(tgt, tgt_type) return rmatcher.targets()
Return ip addrs based on netmask, sitting in the "glob" spot because it is the default
def targets(self): ''' Return ip addrs based on netmask, sitting in the "glob" spot because it is the default ''' addrs = () ret = {} ports = __opts__['ssh_scan_ports'] if not isinstance(ports, list): # Comma-separate list of integers ...
Evaluate a jsonnet input string. contents Raw jsonnet string to evaluate. jsonnet_library_paths List of jsonnet library paths.
def evaluate(contents, jsonnet_library_paths=None): ''' Evaluate a jsonnet input string. contents Raw jsonnet string to evaluate. jsonnet_library_paths List of jsonnet library paths. ''' if not jsonnet_library_paths: jsonnet_library_paths = __salt__['config.option']( ...
Parses fmdump output
def _parse_fmdump(output): ''' Parses fmdump output ''' result = [] output = output.split("\n") # extract header header = [field for field in output[0].lower().split(" ") if field] del output[0] # parse entries for entry in output: entry = [item for item in entry.split(...
Parses fmdump verbose output
def _parse_fmdump_verbose(output): ''' Parses fmdump verbose output ''' result = [] output = output.split("\n") fault = [] verbose_fault = {} for line in output: if line.startswith('TIME'): fault.append(line) if verbose_fault: result.appen...
Parsbb fmdump/fmadm output
def _parse_fmadm_config(output): ''' Parsbb fmdump/fmadm output ''' result = [] output = output.split("\n") # extract header header = [field for field in output[0].lower().split(" ") if field] del output[0] # parse entries for entry in output: entry = [item for item in ...
Internal function for fmadm.repqired, fmadm.replaced, fmadm.flush
def _fmadm_action_fmri(action, fmri): ''' Internal function for fmadm.repqired, fmadm.replaced, fmadm.flush ''' ret = {} fmadm = _check_fmadm() cmd = '{cmd} {action} {fmri}'.format( cmd=fmadm, action=action, fmri=fmri ) res = __salt__['cmd.run_all'](cmd) retco...
Parse fmadm faulty output
def _parse_fmadm_faulty(output): ''' Parse fmadm faulty output ''' def _merge_data(summary, fault): result = {} uuid = summary['event-id'] del summary['event-id'] result[uuid] = OrderedDict() result[uuid]['summary'] = summary result[uuid]['fault'] = fault...
Display fault management logs after : string filter events after time, see man fmdump for format before : string filter events before time, see man fmdump for format CLI Example: .. code-block:: bash salt '*' fmadm.list
def list_records(after=None, before=None): ''' Display fault management logs after : string filter events after time, see man fmdump for format before : string filter events before time, see man fmdump for format CLI Example: .. code-block:: bash salt '*' fmadm.list ...
Display log details uuid: string uuid of fault CLI Example: .. code-block:: bash salt '*' fmadm.show 11b4070f-4358-62fa-9e1e-998f485977e1
def show(uuid): ''' Display log details uuid: string uuid of fault CLI Example: .. code-block:: bash salt '*' fmadm.show 11b4070f-4358-62fa-9e1e-998f485977e1 ''' ret = {} fmdump = _check_fmdump() cmd = '{cmd} -u {uuid} -V'.format( cmd=fmdump, uuid=...
Display fault manager configuration CLI Example: .. code-block:: bash salt '*' fmadm.config
def config(): ''' Display fault manager configuration CLI Example: .. code-block:: bash salt '*' fmadm.config ''' ret = {} fmadm = _check_fmadm() cmd = '{cmd} config'.format( cmd=fmadm ) res = __salt__['cmd.run_all'](cmd) retcode = res['retcode'] result...
Load specified fault manager module path: string path of fault manager module CLI Example: .. code-block:: bash salt '*' fmadm.load /module/path
def load(path): ''' Load specified fault manager module path: string path of fault manager module CLI Example: .. code-block:: bash salt '*' fmadm.load /module/path ''' ret = {} fmadm = _check_fmadm() cmd = '{cmd} load {path}'.format( cmd=fmadm, pa...
Unload specified fault manager module module: string module to unload CLI Example: .. code-block:: bash salt '*' fmadm.unload software-response
def unload(module): ''' Unload specified fault manager module module: string module to unload CLI Example: .. code-block:: bash salt '*' fmadm.unload software-response ''' ret = {} fmadm = _check_fmadm() cmd = '{cmd} unload {module}'.format( cmd=fmadm, ...
Reset module or sub-component module: string module to unload serd : string serd sub module CLI Example: .. code-block:: bash salt '*' fmadm.reset software-response
def reset(module, serd=None): ''' Reset module or sub-component module: string module to unload serd : string serd sub module CLI Example: .. code-block:: bash salt '*' fmadm.reset software-response ''' ret = {} fmadm = _check_fmadm() cmd = '{cmd} rese...
Display list of faulty resources CLI Example: .. code-block:: bash salt '*' fmadm.faulty
def faulty(): ''' Display list of faulty resources CLI Example: .. code-block:: bash salt '*' fmadm.faulty ''' fmadm = _check_fmadm() cmd = '{cmd} faulty'.format( cmd=fmadm, ) res = __salt__['cmd.run_all'](cmd) result = {} if res['stdout'] == '': re...
Ensure the device name supplied is valid in a manner similar to the `exists` function, but raise errors on invalid input rather than return False. This function only validates a block device, it does not check if the block device is a drive or a partition or a filesystem, etc.
def _validate_device(device): ''' Ensure the device name supplied is valid in a manner similar to the `exists` function, but raise errors on invalid input rather than return False. This function only validates a block device, it does not check if the block device is a drive or a partition or a ...
Ensure valid partition boundaries are supplied.
def _validate_partition_boundary(boundary): ''' Ensure valid partition boundaries are supplied. ''' boundary = six.text_type(boundary) match = re.search(r'^([\d.]+)(\D*)$', boundary) if match: unit = match.group(2) if not unit or unit in VALID_UNITS: return raise ...
Ask the kernel to update its local partition data. When no args are specified all block devices are tried. Caution: Generally only works on devices with no mounted partitions and may take a long time to return if specified devices are in use. CLI Examples: .. code-block:: bash salt '*' p...
def probe(*devices): ''' Ask the kernel to update its local partition data. When no args are specified all block devices are tried. Caution: Generally only works on devices with no mounted partitions and may take a long time to return if specified devices are in use. CLI Examples: .. code...
Prints partition information of given <device> CLI Examples: .. code-block:: bash salt '*' partition.list /dev/sda salt '*' partition.list /dev/sda unit=s salt '*' partition.list /dev/sda unit=kB
def list_(device, unit=None): ''' Prints partition information of given <device> CLI Examples: .. code-block:: bash salt '*' partition.list /dev/sda salt '*' partition.list /dev/sda unit=s salt '*' partition.list /dev/sda unit=kB ''' _validate_device(device) if un...
Check if partition satisfies the alignment constraint of part_type. Type must be "minimal" or "optimal". CLI Example: .. code-block:: bash salt '*' partition.align_check /dev/sda minimal 1
def align_check(device, part_type, partition): ''' Check if partition satisfies the alignment constraint of part_type. Type must be "minimal" or "optimal". CLI Example: .. code-block:: bash salt '*' partition.align_check /dev/sda minimal 1 ''' _validate_device(device) if part...
Copies the file system on the partition <from-minor> to partition <to-minor>, deleting the original contents of the destination partition. CLI Example: .. code-block:: bash salt '*' partition.cp /dev/sda 2 3
def cp(device, from_minor, to_minor): # pylint: disable=C0103 ''' Copies the file system on the partition <from-minor> to partition <to-minor>, deleting the original contents of the destination partition. CLI Example: .. code-block:: bash salt '*' partition.cp /dev/sda 2 3 ''' ...
Sets the system ID for the partition. Some typical values are:: b: FAT32 (vfat) 7: HPFS/NTFS 82: Linux Swap 83: Linux 8e: Linux LVM fd: Linux RAID Auto CLI Example: .. code-block:: bash salt '*' partition.set_id /dev/sda 1 83
def set_id(device, minor, system_id): ''' Sets the system ID for the partition. Some typical values are:: b: FAT32 (vfat) 7: HPFS/NTFS 82: Linux Swap 83: Linux 8e: Linux LVM fd: Linux RAID Auto CLI Example: .. code-block:: bash salt '*' parti...
List the system types that are supported by the installed version of sfdisk CLI Example: .. code-block:: bash salt '*' partition.system_types
def system_types(): ''' List the system types that are supported by the installed version of sfdisk CLI Example: .. code-block:: bash salt '*' partition.system_types ''' ret = {} for line in __salt__['cmd.run']('sfdisk -T').splitlines(): if not line: continue ...
Makes a file system <fs_type> on partition <device>, destroying all data that resides on that partition. <fs_type> must be one of "ext2", "fat32", "fat16", "linux-swap" or "reiserfs" (if libreiserfs is installed) CLI Example: .. code-block:: bash salt '*' partition.mkfs /dev/sda2 fat32
def mkfs(device, fs_type): ''' Makes a file system <fs_type> on partition <device>, destroying all data that resides on that partition. <fs_type> must be one of "ext2", "fat32", "fat16", "linux-swap" or "reiserfs" (if libreiserfs is installed) CLI Example: .. code-block:: bash salt '*...
Create a new disklabel (partition table) of label_type. Type should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun". CLI Example: .. code-block:: bash salt '*' partition.mklabel /dev/sda msdos
def mklabel(device, label_type): ''' Create a new disklabel (partition table) of label_type. Type should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun". CLI Example: .. code-block:: bash salt '*' partition.mklabel /dev/sda msdos ''' if...
Make a part_type partition for filesystem fs_type, beginning at start and ending at end (by default in megabytes). part_type should be one of "primary", "logical", or "extended". CLI Examples: .. code-block:: bash salt '*' partition.mkpart /dev/sda primary fs_type=fat32 start=0 end=639 ...
def mkpart(device, part_type, fs_type=None, start=None, end=None): ''' Make a part_type partition for filesystem fs_type, beginning at start and ending at end (by default in megabytes). part_type should be one of "primary", "logical", or "extended". CLI Examples: .. code-block:: bash ...
Make a <part_type> partition with a new filesystem of <fs_type>, beginning at <start> and ending at <end> (by default in megabytes). <part_type> should be one of "primary", "logical", or "extended". <fs_type> must be one of "ext2", "fat32", "fat16", "linux-swap" or "reiserfs" (if libreiserfs is install...
def mkpartfs(device, part_type, fs_type, start, end): ''' Make a <part_type> partition with a new filesystem of <fs_type>, beginning at <start> and ending at <end> (by default in megabytes). <part_type> should be one of "primary", "logical", or "extended". <fs_type> must be one of "ext2", "fat32", ...
Set the name of partition to name. This option works only on Mac, PC98, and GPT disklabels. The name can be placed in quotes, if necessary. CLI Example: .. code-block:: bash salt '*' partition.name /dev/sda 1 'My Documents'
def name(device, partition, name): ''' Set the name of partition to name. This option works only on Mac, PC98, and GPT disklabels. The name can be placed in quotes, if necessary. CLI Example: .. code-block:: bash salt '*' partition.name /dev/sda 1 'My Documents' ''' _validate_devi...
Rescue a lost partition that was located somewhere between start and end. If a partition is found, parted will ask if you want to create an entry for it in the partition table. CLI Example: .. code-block:: bash salt '*' partition.rescue /dev/sda 0 8056
def rescue(device, start, end): ''' Rescue a lost partition that was located somewhere between start and end. If a partition is found, parted will ask if you want to create an entry for it in the partition table. CLI Example: .. code-block:: bash salt '*' partition.rescue /dev/sda 0 8...
Resizes the partition with number <minor>. The partition will start <start> from the beginning of the disk, and end <end> from the beginning of the disk. resize never changes the minor number. Extended partitions can be resized, so long as the new extended partition completely contains all logical part...
def resize(device, minor, start, end): ''' Resizes the partition with number <minor>. The partition will start <start> from the beginning of the disk, and end <end> from the beginning of the disk. resize never changes the minor number. Extended partitions can be resized, so long as the new extended...
Removes the partition with number <minor>. CLI Example: .. code-block:: bash salt '*' partition.rm /dev/sda 5
def rm(device, minor): # pylint: disable=C0103 ''' Removes the partition with number <minor>. CLI Example: .. code-block:: bash salt '*' partition.rm /dev/sda 5 ''' _validate_device(device) try: int(minor) except Exception: raise CommandExecutionError( ...
Changes a flag on the partition with number <minor>. A flag can be either "on" or "off" (make sure to use proper quoting, see :ref:`YAML Idiosyncrasies <yaml-idiosyncrasies>`). Some or all of these flags will be available, depending on what disk label you are using. Valid flags are: * boot ...
def set_(device, minor, flag, state): ''' Changes a flag on the partition with number <minor>. A flag can be either "on" or "off" (make sure to use proper quoting, see :ref:`YAML Idiosyncrasies <yaml-idiosyncrasies>`). Some or all of these flags will be available, depending on what disk label you a...
Toggle the state of <flag> on <partition>. Valid flags are the same as the set command. CLI Example: .. code-block:: bash salt '*' partition.toggle /dev/sda 1 boot
def toggle(device, partition, flag): ''' Toggle the state of <flag> on <partition>. Valid flags are the same as the set command. CLI Example: .. code-block:: bash salt '*' partition.toggle /dev/sda 1 boot ''' _validate_device(device) try: int(partition) except...
Changes a flag on selected device. A flag can be either "on" or "off" (make sure to use proper quoting, see :ref:`YAML Idiosyncrasies <yaml-idiosyncrasies>`). Some or all of these flags will be available, depending on what disk label you are using. Valid flags are: * cylinder_alignment ...
def disk_set(device, flag, state): ''' Changes a flag on selected device. A flag can be either "on" or "off" (make sure to use proper quoting, see :ref:`YAML Idiosyncrasies <yaml-idiosyncrasies>`). Some or all of these flags will be available, depending on what disk label you are using. Va...
Toggle the state of <flag> on <device>. Valid flags are the same as the disk_set command. CLI Example: .. code-block:: bash salt '*' partition.disk_toggle /dev/sda pmbr_boot
def disk_toggle(device, flag): ''' Toggle the state of <flag> on <device>. Valid flags are the same as the disk_set command. CLI Example: .. code-block:: bash salt '*' partition.disk_toggle /dev/sda pmbr_boot ''' _validate_device(device) if flag not in VALID_DISK_FLAGS: ...
Check to see if the partition exists CLI Example: .. code-block:: bash salt '*' partition.exists /dev/sdb1
def exists(device=''): ''' Check to see if the partition exists CLI Example: .. code-block:: bash salt '*' partition.exists /dev/sdb1 ''' if os.path.exists(device): dev = os.stat(device).st_mode if stat.S_ISBLK(dev): return True return False
Return the full path for the packages and repository freezer files.
def _paths(name=None): ''' Return the full path for the packages and repository freezer files. ''' name = 'freezer' if not name else name states_path = _states_path() return ( os.path.join(states_path, '{}-pkgs.yml'.format(name)), os.path.join(states_path, '{}-reps.yml'.form...
Return True if there is already a frozen state. A frozen state is merely a list of packages (including the version) in a specific time. This information can be used to compare with the current list of packages, and revert the installation of some extra packages that are in the system. name ...
def status(name=None): ''' Return True if there is already a frozen state. A frozen state is merely a list of packages (including the version) in a specific time. This information can be used to compare with the current list of packages, and revert the installation of some extra packages that a...
Return the list of frozen states. CLI Example: .. code-block:: bash salt '*' freezer.list
def list_(): ''' Return the list of frozen states. CLI Example: .. code-block:: bash salt '*' freezer.list ''' ret = [] states_path = _states_path() if not os.path.isdir(states_path): return ret for state in os.listdir(states_path): if state.endswith(('-p...
Save the list of package and repos in a freeze file. As this module is build on top of the pkg module, the user can send extra attributes to the underlying pkg module via kwargs. This function will call ``pkg.list_pkgs`` and ``pkg.list_repos``, and any additional arguments will be passed through to tho...
def freeze(name=None, force=False, **kwargs): ''' Save the list of package and repos in a freeze file. As this module is build on top of the pkg module, the user can send extra attributes to the underlying pkg module via kwargs. This function will call ``pkg.list_pkgs`` and ``pkg.list_repos``, ...
Make sure that the system contains the packages and repos from a frozen state. Read the list of packages and repositories from the freeze file, and compare it with the current list of packages and repos. If there is any difference, all the missing packages are repos will be installed, and all the e...
def restore(name=None, **kwargs): ''' Make sure that the system contains the packages and repos from a frozen state. Read the list of packages and repositories from the freeze file, and compare it with the current list of packages and repos. If there is any difference, all the missing packages ...
Returns the rabbitmq-plugin command path if we're running an OS that doesn't put it in the standard /usr/bin or /usr/local/bin This works by taking the rabbitmq-server version and looking for where it seems to be hidden in /usr/lib.
def _get_rabbitmq_plugin(): ''' Returns the rabbitmq-plugin command path if we're running an OS that doesn't put it in the standard /usr/bin or /usr/local/bin This works by taking the rabbitmq-server version and looking for where it seems to be hidden in /usr/lib. ''' global RABBITMQ_PLUGINS...
Looks for rabbitmqctl warning, or general formatting, strings that aren't intended to be parsed as output. Returns a boolean whether the line can be parsed as rabbitmqctl output.
def _safe_output(line): ''' Looks for rabbitmqctl warning, or general formatting, strings that aren't intended to be parsed as output. Returns a boolean whether the line can be parsed as rabbitmqctl output. ''' return not any([ line.startswith('Listing') and line.endswith('...'), ...
Convert rabbitmqctl output to a dict of data cmdoutput: string output of rabbitmqctl commands values_mapper: function object to process the values part of each line
def _output_to_dict(cmdoutput, values_mapper=None): ''' Convert rabbitmqctl output to a dict of data cmdoutput: string output of rabbitmqctl commands values_mapper: function object to process the values part of each line ''' if isinstance(cmdoutput, dict): if cmdoutput['retcode'] != 0 or...
Convert rabbitmqctl output to a list of strings (assuming whitespace-delimited output). Ignores output lines that shouldn't be parsed, like warnings. cmdoutput: string output of rabbitmqctl commands
def _output_to_list(cmdoutput): ''' Convert rabbitmqctl output to a list of strings (assuming whitespace-delimited output). Ignores output lines that shouldn't be parsed, like warnings. cmdoutput: string output of rabbitmqctl commands ''' return [item for line in cmdoutput.splitlines() if _safe_...
Return a list of users based off of rabbitmqctl user_list. CLI Example: .. code-block:: bash salt '*' rabbitmq.list_users
def list_users(runas=None): ''' Return a list of users based off of rabbitmqctl user_list. CLI Example: .. code-block:: bash salt '*' rabbitmq.list_users ''' # Windows runas currently requires a password. # Due to this, don't use a default value for # runas in Windows. if ...
Return a list of vhost based on rabbitmqctl list_vhosts. CLI Example: .. code-block:: bash salt '*' rabbitmq.list_vhosts
def list_vhosts(runas=None): ''' Return a list of vhost based on rabbitmqctl list_vhosts. CLI Example: .. code-block:: bash salt '*' rabbitmq.list_vhosts ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() res = __salt__['cmd.r...
Return whether the user exists based on rabbitmqctl list_users. CLI Example: .. code-block:: bash salt '*' rabbitmq.user_exists rabbit_user
def user_exists(name, runas=None): ''' Return whether the user exists based on rabbitmqctl list_users. CLI Example: .. code-block:: bash salt '*' rabbitmq.user_exists rabbit_user ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() ...
Return whether the vhost exists based on rabbitmqctl list_vhosts. CLI Example: .. code-block:: bash salt '*' rabbitmq.vhost_exists rabbit_host
def vhost_exists(name, runas=None): ''' Return whether the vhost exists based on rabbitmqctl list_vhosts. CLI Example: .. code-block:: bash salt '*' rabbitmq.vhost_exists rabbit_host ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_use...
Add a rabbitMQ user via rabbitmqctl user_add <user> <password> CLI Example: .. code-block:: bash salt '*' rabbitmq.add_user rabbit_user password
def add_user(name, password=None, runas=None): ''' Add a rabbitMQ user via rabbitmqctl user_add <user> <password> CLI Example: .. code-block:: bash salt '*' rabbitmq.add_user rabbit_user password ''' clear_pw = False if password is None: # Generate a random, temporary pas...
Deletes a user via rabbitmqctl delete_user. CLI Example: .. code-block:: bash salt '*' rabbitmq.delete_user rabbit_user
def delete_user(name, runas=None): ''' Deletes a user via rabbitmqctl delete_user. CLI Example: .. code-block:: bash salt '*' rabbitmq.delete_user rabbit_user ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() res = __salt__['...
Changes a user's password. CLI Example: .. code-block:: bash salt '*' rabbitmq.change_password rabbit_user password
def change_password(name, password, runas=None): ''' Changes a user's password. CLI Example: .. code-block:: bash salt '*' rabbitmq.change_password rabbit_user password ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() if sal...
.. versionadded:: 2016.3.0 Checks if a user's password is valid. CLI Example: .. code-block:: bash salt '*' rabbitmq.check_password rabbit_user password
def check_password(name, password, runas=None): ''' .. versionadded:: 2016.3.0 Checks if a user's password is valid. CLI Example: .. code-block:: bash salt '*' rabbitmq.check_password rabbit_user password ''' # try to get the rabbitmq-version - adapted from _get_rabbitmq_plugin ...
Adds a vhost via rabbitmqctl add_vhost. CLI Example: .. code-block:: bash salt '*' rabbitmq add_vhost '<vhost_name>'
def add_vhost(vhost, runas=None): ''' Adds a vhost via rabbitmqctl add_vhost. CLI Example: .. code-block:: bash salt '*' rabbitmq add_vhost '<vhost_name>' ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() res = __salt__['cmd....
Sets permissions for vhost via rabbitmqctl set_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.set_permissions myvhost myuser
def set_permissions(vhost, user, conf='.*', write='.*', read='.*', runas=None): ''' Sets permissions for vhost via rabbitmqctl set_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.set_permissions myvhost myuser ''' if runas is None and not salt.utils.platform.is_windows...
Lists permissions for vhost via rabbitmqctl list_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.list_permissions /myvhost
def list_permissions(vhost, runas=None): ''' Lists permissions for vhost via rabbitmqctl list_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.list_permissions /myvhost ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_us...
List permissions for a user via rabbitmqctl list_user_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.list_user_permissions user
def list_user_permissions(name, runas=None): ''' List permissions for a user via rabbitmqctl list_user_permissions CLI Example: .. code-block:: bash salt '*' rabbitmq.list_user_permissions user ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.u...
Add user tags via rabbitmqctl set_user_tags CLI Example: .. code-block:: bash salt '*' rabbitmq.set_user_tags myadmin administrator
def set_user_tags(name, tags, runas=None): '''Add user tags via rabbitmqctl set_user_tags CLI Example: .. code-block:: bash salt '*' rabbitmq.set_user_tags myadmin administrator ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() ...
Join a rabbit cluster CLI Example: .. code-block:: bash salt '*' rabbitmq.join_cluster rabbit.example.com rabbit
def join_cluster(host, user='rabbit', ram_node=None, runas=None): ''' Join a rabbit cluster CLI Example: .. code-block:: bash salt '*' rabbitmq.join_cluster rabbit.example.com rabbit ''' cmd = [RABBITMQCTL, 'join_cluster'] if ram_node: cmd.append('--ram') cmd.append('{...
Returns queue details of the / virtual host CLI Example: .. code-block:: bash salt '*' rabbitmq.list_queues messages consumers
def list_queues(runas=None, *args): ''' Returns queue details of the / virtual host CLI Example: .. code-block:: bash salt '*' rabbitmq.list_queues messages consumers ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() cmd = [R...
Return a dictionary of policies nested by vhost and name based on the data returned from rabbitmqctl list_policies. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.list_policies
def list_policies(vhost="/", runas=None): ''' Return a dictionary of policies nested by vhost and name based on the data returned from rabbitmqctl list_policies. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.list_policies ''' r...
Set a policy based on rabbitmqctl set_policy. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.set_policy / HA '.*' '{"ha-mode":"all"}'
def set_policy(vhost, name, pattern, definition, priority=None, runas=None, apply_to=None): ''' Set a policy based on rabbitmqctl set_policy. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-b...
Delete a policy based on rabbitmqctl clear_policy. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.delete_policy / HA
def delete_policy(vhost, name, runas=None): ''' Delete a policy based on rabbitmqctl clear_policy. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.delete_policy / HA ''' if runas is None and not salt.utils.platform.is_windows(): ...
Return whether the policy exists based on rabbitmqctl list_policies. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.policy_exists / HA
def policy_exists(vhost, name, runas=None): ''' Return whether the policy exists based on rabbitmqctl list_policies. Reference: http://www.rabbitmq.com/ha.html CLI Example: .. code-block:: bash salt '*' rabbitmq.policy_exists / HA ''' if runas is None and not salt.utils.platform....
Returns a list of the names of all available plugins (enabled and disabled). CLI Example: .. code-block:: bash salt '*' rabbitmq.list_available_plugins
def list_available_plugins(runas=None): ''' Returns a list of the names of all available plugins (enabled and disabled). CLI Example: .. code-block:: bash salt '*' rabbitmq.list_available_plugins ''' if runas is None and not salt.utils.platform.is_windows(): ...
Return whether the plugin is enabled. CLI Example: .. code-block:: bash salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name
def plugin_is_enabled(name, runas=None): ''' Return whether the plugin is enabled. CLI Example: .. code-block:: bash salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() r...
Enable a RabbitMQ plugin via the rabbitmq-plugins command. CLI Example: .. code-block:: bash salt '*' rabbitmq.enable_plugin foo
def enable_plugin(name, runas=None): ''' Enable a RabbitMQ plugin via the rabbitmq-plugins command. CLI Example: .. code-block:: bash salt '*' rabbitmq.enable_plugin foo ''' if runas is None and not salt.utils.platform.is_windows(): runas = salt.utils.user.get_user() cmd =...
Return True or False if cygwin is installed. Use the cygcheck executable to check install. It is installed as part of the base package, and we use it to check packages
def _check_cygwin_installed(cyg_arch='x86_64'): ''' Return True or False if cygwin is installed. Use the cygcheck executable to check install. It is installed as part of the base package, and we use it to check packages ''' path_to_cygcheck = os.sep.join(['C:', ...
Return the list of packages based on the mirror provided.
def _get_all_packages(mirror=DEFAULT_MIRROR, cyg_arch='x86_64'): ''' Return the list of packages based on the mirror provided. ''' if 'cyg.all_packages' not in __context__: __context__['cyg.all_packages'] = {} if mirror not in __context__['cyg.all_packages']: __...
Check if the package is valid on the given mirrors. Args: package: The name of the package cyg_arch: The cygwin architecture mirrors: any mirrors to check Returns (bool): True if Valid, otherwise False CLI Example: .. code-block:: bash salt '*' cyg.check_valid_packag...
def check_valid_package(package, cyg_arch='x86_64', mirrors=None): ''' Check if the package is valid on the given mirrors. Args: package: The name of the package cyg_arch: The cygwin architecture mirrors: any mirrors to check Retu...
Retrieve the correct setup.exe. Run it with the correct arguments to get the bare minimum cygwin installation up and running.
def _run_silent_cygwin(cyg_arch='x86_64', args=None, mirrors=None): ''' Retrieve the correct setup.exe. Run it with the correct arguments to get the bare minimum cygwin installation up and running. ''' cyg_cache_dir = os.sep.join(['c:', 'cygcache'])...
Run the cygcheck executable.
def _cygcheck(args, cyg_arch='x86_64'): ''' Run the cygcheck executable. ''' cmd = ' '.join([ os.sep.join(['c:', _get_cyg_dir(cyg_arch), 'bin', 'cygcheck']), '-c', args]) ret = __salt__['cmd.run_all'](cmd) if ret['retcode'] == 0: return ret['stdout'] else: r...
Install one or several packages. packages : None The packages to install cyg_arch : x86_64 Specify the architecture to install the package under Current options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.install dos2unix salt '*' cyg.in...
def install(packages=None, cyg_arch='x86_64', mirrors=None): ''' Install one or several packages. packages : None The packages to install cyg_arch : x86_64 Specify the architecture to install the package under Current options are x86 and x86_64 CLI ...
Uninstall one or several packages. packages The packages to uninstall. cyg_arch : x86_64 Specify the architecture to remove the package from Current options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.uninstall dos2unix salt '*' cyg.unin...
def uninstall(packages, cyg_arch='x86_64', mirrors=None): ''' Uninstall one or several packages. packages The packages to uninstall. cyg_arch : x86_64 Specify the architecture to remove the package from Current options are x86 and x86_64 CLI Exa...
Update all packages. cyg_arch : x86_64 Specify the cygwin architecture update Current options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.update salt '*' cyg.update dos2unix mirrors="[{'http://mirror': 'http://url/to/public/key}]"
def update(cyg_arch='x86_64', mirrors=None): ''' Update all packages. cyg_arch : x86_64 Specify the cygwin architecture update Current options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.update salt '*' cyg.update dos2unix mirrors="[{'http://...
List locally installed packages. package : '' package name to check. else all cyg_arch : Cygwin architecture to use Options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.list
def list_(package='', cyg_arch='x86_64'): ''' List locally installed packages. package : '' package name to check. else all cyg_arch : Cygwin architecture to use Options are x86 and x86_64 CLI Example: .. code-block:: bash salt '*' cyg.list ''' pkgs =...
Return the targets from the flat yaml file, checks opts for location but defaults to /etc/salt/roster
def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613 ''' Return the targets from the flat yaml file, checks opts for location but defaults to /etc/salt/roster ''' ret = {} cloud_opts = salt.config.cloud_config( os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud...
Extract the preferred IP address from the ipv4 grain
def extract_ipv4(roster_order, ipv4): ''' Extract the preferred IP address from the ipv4 grain ''' for ip_type in roster_order: for ip_ in ipv4: if ':' in ip_: continue if not salt.utils.validate.net.ipv4_addr(ip_): continue if ...
Prepare the connection with the remote network device, and clean up the key value pairs, removing the args used for the connection init.
def _prepare_connection(**nxos_api_kwargs): ''' Prepare the connection with the remote network device, and clean up the key value pairs, removing the args used for the connection init. ''' nxos_api_kwargs = clean_kwargs(**nxos_api_kwargs) init_kwargs = {} # Clean up any arguments that are no...
Execute an arbitrary RPC request via the Nexus API. commands The commands to be executed. method: ``cli`` The type of the response, i.e., raw text (``cli_ascii``) or structured document (``cli``). Defaults to ``cli`` (structured data). transport: ``https`` Specifies the ty...
def rpc(commands, method='cli', **kwargs): ''' Execute an arbitrary RPC request via the Nexus API. commands The commands to be executed. method: ``cli`` The type of the response, i.e., raw text (``cli_ascii``) or structured document (``cli``). Defaults to ``cli`...
Execute the render system against a single reaction file and return the data structure
def render_reaction(self, glob_ref, tag, data): ''' Execute the render system against a single reaction file and return the data structure ''' react = {} if glob_ref.startswith('salt://'): glob_ref = self.minion.functions['cp.cache_file'](glob_ref) or '' ...