Service Script python reference¶
LMI software provider client library.
Package specification¶
Referred to as pkg_spec. Is a string identifying set of packages. It constitutes at least of package name. Each additional detail narrows the the possible set of matchin packages. The most complete specifications are nevra and envra.
Follows the list of all possible specifications:
- <name>
- <name>.<arch>
- <name>-<version>-<release>.<arch> (nvra)
- <name>-<epoch>:<version>-<release>.<arch> (nevra)
- <epoch>:<name>-<version>-<release>.<arch> (envra)
Regular expressions¶
These may be used check, whether the given pkg_spec is valid and allows to get all the interesting parts out of it.
- lmi.scripts.software.RE_NA¶
Regular expression matching package specified as <name>.<arch>.
- lmi.scripts.software.RE_NEVRA¶
Regular expression matching package specified as:
<name>-<epoch>:<version>-<release>.<arch>
The epoch part is optional. So it can be used also to match nvra string.
- lmi.scripts.software.RE_ENVRA¶
Regular expression matching package specified as:
<epoch>:<name>-<version>-<release>.<arch>
Functions¶
- lmi.scripts.software.FILE_TYPES = ('Unknown', 'File', 'Directory', 'Symlink', 'FIFO', 'Character Device', 'Block Device')¶
Array of file type names.
- lmi.scripts.software.find_package(ns, allow_duplicates=False, exact_match=True, **kwargs)¶
Yields just a limited set of packages matching particular filter. Keyword arguments are used to specify this filter, which can contain following keys:
- name :
- Package name.
- epoch :
- package’s epoch
- version :
- version of package
- release :
- release of package
- arch :
- requested architecture of package
- nevra :
string containing all previous keys in following notation:
<name>-<epoch>:<version>-<release>.<arch>
- envra :
similar to nevra, the notation is different:
<epoch>:<name>-<version>-<release>.<arch>
- repoid :
- repository identification string, where package must be available
- pkg_spec :
- Package specification string. See Package specification.
Parameters: - allow_duplicates (boolean) – Whether the output shall contain multiple versions of the same packages identified with <name>.<architecture>.
- exact_match (boolean) – Whether the name key shall be tested for exact match. If False it will be tested for inclusion.
Returns: Instance names of LMI_SoftwareIdentity.
Return type: generator over lmi.shell.LmiInstanceName
- lmi.scripts.software.get_package_nevra(package)¶
Get a nevra from an instance of LMI_SoftwareIdentity.
Parameters: package (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance or instance name of LMI_SoftwareIdentity representing package to install. Returns: Nevra string of particular package. Return type: string
- lmi.scripts.software.get_repository(ns, repoid)¶
Return an instance of repository identified by its identification string.
Parameters: repoid (string) – Identification string of repository. Returns: Instance of LMI_SoftwareIdentityResource. Return type: lmi.shell.LMIInstance
- lmi.scripts.software.install_from_uri(ns, uri, force=False, update=False)¶
Install package from URI on remote system.
Parameters: - uri (string) – Identifier of RPM package available via http, https, or ftp service.
- force (boolean) – Whether the installation shall be done even if installing the same (reinstalling) or older version than already installed.
- update (boolean) – Whether this is an update. Update fails if package is not already installed on system.
- lmi.scripts.software.install_package(ns, package, force=False, update=False)¶
Install package on system.
Parameters: - package (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance or instance name of LMI_SoftwareIdentity representing package to install.
- force (boolean) – Whether the installation shall be done even if installing the same (reinstalling) or older version than already installed.
- update (boolean) – Whether this is an update. Update fails if package is not already installed on system.
Returns: Software identity installed on remote system. It’s an instance LMI_SoftwareIdentity.
Return type:
- lmi.scripts.software.list_available_packages(ns, allow_installed=False, allow_duplicates=False, repoid=None)¶
Yields instances of LMI_SoftwareIdentity representing available packages.
Parameters: - allow_installed (boolean) – Whether to include available packages that are installed.
- allow_duplicates (boolean) – Whether to include duplicates packages (those having same name and architecture). Otherwise only the newest packages available for each (name, architecture) pair will be contained in result.
- repoid (string) – Repository identification string. This will filter available packages just for those provided by this repository.
Return type: generator
- lmi.scripts.software.list_installed_packages(ns)¶
Yields instances of LMI_SoftwareIdentity representing installed packages.
Return type: generator
- lmi.scripts.software.list_package_files(ns, package, file_type=None)¶
Get a list of files belonging to particular installed RPM package. Yields instances of LMI_SoftwareIdentityFileCheck.
Parameters: - package (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance or instance name of LMI_SoftwareIdentity.
- file_type (string, integer or None) – Either an index to FILE_TYPES array or one of: { "all", "file", "directory", "symlink", "fifo", "device" }.
Returns: Instances of LMI_SoftwareIdentityFileCheck.
Return type: generator over lmi.shell.LMIInstance
- lmi.scripts.software.list_repositories(ns, enabled=True)¶
Yields instances of LMI_SoftwareIdentityResource representing software repositories.
Parameters: enabled (boolean or None) – Whether to list only enabled repositories. If False only disabled repositories shall be listed. If None, all repositories shall be listed. Returns: Instances of LMI_SoftwareIdentityResource Return type: generator over lmi.shell.LMIInstance
- lmi.scripts.software.pkg_spec_to_filter(pkg_spec)¶
Converts package specification to a set of keys, that can be used to query package properties.
Parameters: pkg_spec (string) – Package specification (see Package specification). Only keys given in this string will appear in resulting dictionary. Returns: Dictionary with possible keys being a subset of following: {'name', 'epoch', 'version', 'release', 'arch'}. Values are non-empty parts of pkg_spec string. Return type: dictionary
- lmi.scripts.software.remove_package(ns, package)¶
Uninstall given package from system.
Raises: LmiFailed` will be raised on failure. Parameters: package (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance or instance name of LMI_SoftwareIdentity representing package to remove.
- lmi.scripts.software.render_failed_flags(failed_flags)¶
Make one liner string representing failed flags list of file that did not pass the verification.
Parameters: failed_flags (list) – Value of FailedFlags property of some LMI_SoftwareIdentityFileCheck. Returns: Verification string with format matching the output of rpm -V command. Return type: string
- lmi.scripts.software.set_repository_enabled(ns, repository, enable=True)¶
Enable or disable repository.
Parameters: - repository (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance of LMI_SoftwareIdentityResource.
- enable (boolean) – New value of EnabledState property.
Returns: Previous value of repository’s EnabledState.
Return type: boolean
- lmi.scripts.software.verify_package(ns, package)¶
Returns the instances of LMI_SoftwareIdentityFileCheck representing files, that did not pass the verification.
Parameters: package (lmi.shell.LMIInstance or lmi.shell.LMIInstanceName) – Instance or instance name of LMI_SoftwareIdentity representing package to verify. Returns: List of instances of LMI_SoftwareIdentityFileCheck with non-empty FailedFlags property. Return type: list