INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Makes a string describing the target of an EntryPoint object.
def _format_entrypoint_target(ep): ''' Makes a string describing the target of an EntryPoint object. Base strongly on EntryPoint.__str__(). ''' s = ep.module_name if ep.attrs: s += ':' + '.'.join(ep.attrs) return s
Load execution modules
def minion_mods( opts, context=None, utils=None, whitelist=None, initial_load=False, loaded_base_name=None, notify=False, static_modules=None, proxy=None): ''' Load execution modules Returns a dictionary of execution modules appropriat...
Returns a single module loaded raw and bypassing the __virtual__ function
def raw_mod(opts, name, functions, mod='modules'): ''' Returns a single module loaded raw and bypassing the __virtual__ function .. code-block:: python import salt.config import salt.loader __opts__ = salt.config.minion_config('/etc/salt/minion') testmod = salt.loader.raw_...
Return the master services plugins
def engines(opts, functions, runners, utils, proxy=None): ''' Return the master services plugins ''' pack = {'__salt__': functions, '__runners__': runners, '__proxy__': proxy, '__utils__': utils} return LazyLoader( _module_dirs(opts, 'engines'), op...
Returns the proxy module for this salt - proxy - minion
def proxy(opts, functions=None, returners=None, whitelist=None, utils=None): ''' Returns the proxy module for this salt-proxy-minion ''' ret = LazyLoader( _module_dirs(opts, 'proxy'), opts, tag='proxy', pack={'__salt__': functions, '__ret__': returners, '__utils__': utils...
Returns the returner modules
def returners(opts, functions, whitelist=None, context=None, proxy=None): ''' Returns the returner modules ''' return LazyLoader( _module_dirs(opts, 'returners', 'returner'), opts, tag='returner', whitelist=whitelist, pack={'__salt__': functions, '__context__': co...
Returns the utility modules
def utils(opts, whitelist=None, context=None, proxy=proxy): ''' Returns the utility modules ''' return LazyLoader( _module_dirs(opts, 'utils', ext_type_dirs='utils_dirs'), opts, tag='utils', whitelist=whitelist, pack={'__context__': context, '__proxy__': proxy or ...
Returns the pillars modules
def pillars(opts, functions, context=None): ''' Returns the pillars modules ''' ret = LazyLoader(_module_dirs(opts, 'pillar'), opts, tag='pillar', pack={'__salt__': functions, '__context__': context, ...
Returns the tops modules
def tops(opts): ''' Returns the tops modules ''' if 'master_tops' not in opts: return {} whitelist = list(opts['master_tops'].keys()) ret = LazyLoader( _module_dirs(opts, 'tops', 'top'), opts, tag='top', whitelist=whitelist, ) return FilterDictWrap...
Returns the wheels modules
def wheels(opts, whitelist=None, context=None): ''' Returns the wheels modules ''' if context is None: context = {} return LazyLoader( _module_dirs(opts, 'wheel'), opts, tag='wheel', whitelist=whitelist, pack={'__context__': context}, )
Returns the outputters modules
def outputters(opts): ''' Returns the outputters modules :param dict opts: The Salt options dictionary :returns: LazyLoader instance, with only outputters present in the keyspace ''' ret = LazyLoader( _module_dirs(opts, 'output', ext_type_dirs='outputter_dirs'), opts, ta...
Returns the auth modules
def auth(opts, whitelist=None): ''' Returns the auth modules :param dict opts: The Salt options dictionary :returns: LazyLoader ''' return LazyLoader( _module_dirs(opts, 'auth'), opts, tag='auth', whitelist=whitelist, pack={'__salt__': minion_mods(opts)},...
Returns the file server modules
def fileserver(opts, backends): ''' Returns the file server modules ''' return LazyLoader(_module_dirs(opts, 'fileserver'), opts, tag='fileserver', whitelist=backends, pack={'__utils__': utils(opts)})
Returns the roster modules
def roster(opts, runner=None, utils=None, whitelist=None): ''' Returns the roster modules ''' return LazyLoader( _module_dirs(opts, 'roster'), opts, tag='roster', whitelist=whitelist, pack={ '__runner__': runner, '__utils__': utils, ...
Load the thorium runtime modules
def thorium(opts, functions, runners): ''' Load the thorium runtime modules ''' pack = {'__salt__': functions, '__runner__': runners, '__context__': {}} ret = LazyLoader(_module_dirs(opts, 'thorium'), opts, tag='thorium', pack=pack) ret.pack['__thorium__'] = r...
Returns the state modules
def states(opts, functions, utils, serializers, whitelist=None, proxy=None, context=None): ''' Returns the state modules :param dict opts: The Salt options dictionary :param dict functions: A dictionary of minion modules, with module names as keys and funcs as values. ....
Load the beacon modules
def beacons(opts, functions, context=None, proxy=None): ''' Load the beacon modules :param dict opts: The Salt options dictionary :param dict functions: A dictionary of minion modules, with module names as keys and funcs as values. ''' return LazyLoader( _mod...
Returns the custom logging handler modules
def log_handlers(opts): ''' Returns the custom logging handler modules :param dict opts: The Salt options dictionary ''' ret = LazyLoader( _module_dirs( opts, 'log_handlers', int_type='handlers', base_path=os.path.join(SALT_BASE_PATH, 'log'), ...
Returns the custom logging handler modules
def ssh_wrapper(opts, functions=None, context=None): ''' Returns the custom logging handler modules ''' return LazyLoader( _module_dirs( opts, 'wrapper', base_path=os.path.join(SALT_BASE_PATH, os.path.join('client', 'ssh')), ), opts, ta...
Returns the render modules
def render(opts, functions, states=None, proxy=None, context=None): ''' Returns the render modules ''' if context is None: context = {} pack = {'__salt__': functions, '__grains__': opts.get('grains', {}), '__context__': context} if states: pack['__states...
Returns the grain functions
def grain_funcs(opts, proxy=None): ''' Returns the grain functions .. code-block:: python import salt.config import salt.loader __opts__ = salt.config.minion_config('/etc/salt/minion') grainfuncs = salt.loader.grain_funcs(__opts__) ''' ret = LazyLoader( ...
Returns the grains cached in cfn or None if the cache is too old or is corrupted.
def _load_cached_grains(opts, cfn): ''' Returns the grains cached in cfn, or None if the cache is too old or is corrupted. ''' if not os.path.isfile(cfn): log.debug('Grains cache file does not exist.') return None grains_cache_age = int(time.time() - os.path.getmtime(cfn)) i...
Return the functions for the dynamic grains and the values for the static grains.
def grains(opts, force_refresh=False, proxy=None): ''' Return the functions for the dynamic grains and the values for the static grains. Since grains are computed early in the startup process, grains functions do not have __salt__ or __proxy__ available. At proxy-minion startup, this function ...
Directly call a function inside a loader directory
def call(fun, **kwargs): ''' Directly call a function inside a loader directory ''' args = kwargs.get('args', []) dirs = kwargs.get('dirs', []) funcs = LazyLoader( [os.path.join(SALT_BASE_PATH, 'modules')] + dirs, None, tag='modules', virtual_enable=False, ) ...
Directly call a function inside a loader directory
def runner(opts, utils=None, context=None, whitelist=None): ''' Directly call a function inside a loader directory ''' if utils is None: utils = {} if context is None: context = {} ret = LazyLoader( _module_dirs(opts, 'runners', 'runner', ext_type_dirs='runner_dirs'), ...
Make a very small database call
def sdb(opts, functions=None, whitelist=None, utils=None): ''' Make a very small database call ''' if utils is None: utils = {} return LazyLoader( _module_dirs(opts, 'sdb'), opts, tag='sdb', pack={ '__sdb__': functions, '__opts__': opt...
Return modules for SPM s package database
def pkgdb(opts): ''' Return modules for SPM's package database .. versionadded:: 2015.8.0 ''' return LazyLoader( _module_dirs( opts, 'pkgdb', base_path=os.path.join(SALT_BASE_PATH, 'spm') ), opts, tag='pkgdb' )
Return the cloud functions
def clouds(opts): ''' Return the cloud functions ''' # Let's bring __active_provider_name__, defaulting to None, to all cloud # drivers. This will get temporarily updated/overridden with a context # manager when needed. functions = LazyLoader( _module_dirs(opts, ...
Returns the executor modules
def executors(opts, functions=None, context=None, proxy=None): ''' Returns the executor modules ''' executors = LazyLoader( _module_dirs(opts, 'executors', 'executor'), opts, tag='executor', pack={'__salt__': functions, '__context__': context or {}, '__proxy__': proxy or ...
Returns the returner modules
def cache(opts, serial): ''' Returns the returner modules ''' return LazyLoader( _module_dirs(opts, 'cache', 'cache'), opts, tag='cache', pack={'__opts__': opts, '__context__': {'serial': serial}}, )
Inject a variable into a module. This is used to inject globals like __salt__ __pillar or grains.
def _inject_into_mod(mod, name, value, force_lock=False): ''' Inject a variable into a module. This is used to inject "globals" like ``__salt__``, ``__pillar``, or ``grains``. Instead of injecting the value directly, a ``ThreadLocalProxy`` is created. If such a proxy is already present under the sp...
Decorator used by the LazyLoader to inject globals into a function at execute time.
def global_injector_decorator(inject_globals): ''' Decorator used by the LazyLoader to inject globals into a function at execute time. globals Dictionary with global variables to inject ''' def inner_decorator(f): @functools.wraps(f) def wrapper(*args, **kwargs): ...
Return the error string for a missing function.
def missing_fun_string(self, function_name): ''' Return the error string for a missing function. This can range from "not available' to "__virtual__" returned False ''' mod_name = function_name.split('.')[0] if mod_name in self.loaded_modules: return '\'{0}\'...
refresh the mapping of the FS on disk
def _refresh_file_mapping(self): ''' refresh the mapping of the FS on disk ''' # map of suffix to description for imp if self.opts.get('cython_enable', True) is True: try: global pyximport pyximport = __import__('pyximport') # pylint: ...
Clear the dict
def clear(self): ''' Clear the dict ''' with self._lock: super(LazyLoader, self).clear() # clear the lazy loader self.loaded_files = set() self.missing_modules = {} self.loaded_modules = {} # if we have been loaded before, lets...
Strip out of the opts any logger instance
def __prep_mod_opts(self, opts): ''' Strip out of the opts any logger instance ''' if '__grains__' not in self.pack: grains = opts.get('grains', {}) if isinstance(grains, ThreadLocalProxy): grains = ThreadLocalProxy.unproxy(grains) se...
Iterate over all file_mapping files in order of closeness to mod_name
def _iter_files(self, mod_name): ''' Iterate over all file_mapping files in order of closeness to mod_name ''' # do we have an exact match? if mod_name in self.file_mapping: yield mod_name # do we have a partial match? for k in self.file_mapping: ...
Load a single item if you have it
def _load(self, key): ''' Load a single item if you have it ''' # if the key doesn't have a '.' then it isn't valid for this mod dict if not isinstance(key, six.string_types): raise KeyError('The key must be a string.') if '.' not in key: raise Key...
Load all of them
def _load_all(self): ''' Load all of them ''' with self._lock: for name in self.file_mapping: if name in self.loaded_files or name in self.missing_modules: continue self._load_module(name) self.loaded = True
Apply the __outputter__ variable to the functions
def _apply_outputter(self, func, mod): ''' Apply the __outputter__ variable to the functions ''' if hasattr(mod, '__outputter__'): outp = mod.__outputter__ if func.__name__ in outp: func.__outputter__ = outp[func.__name__]
Given a loaded module and its default name determine its virtual name
def _process_virtual(self, mod, module_name, virtual_func='__virtual__'): ''' Given a loaded module and its default name determine its virtual name This function returns a tuple. The first value will be either True or False and will indicate if the module should be loaded or not (i.e. i...
Get an individual DMI string from SMBIOS info
def get(string, clean=True): ''' Get an individual DMI string from SMBIOS info string The string to fetch. DMIdecode supports: - ``bios-vendor`` - ``bios-version`` - ``bios-release-date`` - ``system-manufacturer`` - ``system-product-name`` ...
Return DMI records from SMBIOS
def records(rec_type=None, fields=None, clean=True): ''' Return DMI records from SMBIOS type Return only records of type(s) The SMBIOS specification defines the following DMI types: ==== ====================================== Type Information ==== ===============...
Structurize DMI records into a nice list Optionally trash bogus entries and filter output
def _dmi_parse(data, clean=True, fields=None): ''' Structurize DMI records into a nice list Optionally trash bogus entries and filter output ''' dmi = [] # Detect & split Handle records dmi_split = re.compile('(handle [0-9]x[0-9a-f]+[^\n]+)\n', re.MULTILINE+re.IGNORECASE) dmi_raw = iter...
Parse the raw DMIdecode output of a single handle into a nice dict
def _dmi_data(dmi_raw, clean, fields): ''' Parse the raw DMIdecode output of a single handle into a nice dict ''' dmi_data = {} key = None key_data = [None, []] for line in dmi_raw: if re.match(r'\t[^\s]+', line): # Finish previous key if key is not None:...
Simple caster thingy for trying to fish out at least ints & lists from strings
def _dmi_cast(key, val, clean=True): ''' Simple caster thingy for trying to fish out at least ints & lists from strings ''' if clean and not _dmi_isclean(key, val): return elif not re.match(r'serial|part|asset|product', key, flags=re.IGNORECASE): if ',' in val: val = [el....
Call DMIdecode
def _dmidecoder(args=None): ''' Call DMIdecode ''' dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios']) if not args: out = salt.modules.cmdmod._run_quiet(dmidecoder) else: out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args)) return out
Build the mapping for YAML
def construct_mapping(self, node, deep=False): ''' Build the mapping for YAML ''' if not isinstance(node, MappingNode): raise ConstructorError( None, None, 'expected a mapping node, but found {0}'.format(node.id), ...
Verify integers and pass them in correctly is they are declared as octal
def construct_scalar(self, node): ''' Verify integers and pass them in correctly is they are declared as octal ''' if node.tag == 'tag:yaml.org,2002:int': if node.value == '0': pass elif node.value.startswith('0') and not node.value.startsw...
Take an IP string/ int and return an object of the correct type.
def ip_address(address): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. Returns: An...
Take an IP string/ int and return an object of the correct type.
def ip_network(address, strict=True): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP network. Either IPv4 or IPv6 networks may be supplied; integers less than 2**32 will be considered to be IPv4 by default. Returns...
Helper to split the netmask and raise AddressValueError if needed
def _split_optional_netmask(address): """Helper to split the netmask and raise AddressValueError if needed""" addr = str(address).split('/') if len(addr) > 2: raise AddressValueError("Only one '/' permitted in %r" % address) return addr
Count the number of zero bits on the right hand side.
def _count_righthand_zero_bits(number, bits): """Count the number of zero bits on the right hand side. Args: number: an integer. bits: maximum number of bits to count. Returns: The number of zero bits on the right hand side of the number. """ if number == 0: return...
Loops through the addresses collapsing concurrent netblocks.
def _collapse_addresses_recursive(addresses): """Loops through the addresses, collapsing concurrent netblocks. Example: ip1 = IPv4Network('192.0.2.0/26') ip2 = IPv4Network('192.0.2.64/26') ip3 = IPv4Network('192.0.2.128/26') ip4 = IPv4Network('192.0.2.192/26') _collaps...
Collapse a list of IP objects.
def collapse_addresses(addresses): """Collapse a list of IP objects. Example: collapse_addresses([IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]) -> [IPv4Network('192.0.2.0/24')] Args: addresses: An iterator of IPv4Network...
Return prefix length from the bitwise netmask.
def _prefix_from_ip_int(self, ip_int): """Return prefix length from the bitwise netmask. Args: ip_int: An integer, the netmask in expanded bitwise format Returns: An integer, the prefix length. Raises: ValueError: If the input intermingles zeroes & ...
Return prefix length from a numeric string
def _prefix_from_prefix_string(self, prefixlen_str): """Return prefix length from a numeric string Args: prefixlen_str: The string to be converted Returns: An integer, the prefix length. Raises: NetmaskValueError: If the input is not a valid netmask...
Turn a netmask/ hostmask string into a prefix length
def _prefix_from_ip_string(self, ip_str): """Turn a netmask/hostmask string into a prefix length Args: ip_str: The netmask/hostmask to be converted Returns: An integer, the prefix length. Raises: NetmaskValueError: If the input is not a valid netmas...
The subnets which join to make the current subnet.
def subnets(self, prefixlen_diff=1, new_prefix=None): """The subnets which join to make the current subnet. In the case that self contains only one IP (self._prefixlen == 32 for IPv4 or self._prefixlen == 128 for IPv6), yield an iterator with just ourself. Args: pre...
The supernet containing the current network.
def supernet(self, prefixlen_diff=1, new_prefix=None): """The supernet containing the current network. Args: prefixlen_diff: An integer, the amount the prefix length of the network should be decreased by. For example, given a /24 network and a prefixlen_diff of ...
Turn the given IP string into an integer for comparison.
def _ip_int_from_string(self, ip_str): """Turn the given IP string into an integer for comparison. Args: ip_str: A string, the IP ip_str. Returns: The IP ip_str as an integer. Raises: AddressValueError: if ip_str isn't a valid IPv4 Address. ...
Convert a decimal octet into an integer.
def _parse_octet(self, octet_str): """Convert a decimal octet into an integer. Args: octet_str: A string, the number to parse. Returns: The octet as an integer. Raises: ValueError: if the octet isn't strictly a decimal from [0..255]. """ ...
Verify that the netmask is valid.
def _is_valid_netmask(self, netmask): """Verify that the netmask is valid. Args: netmask: A string, either a prefix or dotted decimal netmask. Returns: A boolean, True if the prefix represents a valid IPv4 netmask. """ mask = n...
Test if this address is allocated for private networks.
def is_private(self): """Test if this address is allocated for private networks. Returns: A boolean, True if the address is reserved per iana-ipv4-special-registry. """ return (self in IPv4Network('0.0.0.0/8') or self in IPv4Network('10.0.0.0/8')...
Expand a shortened IPv6 address.
def _explode_shorthand_ip_string(self): """Expand a shortened IPv6 address. Args: ip_str: A string, the IPv6 address. Returns: A string, the expanded IPv6 address. """ if isinstance(self, IPv6Network): ip_str = str(self.network_address) ...
Test if the address is otherwise IETF reserved.
def is_reserved(self): """Test if the address is otherwise IETF reserved. Returns: A boolean, True if the address is within one of the reserved IPv6 Network ranges. """ reserved_networks = [IPv6Network('::/8'), IPv6Network('100::/8'), ...
Test if this address is allocated for private networks.
def is_private(self): """Test if this address is allocated for private networks. Returns: A boolean, True if the address is reserved per iana-ipv6-special-registry. """ return (self in IPv6Network('::1/128') or self in IPv6Network('::/128') or ...
Generate Iterator over usable hosts in a network.
def hosts(self): """Generate Iterator over usable hosts in a network. This is like __iter__ except it doesn't return the Subnet-Router anycast address. """ network = int(self.network_address) broadcast = int(self.broadcast_address) for x in long_range(1, bro...
Convert snetinfo object to list
def _to_list(obj): ''' Convert snetinfo object to list ''' ret = {} for attr in __attrs: if hasattr(obj, attr): ret[attr] = getattr(obj, attr) return ret
Validate the beacon configuration
def validate(config): ''' Validate the beacon configuration ''' VALID_ITEMS = [ 'type', 'bytes_sent', 'bytes_recv', 'packets_sent', 'packets_recv', 'errin', 'errout', 'dropin', 'dropout' ] # Configuration for load beacon should be a list of dicts if not isinstance(c...
Emit the network statistics of this host.
def beacon(config): ''' Emit the network statistics of this host. Specify thresholds for each network stat and only emit a beacon if any of them are exceeded. Emit beacon when any values are equal to configured values. .. code-block:: yaml beacons: network_info: ...
Return apcaccess output
def status(): ''' Return apcaccess output CLI Example: .. code-block:: bash salt '*' apcups.status ''' ret = {} apcaccess = _check_apcaccess() res = __salt__['cmd.run_all'](apcaccess) retcode = res['retcode'] if retcode != 0: ret['Error'] = 'Something with wron...
Return load
def status_load(): ''' Return load CLI Example: .. code-block:: bash salt '*' apcups.status_load ''' data = status() if 'LOADPCT' in data: load = data['LOADPCT'].split() if load[1].lower() == 'percent': return float(load[0]) return {'Error': 'Load ...
Return battery charge
def status_charge(): ''' Return battery charge CLI Example: .. code-block:: bash salt '*' apcups.status_charge ''' data = status() if 'BCHARGE' in data: charge = data['BCHARGE'].split() if charge[1].lower() == 'percent': return float(charge[0]) ret...
Ensures a host s core dump configuration.
def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500): ''' Ensures a host's core dump configuration. name Name of the state. enabled Sets whether or not ESXi core dump collection should be enabled. This is a boolean value set to ``True`` or ``False``...
Ensures the given password is set on the ESXi host. Passwords cannot be obtained from host so if a password is set in this state the vsphere. update_host_password function will always run ( except when using test = True functionality ) and the state s changes dictionary will always be populated.
def password_present(name, password): ''' Ensures the given password is set on the ESXi host. Passwords cannot be obtained from host, so if a password is set in this state, the ``vsphere.update_host_password`` function will always run (except when using test=True functionality) and the state's chang...
Ensures a host s NTP server configuration such as setting NTP servers ensuring the NTP daemon is running or stopped or restarting the NTP daemon for the ESXi host.
def ntp_configured(name, service_running, ntp_servers=None, service_policy=None, service_restart=False, update_datetime=False): ''' Ensures a host's NTP server configuration such as setting NTP servers, ensuring the ...
Configures a host s VMotion properties such as enabling VMotion and setting the device VirtualNic that VMotion will use.
def vmotion_configured(name, enabled, device='vmk0'): ''' Configures a host's VMotion properties such as enabling VMotion and setting the device VirtualNic that VMotion will use. name Name of the state. enabled Ensures whether or not VMotion should be enabled on a host as a boolean...
Configures a host s VSAN properties such as enabling or disabling VSAN or adding VSAN - eligible disks to the VSAN system for the host.
def vsan_configured(name, enabled, add_disks_to_vsan=False): ''' Configures a host's VSAN properties such as enabling or disabling VSAN, or adding VSAN-eligible disks to the VSAN system for the host. name Name of the state. enabled Ensures whether or not VSAN should be enabled on a...
Manage the SSH configuration for a host including whether or not SSH is running or the presence of a given SSH key. Note: Only one ssh key can be uploaded for root. Uploading a second key will replace any existing key.
def ssh_configured(name, service_running, ssh_key=None, ssh_key_file=None, service_policy=None, service_restart=False, certificate_verify=False): ''' Manage the SSH configuration for a host includin...
Ensures the specified syslog configuration parameters. By default this state will reset the syslog service after any new or changed parameters are set successfully.
def syslog_configured(name, syslog_configs, firewall=True, reset_service=True, reset_syslog_config=False, reset_configs=None): ''' Ensures the specified syslog configuration parameters. By default, ...
Configures the disk groups to use for vsan.
def diskgroups_configured(name, diskgroups, erase_disks=False): ''' Configures the disk groups to use for vsan. This function will do the following: 1. Check whether or not all disks in the diskgroup spec exist, and raises and errors if they do not. 2. Create diskgroups with the correct di...
Configures the host cache used for swapping.
def host_cache_configured(name, enabled, datastore, swap_size='100%', dedicated_backing_disk=False, erase_backing_disk=False): ''' Configures the host cache used for swapping. It will do the following: 1. Checks if backing disk exists 2. Creates...
Ensures that the hostname is set to the specified value.
def hostname(name, hostname=None): ''' Ensures that the hostname is set to the specified value. .. versionadded:: 2019.2.0 name: The name of the module function to execute. hostname(str): The hostname of the server. SLS Example: .. code-block:: yaml set_name: cimc.hos...
Ensures that the logging levels are set on the device. The logging levels must match the following options: emergency alert critical error warning notice informational debug.
def logging_levels(name, remote=None, local=None): ''' Ensures that the logging levels are set on the device. The logging levels must match the following options: emergency, alert, critical, error, warning, notice, informational, debug. .. versionadded:: 2019.2.0 name: The name of the module f...
Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four NTP servers will be reviewed. Any entries past four will be ignored.
def ntp(name, servers): ''' Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four NTP servers will be reviewed. Any entries past four will be ignored. name: The name of the module function to execute. servers(str, list): The IP address ...
Ensures that the power configuration is configured on the system. This is only available on some C - Series servers.
def power_configuration(name, policy=None, delayType=None, delayValue=None): ''' Ensures that the power configuration is configured on the system. This is only available on some C-Series servers. .. versionadded:: 2019.2.0 name: The name of the module function to execute. policy(str): The act...
Ensures that the syslog servers are set to the specified values. A value of None will be ignored.
def syslog(name, primary=None, secondary=None): ''' Ensures that the syslog servers are set to the specified values. A value of None will be ignored. name: The name of the module function to execute. primary(str): The IP address or FQDN of the primary syslog server. secondary(str): The IP address...
Ensures that a user is configured on the device. Due to being unable to verify the user password. This is a forced operation.
def user(name, id='', user='', priv='', password='', status='active'): ''' Ensures that a user is configured on the device. Due to being unable to verify the user password. This is a forced operation. .. versionadded:: 2019.2.0 name: The name of the module function to execute. id(int): The us...
This function gets called when the proxy starts up. For login the protocol and port are cached.
def init(opts): ''' This function gets called when the proxy starts up. For login the protocol and port are cached. ''' log.debug('Initting esxcluster proxy module in process %s', os.getpid()) log.debug('Validating esxcluster proxy input') schema = EsxclusterProxySchema.serialize() l...
Cycle through all the possible credentials and return the first one that works.
def find_credentials(): ''' Cycle through all the possible credentials and return the first one that works. ''' # if the username and password were already found don't fo though the # connection process again if 'username' in DETAILS and 'password' in DETAILS: return DETAILS['userna...
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 ''' template = get_roster_file(__opts__) rend = salt.loader.render(__opts__, {}) raw = compile_template(template, ...
Execute salt - key
def run(self): ''' Execute salt-key ''' import salt.key self.parse_args() self.setup_logfile_logger() verify_log(self.config) key = salt.key.KeyCLI(self.config) if check_user(self.config['user']): key.run()
Get a decrypted secret from the tISMd API
def get(key, service=None, profile=None): # pylint: disable=W0613 ''' Get a decrypted secret from the tISMd API ''' if not profile.get('url') or not profile.get('token'): raise SaltConfigurationError("url and/or token missing from the tism sdb profile") request = {"token": profile['token'...
Execute queries against POSTGRES merge and return as a dict
def ext_pillar(minion_id, pillar, *args, **kwargs): ''' Execute queries against POSTGRES, merge and return as a dict ''' return POSTGRESExtPillar().fetch(minion_id, pillar, *args, **kwargs)
Yield a POSTGRES cursor
def _get_cursor(self): ''' Yield a POSTGRES cursor ''' _options = self._get_options() conn = psycopg2.connect(host=_options['host'], user=_options['user'], password=_options['pass'], d...
This function normalizes the config block into a set of queries we can use. The return is a list of consistently laid out dicts.
def extract_queries(self, args, kwargs): ''' This function normalizes the config block into a set of queries we can use. The return is a list of consistently laid out dicts. ''' return super(POSTGRESExtPillar, self).extract_queries(args, kwargs)
Returns the cmdline of a Process instance.
def _get_proc_cmdline(proc): ''' Returns the cmdline of a Process instance. It's backward compatible with < 2.0 versions of psutil. ''' try: return salt.utils.data.decode(proc.cmdline() if PSUTIL2 else proc.cmdline) except (psutil.NoSuchProcess, psutil.AccessDenied): return []
Returns the create_time of a Process instance.
def _get_proc_create_time(proc): ''' Returns the create_time of a Process instance. It's backward compatible with < 2.0 versions of psutil. ''' try: return salt.utils.data.decode(proc.create_time() if PSUTIL2 else proc.create_time) except (psutil.NoSuchProcess, psutil.AccessDenied): ...
Returns the name of a Process instance.
def _get_proc_name(proc): ''' Returns the name of a Process instance. It's backward compatible with < 2.0 versions of psutil. ''' try: return salt.utils.data.decode(proc.name() if PSUTIL2 else proc.name) except (psutil.NoSuchProcess, psutil.AccessDenied): return []