Software 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
nvrastring.
-
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, installed=None, **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
namekey shall be tested for exact match. IfFalseit will be tested for inclusion. - installed (boolean) -- Limit the search to installed or not installed packages. Unless set to boolean value, all packages will be searched for matching one.
Returns: Instance names of
LMI_SoftwareIdentity.Return type: generator over
lmi.shell.LmiInstanceName
-
lmi.scripts.software.get_backend(ns)¶ Get provider's backend code.
Returns: One of BACKEND_YUM,BACKEND_PACKAGEKITReturn type: int
-
lmi.scripts.software.get_installation_service(ns)¶ Get and cache installation service instance.
Returns: An instance of LMI_SoftwareInstallationService.
-
lmi.scripts.software.get_package_nevra(package)¶ Get a nevra from an instance of
LMI_SoftwareIdentity.Parameters: package ( lmi.shell.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance or instance name ofLMI_SoftwareIdentityrepresenting 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.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance or instance name ofLMI_SoftwareIdentityrepresenting 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.shell.LMIInstance- package (
-
lmi.scripts.software.is_package_installed(package, installed_nevras=None)¶ Parameters: installed_nevras (set) -- An optional set of nevra strings of installed packages. This speeds up processing it PackageKit backend is used.. Returns: Trueif the package is installedReturn type: boolean
-
lmi.scripts.software.list_available_packages(ns, allow_installed=False, allow_duplicates=False, repoid=None, installed_nevras=None)¶ Yields instances of
LMI_SoftwareIdentityrepresenting 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 to those provided by this repository.
- installed_nevras -- Set of nevra strings of installed packages. This speeds up execution for PackageKit backend.
Return type: generator
-
lmi.scripts.software.list_installed_packages(ns)¶ Yields instances of
LMI_SoftwareIdentityrepresenting 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.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance or instance name ofLMI_SoftwareIdentity. - file_type (string, integer or
None) -- Either an index toFILE_TYPESarray or one of:{ "all", "file", "directory", "symlink", "fifo", "device" }.
Returns: Instances of
LMI_SoftwareIdentityFileCheck.Return type: generator over
lmi.shell.LMIInstance- package (
-
lmi.scripts.software.list_repositories(ns, enabled=True)¶ Yields instances of
LMI_SoftwareIdentityResourcerepresenting software repositories.Parameters: enabled (boolean or None) -- Whether to list only enabled repositories. IfFalseonly disabled repositories shall be listed. IfNone, all repositories shall be listed.Returns: Instances of LMI_SoftwareIdentityResourceReturn 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 ofpkg_specstring.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.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance or instance name ofLMI_SoftwareIdentityrepresenting 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 FailedFlagsproperty of someLMI_SoftwareIdentityFileCheck.Returns: Verification string with format matching the output of rpm -Vcommand.Return type: string
-
lmi.scripts.software.set_repository_enabled(ns, repository, enable=True)¶ Enable or disable repository.
Parameters: - repository (
lmi.shell.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance ofLMI_SoftwareIdentityResource. - enable (boolean) -- New value of
EnabledStateproperty.
Returns: Previous value of repository's
EnabledState.Return type: boolean
- repository (
-
lmi.scripts.software.verify_package(ns, package)¶ Returns the instances of
LMI_SoftwareIdentityFileCheckrepresenting files, that did not pass the verification.Parameters: package ( lmi.shell.LMIInstanceorlmi.shell.LMIInstanceName) -- Instance or instance name ofLMI_SoftwareIdentityrepresenting package to verify.Returns: List of instances of LMI_SoftwareIdentityFileCheckwith non-emptyFailedFlagsproperty.Return type: list