INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Get a Group ID given a Group Name or Group Name and VPC ID
def get_group_id(name, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Get a Group ID given a Group Name or Group Name and VPC ID CLI example:: salt myminion boto_secgroup.get_group_id mysecgroup ''' conn = _get_conn(region=region, key=key...
Given a list of security groups and a vpc_id convert_to_group_ids will convert all list items in the given list to security group ids.
def convert_to_group_ids(groups, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Given a list of security groups and a vpc_id, convert_to_group_ids will convert all list items in the given list to security group ids. CLI example:: salt...
Get the configuration for a security group.
def get_config(name=None, group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None): ''' Get the configuration for a security group. CLI example:: salt myminion boto_secgroup.get_config mysecgroup ''' conn = _get_conn(region=region, key=key,...
Create a security group.
def create(name, description, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Create a security group. CLI example:: salt myminion boto_secgroup.create mysecgroup 'My Security Group' ''' conn = _get_conn(region=region, key=key, keyid=keyid, prof...
Delete a security group.
def delete(name=None, group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None): ''' Delete a security group. CLI example:: salt myminion boto_secgroup.delete mysecgroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Add a new rule to an existing security group.
def authorize(name=None, source_group_name=None, source_group_owner_id=None, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None, group_id=None, source_group_group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None, egres...
Given VPC properties find and return matching VPC ids. Borrowed from boto_vpc ; these could be refactored into a common library
def _find_vpcs(vpc_id=None, vpc_name=None, cidr=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Given VPC properties, find and return matching VPC ids. Borrowed from boto_vpc; these could be refactored into a common library ''' if all((vpc_id, vpc_name)): ...
sets tags on a security group
def set_tags(tags, name=None, group_id=None, vpc_name=None, vpc_id=None, region=None, key=None, keyid=None, profile=None): ''' sets tags on a security group .. versionadded:: 2016.3.0 tags a...
deletes tags from a security group
def delete_tags(tags, name=None, group_id=None, vpc_name=None, vpc_id=None, region=None, key=None, keyid=None, profile=None): ''' deletes tags from a security group .. versionadde...
List all available package upgrades on this system
def list_upgrades(refresh=True, root=None, **kwargs): ''' List all available package upgrades on this system refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed. root operate on a different root directory. ...
Return the information of the named package available for the system.
def info_available(*names, **kwargs): ''' Return the information of the named package available for the system. refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed or not. root operate on a different root direc...
.. versionadded:: 2015. 5. 4
def version_cmp(ver1, ver2, ignore_epoch=False, **kwargs): ''' .. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ...
List the packages currently installed as a dict. By default the dict contains versions as a comma separated string::
def list_pkgs(versions_as_list=False, root=None, includes=None, **kwargs): ''' List the packages currently installed as a dict. By default, the dict contains versions as a comma separated string:: {'<package_name>': '<version>[,<version>...]'} versions_as_list: If set to true, the vers...
.. versionadded:: 2017. 7. 5 2018. 3. 1
def list_repo_pkgs(*args, **kwargs): ''' .. versionadded:: 2017.7.5,2018.3.1 Returns all available packages. Optionally, package names (and name globs) can be passed and the results will be filtered to packages matching those names. This is recommended as it speeds up the function considerably. ...
Get all the info about repositories from the configurations.
def _get_configured_repos(root=None): ''' Get all the info about repositories from the configurations. ''' repos = os.path.join(root, os.path.relpath(REPOS, os.path.sep)) if root else REPOS repos_cfg = configparser.ConfigParser() if os.path.exists(repos): repos_cfg.read([repos + '/' + f...
Get one repo meta - data.
def _get_repo_info(alias, repos_cfg=None, root=None): ''' Get one repo meta-data. ''' try: meta = dict((repos_cfg or _get_configured_repos(root=root)).items(alias)) meta['alias'] = alias for key, val in six.iteritems(meta): if val in ['0', '1']: meta[k...
Lists all repos.
def list_repos(root=None, **kwargs): ''' Lists all repos. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.list_repos ''' repos_cfg = _get_configured_repos(root=root) all_repos = {} for alias in repos_cfg.sections(): ...
Delete a repo.
def del_repo(repo, root=None): ''' Delete a repo. root operate on a different root directory. CLI Examples: .. code-block:: bash salt '*' pkg.del_repo alias ''' repos_cfg = _get_configured_repos(root=root) for alias in repos_cfg.sections(): if alias == repo: ...
Modify one or more values for a repo. If the repo does not exist it will be created so long as the following values are specified:
def mod_repo(repo, **kwargs): ''' Modify one or more values for a repo. If the repo does not exist, it will be created, so long as the following values are specified: repo or alias alias by which Zypper refers to the repo url, mirrorlist or baseurl the URL for Zypper to reference ...
Force a repository refresh by calling zypper refresh -- force return a dict::
def refresh_db(root=None): ''' Force a repository refresh by calling ``zypper refresh --force``, return a dict:: {'<database name>': Bool} root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db ''' # Remove rtag file...
Form a package names list find prefixes of packages types.
def _find_types(pkgs): '''Form a package names list, find prefixes of packages types.''' return sorted({pkg.split(':', 1)[0] for pkg in pkgs if len(pkg.split(':', 1)) == 2})
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any zypper commands spawned by Salt when the salt - min...
def install(name=None, refresh=False, fromrepo=None, pkgs=None, sources=None, downloadonly=None, skip_verify=False, version=None, ignore_repo_failure=False, no_recommends=False, root=None, ...
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any zypper commands spawned by Salt when the salt - min...
def upgrade(refresh=True, dryrun=False, dist_upgrade=False, fromrepo=None, novendorchange=False, skip_verify=False, no_recommends=False, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:...
Remove and purge do identical things but with different Zypper commands this function performs the common logic.
def _uninstall(name=None, pkgs=None, root=None): ''' Remove and purge do identical things but with different Zypper commands, this function performs the common logic. ''' try: pkg_params = __salt__['pkg_resource.parse_targets'](name, pkgs)[0] except MinionError as exc: raise Comm...
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any zypper commands spawned by Salt when the salt - min...
def remove(name=None, pkgs=None, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemo...
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any zypper commands spawned by Salt when the salt - min...
def purge(name=None, pkgs=None, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon...
List current package locks.
def list_locks(root=None): ''' List current package locks. root operate on a different root directory. Return a dict containing the locked package with attributes:: {'<package>': {'case_sensitive': '<case_sensitive>', 'match_type': '<match_type>' ...
Remove unused locks that do not currently ( with regard to repositories used ) lock any package.
def clean_locks(root=None): ''' Remove unused locks that do not currently (with regard to repositories used) lock any package. root Operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.clean_locks ''' LCK = "removed" out = {LCK: 0}...
Remove specified package lock.
def unhold(name=None, pkgs=None, **kwargs): ''' Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,<package2>,<package3> salt '*' ...
Remove specified package lock.
def remove_lock(packages, root=None, **kwargs): # pylint: disable=unused-argument ''' Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,...
Add a package lock. Specify packages to lock by exact name.
def hold(name=None, pkgs=None, **kwargs): ''' Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg.add_lock <package1>,<package2>,<packag...
Add a package lock. Specify packages to lock by exact name.
def add_lock(packages, root=None, **kwargs): # pylint: disable=unused-argument ''' Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg....
List all known patterns in repos.
def _get_patterns(installed_only=None, root=None): ''' List all known patterns in repos. ''' patterns = {} for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'pattern').getElementsByTagName('solvable'): installed = element.getAttribute('status') == 'installed' if (insta...
List all known patterns from available repos.
def list_patterns(refresh=False, root=None): ''' List all known patterns from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI Examples:...
List known packages available to the system.
def search(criteria, refresh=False, **kwargs): ''' List known packages, available to the system. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. match (str) One of `exact`, `words`, `substrings`. Search fo...
Extract text from the first occurred DOM aggregate.
def _get_first_aggregate_text(node_list): ''' Extract text from the first occurred DOM aggregate. ''' if not node_list: return '' out = [] for node in node_list[0].childNodes: if node.nodeType == dom.Document.TEXT_NODE: out.append(node.nodeValue) return '\n'.join...
List all available or installed SUSE products.
def list_products(all=False, refresh=False, root=None): ''' List all available or installed SUSE products. all List all products available or only installed. Default is False. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is...
Download packages to the local disk.
def download(*packages, **kwargs): ''' Download packages to the local disk. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI example: .. code-block:...
List all known patches in repos.
def _get_patches(installed_only=False, root=None): ''' List all known patches in repos. ''' patches = {} for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'patch').getElementsByTagName('solvable'): installed = element.getAttribute('status') == 'installed' if (installed...
.. versionadded:: 2017. 7. 0
def list_patches(refresh=False, root=None, **kwargs): ''' .. versionadded:: 2017.7.0 List all known advisory patches from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate ...
.. versionadded:: 2018. 3. 0
def list_provides(root=None, **kwargs): ''' .. versionadded:: 2018.3.0 List package provides of installed packages as a dict. {'<provided_name>': ['<package_name>', '<package_name>', ...]} root operate on a different root directory. CLI Examples: .. code-block:: bash sal...
.. versionadded:: 2018. 3. 0
def resolve_capabilities(pkgs, refresh=False, root=None, **kwargs): ''' .. versionadded:: 2018.3.0 Convert name provides in ``pkgs`` into real package names if ``resolve_capabilities`` parameter is set to True. In case of ``resolve_capabilities`` is set to False the package list is returned unc...
Resets values of the call setup.
def _reset(self): ''' Resets values of the call setup. :return: ''' self.__cmd = ['zypper', '--non-interactive'] self.__exit_code = 0 self.__call_result = dict() self.__error_msg = '' self.__env = salt.utils.environment.get_module_environment(glob...
Is this is an error code?
def _is_error(self): ''' Is this is an error code? :return: ''' if self.exit_code: msg = self.SUCCESS_EXIT_CODES.get(self.exit_code) if msg: log.info(msg) msg = self.WARNING_EXIT_CODES.get(self.exit_code) if msg: ...
Is Zypper s output is in XML format?
def _is_xml_mode(self): ''' Is Zypper's output is in XML format? :return: ''' return [itm for itm in self.XML_DIRECTIVES if itm in self.__cmd] and True or False
Check and set the result of a zypper command. In case of an error either raise a CommandExecutionError or extract the error.
def _check_result(self): ''' Check and set the result of a zypper command. In case of an error, either raise a CommandExecutionError or extract the error. result The result of a zypper command called with cmd.run_all ''' if not self.__call_result: ...
Call Zypper.
def __call(self, *args, **kwargs): ''' Call Zypper. :param state: :return: ''' self.__called = True if self.__xml: self.__cmd.append('--xmlout') if not self.__refresh and '--no-refresh' not in args: self.__cmd.append('--no-refresh'...
Get available versions of the package.: return:
def _get_available_versions(self): ''' Get available versions of the package. :return: ''' solvables = self.zypper.nolock.xml.call('se', '-xv', self.name).getElementsByTagName('solvable') if not solvables: raise CommandExecutionError('No packages found matchin...
Get available difference between next possible matches.
def _get_scope_versions(self, pkg_versions): ''' Get available difference between next possible matches. :return: ''' get_in_versions = [] for p_version in pkg_versions: if fnmatch.fnmatch(p_version, self.version): get_in_versions.append(p_ver...
Stash operator from the version if any.
def _set_version(self, version): ''' Stash operator from the version, if any. :return: ''' if not version: return exact_version = re.sub(r'[<>=+]*', '', version) self._op = version.replace(exact_version, '') or None if self._op and self._op n...
Make sure that any terminal processes still running when __del__ was called to the waited and cleaned up.
def _cleanup(): ''' Make sure that any terminal processes still running when __del__ was called to the waited and cleaned up. ''' for inst in _ACTIVE[:]: res = inst.isalive() if res is not True: try: _ACTIVE.remove(inst) except ValueError: ...
Send the provided data to the terminal appending a line feed.
def sendline(self, data, linesep=os.linesep): ''' Send the provided data to the terminal appending a line feed. ''' return self.send('{0}{1}'.format(data, linesep))
Receive data from the terminal as a ( stdout stderr ) tuple. If any of those is None we can no longer communicate with the terminal s child process.
def recv(self, maxsize=None): ''' Receive data from the terminal as a (``stdout``, ``stderr``) tuple. If any of those is ``None`` we can no longer communicate with the terminal's child process. ''' if maxsize is None: maxsize = 1024 elif maxsize < 1: ...
Close the communication with the terminal s child. If terminate is True then additionally try to terminate the terminal and if kill is also True kill the terminal if terminating it was not enough.
def close(self, terminate=True, kill=False): ''' Close the communication with the terminal's child. If ``terminate`` is ``True`` then additionally try to terminate the terminal, and if ``kill`` is also ``True``, kill the terminal if terminating it was not enough. ''' ...
Ensure the RackSpace queue exists.
def present(name, provider): ''' Ensure the RackSpace queue exists. name Name of the Rackspace queue. provider Salt Cloud Provider ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} is_present = list(__salt__['cloud.action']('queues_exists', provider=pr...
Ensure the named Rackspace queue is deleted.
def absent(name, provider): ''' Ensure the named Rackspace queue is deleted. name Name of the Rackspace queue. provider Salt Cloud provider ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} is_present = list(__salt__['cloud.action']('queues_exists', pr...
Connect to the DRAC
def __connect(hostname, timeout=20, username=None, password=None): ''' Connect to the DRAC ''' drac_cred = __opts__.get('drac') err_msg = 'No drac login credentials found. Please add the \'username\' and \'password\' ' \ 'fields beneath a \'drac\' key in the master configuration file. ...
Grab DRAC version
def __version(client): ''' Grab DRAC version ''' versions = {9: 'CMC', 8: 'iDRAC6', 10: 'iDRAC6', 11: 'iDRAC6', 16: 'iDRAC7', 17: 'iDRAC7'} if isinstance(client, paramiko.SSHClient): (stdin, stdout, stderr) = cl...
Connect to the Dell DRAC and have the boot order set to PXE and power cycle the system to PXE boot
def pxe(hostname, timeout=20, username=None, password=None): ''' Connect to the Dell DRAC and have the boot order set to PXE and power cycle the system to PXE boot CLI Example: .. code-block:: bash salt-run drac.pxe example.com ''' _cmds = [ 'racadm config -g cfgServerInfo...
Reboot a server using the Dell DRAC
def reboot(hostname, timeout=20, username=None, password=None): ''' Reboot a server using the Dell DRAC CLI Example: .. code-block:: bash salt-run drac.reboot example.com ''' client = __connect(hostname, timeout, username, password) if isinstance(client, paramiko.SSHClient): ...
Display the version of DRAC
def version(hostname, timeout=20, username=None, password=None): ''' Display the version of DRAC CLI Example: .. code-block:: bash salt-run drac.version example.com ''' return __version(__connect(hostname, timeout, username, password))
Emit the status of a connected display to the minion
def beacon(config): ''' Emit the status of a connected display to the minion Mainly this is used to detect when the display fails to connect for whatever reason. .. code-block:: yaml beacons: glxinfo: - user: frank - screen_event: True ''' log.t...
Retrieve master config options with optional nesting via the delimiter argument.
def get(key, default='', delimiter=':'): ''' Retrieve master config options, with optional nesting via the delimiter argument. **Arguments** default If the key is not found, the default will be returned instead delimiter Override the delimiter used to separate nested levels ...
Reissues a purchased SSL certificate. Returns a dictionary of result values.
def reissue(csr_file, certificate_id, web_server_type, approver_email=None, http_dc_validation=False, **kwargs): ''' Reissues a purchased SSL certificate. Returns a dictionary of result values. csr_file Path to Certificate Signing Requ...
Renews an SSL certificate if it is ACTIVE and Expires < = 30 days. Returns the following information:
def renew(years, certificate_id, certificate_type, promotion_code=None): ''' Renews an SSL certificate if it is ACTIVE and Expires <= 30 days. Returns the following information: - The certificate ID - The order ID - The transaction ID - The amount charged for the order years : 1 ...
Creates a new SSL certificate. Returns the following information:
def create(years, certificate_type, promotion_code=None, sans_to_add=None): ''' Creates a new SSL certificate. Returns the following information: - Whether or not the SSL order was successful - The certificate ID - The order ID - The transaction ID - The amount charged for the order - T...
Parses the CSR. Returns a dictionary of result values.
def parse_csr(csr_file, certificate_type, http_dc_validation=False): ''' Parses the CSR. Returns a dictionary of result values. csr_file Path to Certificate Signing Request file certificate_type Type of SSL Certificate. Possible values include: - EV Multi Domain SSL - ...
Returns a list of SSL certificates for a particular user
def get_list(**kwargs): ''' Returns a list of SSL certificates for a particular user ListType : All Possible values: - All - Processing - EmailSent - TechnicalProblem - InProgress - Completed - Deactivated - Active - Cancelled...
Retrieves information about the requested SSL certificate. Returns a dictionary of information about the SSL certificate with two keys:
def get_info(certificate_id, returncertificate=False, returntype=None): ''' Retrieves information about the requested SSL certificate. Returns a dictionary of information about the SSL certificate with two keys: - **ssl** - Contains the metadata information - **certificate** - Contains the details ...
Return the changes
def _check_cron(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None, comment=None, commented=None, identifier=None, special=None): ''...
Return the environment changes
def _check_cron_env(user, name, value=None): ''' Return the environment changes ''' if value is None: value = "" # Matching value set in salt.modules.cron._render_tab lst = __salt__['cron.list_tab'](user) for env in lst['env']: if name == ...
Returns the proper group owner and path to the cron directory
def _get_cron_info(): ''' Returns the proper group owner and path to the cron directory ''' owner = 'root' if __grains__['os'] == 'FreeBSD': group = 'wheel' crontab_dir = '/var/cron/tabs' elif __grains__['os'] == 'OpenBSD': group = 'crontab' crontab_dir = '/var/cr...
Verifies that the specified cron job is present for the specified user. It is recommended to use identifier. Otherwise the cron job is installed twice if you change the name. For more advanced information about what exactly can be set in the cron timing parameters check your cron system s documentation. Most Unix - lik...
def present(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*', comment=None, commented=False, identifier=False, special=None): ''' Verifies that the specified cron ...
Verifies that the specified cron job is absent for the specified user ; only the name is matched when removing a cron job.
def absent(name, user='root', identifier=False, special=None, **kwargs): ''' Verifies that the specified cron job is absent for the specified user; only the name is matched when removing a cron job. name The command that should be absent in the user c...
Provides file. managed - like functionality ( templating etc. ) for a pre - made crontab file to be assigned to a given user.
def file(name, source_hash='', source_hash_name=None, user='root', template=None, context=None, replace=True, defaults=None, backup='', **kwargs): ''' Provides file.managed-like functionality (templating, etc.) for a pre-made c...
Verifies that the specified environment variable is present in the crontab for the specified user.
def env_present(name, value=None, user='root'): ''' Verifies that the specified environment variable is present in the crontab for the specified user. name The name of the environment variable to set in the user crontab user The name of the user whos...
Verifies that the specified environment variable is absent from the crontab for the specified user
def env_absent(name, user='root'): ''' Verifies that the specified environment variable is absent from the crontab for the specified user name The name of the environment variable to remove from the user crontab user The name of the user whose crontab needs to be mod...
The HighState Outputter is only meant to be used with the state. highstate function or a function that returns highstate return data.
def output(data, **kwargs): # pylint: disable=unused-argument ''' The HighState Outputter is only meant to be used with the state.highstate function, or a function that returns highstate return data. ''' if len(data.keys()) == 1: # account for nested orchs via saltutil.runner if 're...
Main highstate formatter. can be called recursively if a nested highstate contains other highstates ( ie in an orchestration )
def _format_host(host, data, indent_level=1): ''' Main highstate formatter. can be called recursively if a nested highstate contains other highstates (ie in an orchestration) ''' host = salt.utils.data.decode(host) colors = salt.utils.color.get_colors( __opts__.get('color'), ...
Print the changes data using the nested outputter
def _nested_changes(changes): ''' Print the changes data using the nested outputter ''' ret = '\n' ret += salt.output.out_format( changes, 'nested', __opts__, nested_indent=14) return ret
Format the changes dict based on what the data is
def _format_changes(changes, orchestration=False): ''' Format the changes dict based on what the data is ''' if not changes: return False, '' if orchestration: return True, _nested_changes(changes) if not isinstance(changes, dict): return True, 'Invalid Changes data: {0...
Terse formatting of a message.
def _format_terse(tcolor, comps, ret, colors, tabular): ''' Terse formatting of a message. ''' result = 'Clean' if ret['changes']: result = 'Changed' if ret['result'] is False: result = 'Failed' elif ret['result'] is None: result = 'Differs' if tabular is True: ...
The kernerpkg watcher called to invoke the watch command. When called execute a kernelpkg state based on a watch or listen call.
def mod_watch(name, sfun, **kwargs): ''' The kernerpkg watcher, called to invoke the watch command. When called, execute a kernelpkg state based on a watch or listen call. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should n...
PRIVATE METHOD Checks to see if the value of a primitive or built - in container such as a list dict set tuple etc is empty or none. None type is returned if the value is empty/ None/ False. Number data types that are 0 will return None.
def _get_none_or_value(value): ''' PRIVATE METHOD Checks to see if the value of a primitive or built-in container such as a list, dict, set, tuple etc is empty or none. None type is returned if the value is empty/None/False. Number data types that are 0 will return None. value : obj The...
PRIVATE METHOD Creates a new return dict with default values. Defaults may be overwritten.
def _get_return_dict(success=True, data=None, errors=None, warnings=None): ''' PRIVATE METHOD Creates a new return dict with default values. Defaults may be overwritten. success : boolean (True) True indicates a successful result. data : dict<str,obj> ({}) Data to be returned to the...
PRIVATE METHOD Updates the return dictionary and returns it.
def _update_return_dict(ret, success, data, errors=None, warnings=None): ''' PRIVATE METHOD Updates the return dictionary and returns it. ret : dict<str,obj> The original return dict to update. The ret param should have been created from _get_return_dict() success : boolean (True) ...
PRIVATE METHOD Formats the URL based on parameters and if cores are used or not
def _format_url(handler, host=None, core_name=None, extra=None): ''' PRIVATE METHOD Formats the URL based on parameters, and if cores are used or not handler : str The request handler to hit. host : str (None) The solr host to query. __opts__['host'] is default core_name : str (...
Install an auth handler for urllib2
def _auth(url): ''' Install an auth handler for urllib2 ''' user = __salt__['config.get']('solr.user', False) password = __salt__['config.get']('solr.passwd', False) realm = __salt__['config.get']('solr.auth_realm', 'Solr') if user and password: basic = _HTTPBasicAuthHandler() ...
PRIVATE METHOD Uses salt. utils. json. load to fetch the JSON results from the solr API.
def _http_request(url, request_timeout=None): ''' PRIVATE METHOD Uses salt.utils.json.load to fetch the JSON results from the solr API. url : str a complete URL that can be passed to urllib.open request_timeout : int (None) The number of seconds before the timeout should fail. Leave...
PRIVATE METHOD Performs the requested replication command and returns a dictionary with success errors and data as keys. The data object will contain the JSON response.
def _replication_request(command, host=None, core_name=None, params=None): ''' PRIVATE METHOD Performs the requested replication command and returns a dictionary with success, errors and data as keys. The data object will contain the JSON response. command : str The replication command ...
PRIVATE METHOD Calls the _http_request method and passes the admin command to execute and stores the data. This data is fairly static but should be refreshed periodically to make sure everything this OK. The data object will contain the JSON response.
def _get_admin_info(command, host=None, core_name=None): ''' PRIVATE METHOD Calls the _http_request method and passes the admin command to execute and stores the data. This data is fairly static but should be refreshed periodically to make sure everything this OK. The data object will contain th...
PRIVATE METHOD updates the default import options from __opts__ [ solr. dih. import_options ] with the dictionary passed in. Also converts booleans to strings to pass to solr.
def _merge_options(options): ''' PRIVATE METHOD updates the default import options from __opts__['solr.dih.import_options'] with the dictionary passed in. Also converts booleans to strings to pass to solr. options : dict<str,boolean> Dictionary the over rides the default options define...
PRIVATE METHOD - MASTER CALL Does a pre - check to make sure that all the options are set and that we can talk to solr before trying to send a command to solr. This Command should only be issued to masters.
def _pre_index_check(handler, host=None, core_name=None): ''' PRIVATE METHOD - MASTER CALL Does a pre-check to make sure that all the options are set and that we can talk to solr before trying to send a command to solr. This Command should only be issued to masters. handler : str The im...
PRIVATE METHOD Traverses a dictionary of dictionaries/ lists to find key and return the value stored. TODO:// this method doesn t really work very well and it s not really very useful in its current state. The purpose for this method is to simplify parsing the JSON output so you can just pass the key you want to find a...
def _find_value(ret_dict, key, path=None): ''' PRIVATE METHOD Traverses a dictionary of dictionaries/lists to find key and return the value stored. TODO:// this method doesn't really work very well, and it's not really very useful in its current state. The purpose for this method is ...
Gets the lucene version that solr is using. If you are running a multi - core setup you should specify a core name since all the cores run under the same servlet container they will all have the same version.
def lucene_version(core_name=None): ''' Gets the lucene version that solr is using. If you are running a multi-core setup you should specify a core name since all the cores run under the same servlet container, they will all have the same version. core_name : str (None) The name of the solr...
Gets the solr version for the core specified. You should specify a core here as all the cores will run under the same servlet container and so will all have the same version.
def version(core_name=None): ''' Gets the solr version for the core specified. You should specify a core here as all the cores will run under the same servlet container and so will all have the same version. core_name : str (None) The name of the solr core if using cores. Leave this blank ...
Search queries fast but it is a very expensive operation. The ideal process is to run this with a master/ slave configuration. Then you can optimize the master and push the optimized index to the slaves. If you are running a single solr instance or if you are going to run this on a slave be aware than search performanc...
def optimize(host=None, core_name=None): ''' Search queries fast, but it is a very expensive operation. The ideal process is to run this with a master/slave configuration. Then you can optimize the master, and push the optimized index to the slaves. If you are running a single solr instance, or if ...
Does a health check on solr makes sure solr can talk to the indexes.
def ping(host=None, core_name=None): ''' Does a health check on solr, makes sure solr can talk to the indexes. host : str (None) The solr host to query. __opts__['host'] is default. core_name : str (None) The name of the solr core if using cores. Leave this blank if you are not ...
SLAVE CALL Check for errors and determine if a slave is replicating or not.
def is_replication_enabled(host=None, core_name=None): ''' SLAVE CALL Check for errors, and determine if a slave is replicating or not. host : str (None) The solr host to query. __opts__['host'] is default. core_name : str (None) The name of the solr core if using cores. Leave this ...
SLAVE CALL Verifies that the master and the slave versions are in sync by comparing the index version. If you are constantly pushing updates the index the master and slave versions will seldom match. A solution to this is pause indexing every so often to allow the slave to replicate and then call this method before all...
def match_index_versions(host=None, core_name=None): ''' SLAVE CALL Verifies that the master and the slave versions are in sync by comparing the index version. If you are constantly pushing updates the index the master and slave versions will seldom match. A solution to this is pause indexing ev...