InstalledRpms - Command rpm -qa
¶
InstalledRpms - command rpm -qa
¶
ContainerInstalledRpms - command rpm -qa
for containers¶
-
class
insights.parsers.installed_rpms.
ContainerInstalledRpms
(context)[source]¶ Bases:
insights.core.ContainerParser
,insights.parsers.installed_rpms.InstalledRpms
Parses the data for list of installed rpms of the running containers which are based on RHEL images.
Sample output:
a52dec-0.7.4-18.el7.nux.x86_64 Tue 14 Jul 2015 09:25:38 AEST 1398536494 aalib-libs-1.4.0-0.22.rc5.el7.x86_64 Tue 14 Jul 2015 09:25:40 AEST 1390535634 abrt-2.1.11-35.el7.x86_64 Wed 09 Nov 2016 14:52:01 AEDT 1446193355 kernel-3.10.0-267.el7.x86_64 Sat 24 Oct 2015 09:56:17 AEDT 1434466402 kernel-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:53:25 AEDT 1476954923 kernel-headers-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:20:59 AEDT 1476954923 kernel-tools-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 15:09:42 AEDT 1476954923 kernel-tools-libs-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:52:13 AEDT 1476954923 kexec-tools-2.0.7-38.el7_2.1.x86_64 Wed 09 Nov 2016 14:48:21 AEDT 1452845178 zlib-1.2.7-15.el7.x86_64 Wed 09 Nov 2016 14:21:19 AEDT 1431443476 zsh-5.0.2-14.el7_2.2.x86_64 Wed 09 Nov 2016 15:13:19 AEDT 1464185248
Examples
>>> type(container_rpms) <class 'insights.parsers.installed_rpms.ContainerInstalledRpms'> >>> container_rpms.container_id 'cc2883a1a369' >>> container_rpms.image 'quay.io/rhel8' >>> container_rpms.engine 'podman' >>> container_rpms.get_min('kernel').package == 'kernel-3.10.0-267.el7' True >>> container_rpms.get_max("kernel").name 'kernel' >>> container_rpms.get_max("kernel").version '3.10.0'
-
insights.parsers.installed_rpms.
Installed
¶
-
class
insights.parsers.installed_rpms.
InstalledRpm
(data)[source]¶ Bases:
object
Class for holding information about one installed RPM.
This class is usually created from dictionary with following structure:
{ 'name': 'package name', 'version': 'package version', 'release': 'package release', 'arch': 'package architecture' }
It may also contain supplementary information from SOS report or epoch information from JSON.
When comparing rpms whose epoch is not
null
, it is necessary to create InstalledRpm object with epoch information like following example:InstalledRpm.from_json('{"name":"microcode_ctl","epoch":"4","version":"20200609","release":"2.20201027.1.el8_3"}'
Factory methods are provided such as
from_package
to create an object from a short package string:kernel-devel-3.10.0-327.36.1.el7.x86_64
from_json
to create an object from JSON:{"name": "kernel-devel", "version": "3.10.0", "release": "327.36.1.el7", "arch": "x86_64"}
and
from_line
to create an object from a long package string:('kernel-devel-3.10.0-327.36.1.el7.x86_64' ' ' 'Wed May 18 14:16:21 2016' ' ' '1410968065' ' ' 'Red Hat, Inc.' ' ' 'hs20-bc2-4.build.redhat.com' ' ' '8902150305004...b3576ff37da7e12e2285358267495ac48a437d4eefb3213' ' ' 'RSA/8, Mon Aug 16 11:14:17 2010, Key ID 199e2f91fd431d51')
-
PRODUCT_SIGNING_KEYS
= ['199e2f91fd431d51', '1ac4971355a34a82', '5054e4a45a6340b3', 'e1a4bd708a828aad', 'f76f66c3d4082792', '5326810137017186', '45689c882fa658e0', '219180cddb42a60e', '7514f77d8366b0d9', '08dd962c1c711042', 'fd372689897da07a', '938a80caf21541eb08b871e6a5787476', 'e191ddb2c509e861', '66e8f8a29c65f85c', '680b9144769a9f8f', '8ed29db42a2898c8']¶ List of package-signing keys in all lower cases. Should be updated timely according to https://access.redhat.com/security/team/key/
Type: list
-
SOSREPORT_KEYS
= ['installtime', 'buildtime', 'vendor', 'buildserver', 'pgpsig', 'pgpsig_short']¶ List of keys for SOS Report RPM information.
Type: list
-
arch
= None¶ RPM package architecture.
Type: str
-
classmethod
from_json
(json_line)[source]¶ The object of this class is usually created from dictionary. Alternatively it can be created from JSON line.
Parameters: json_line (str) -- JSON string in the following format (shown as Python string):
'{"name": "kernel-devel", "version": "3.10.0", "release": "327.36.1.el7", "arch": "x86_64"}'
-
classmethod
from_line
(line)[source]¶ The object of this class is usually created from dictionary. Alternatively it can be created from package line.
Parameters: line (str) -- package line in the following format (shown as Python string):
('kernel-devel-3.10.0-327.36.1.el7.x86_64' ' ' 'Wed May 18 14:16:21 2016' ' ' '1410968065' ' ' 'Red Hat, Inc.' ' ' 'hs20-bc2-4.build.redhat.com' ' ' '8902150305004...b3576ff37da7e12e2285358267495ac48a437d4eefb3213' ' ' 'RSA/8, Mon Aug 16 11:14:17 2010, Key ID 199e2f91fd431d51')
-
classmethod
from_package
(package_string)[source]¶ The object of this class is usually created from dictionary. Alternatively it can be created from package string.
Parameters: package_string (str) -- package string in the following format (shown as Python string):
'kernel-devel-3.10.0-327.36.1.el7.x86_64'
-
name
= None¶ RPM package name.
Type: str
-
nevra
¶ Package string in the format:
name-epoch:version-release.arch
Type: str
-
nvr
¶ Package name-version-release string.
Type: str
-
nvra
¶ Package name-version-release.arch string.
Type: str
-
package
¶ Package name-version-release string.
Type: str
-
package_with_epoch
¶ Package string in the format:
name-epoch:version-release
Type: str
-
redhat_signed
= None¶ True when RPM package is signed by Red Hat, False when RPM package is not signed by Red Hat, None when no sufficient info to determine
Type: bool
-
release
= None¶ RPM package release.
Type: str
-
source
¶ Returns source RPM of this RPM object.
Type: InstalledRpm
-
vendor
= None¶ RPM package vendor. None when no ‘vendor’ info
Type: str
-
version
= None¶ RPM package version.
Type: str
-
-
class
insights.parsers.installed_rpms.
InstalledRpms
(*args, **kwargs)[source]¶ Bases:
insights.core.CommandParser
,insights.parsers.installed_rpms.RpmList
The
InstalledRpms
class parses the output of therpm -qa
command. Each line is parsed and stored in anInstalledRpm
object. Therpm -qa
command may output data in different formats and each format can be handled by the parsing routines of this class. The basic format of command is the package and is shown in the Examples.A parser for working with data containing a list of installed RPM files on the system and related information.
Sample input data:
a52dec-0.7.4-18.el7.nux.x86_64 Tue 14 Jul 2015 09:25:38 AEST 1398536494 aalib-libs-1.4.0-0.22.rc5.el7.x86_64 Tue 14 Jul 2015 09:25:40 AEST 1390535634 abrt-2.1.11-35.el7.x86_64 Wed 09 Nov 2016 14:52:01 AEDT 1446193355 ... kernel-3.10.0-267.el7.x86_64 Sat 24 Oct 2015 09:56:17 AEDT 1434466402 kernel-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:53:25 AEDT 1476954923 kernel-headers-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:20:59 AEDT 1476954923 kernel-tools-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 15:09:42 AEDT 1476954923 kernel-tools-libs-3.10.0-327.36.3.el7.x86_64 Wed 09 Nov 2016 14:52:13 AEDT 1476954923 kexec-tools-2.0.7-38.el7_2.1.x86_64 Wed 09 Nov 2016 14:48:21 AEDT 1452845178 ... zlib-1.2.7-15.el7.x86_64 Wed 09 Nov 2016 14:21:19 AEDT 1431443476 zsh-5.0.2-14.el7_2.2.x86_64 Wed 09 Nov 2016 15:13:19 AEDT 1464185248
Examples
>>> type(rpms) <class 'insights.parsers.installed_rpms.InstalledRpms'> >>> 'kernel' in rpms True >>> rpms.corrupt False >>> rpms.get_max('kernel') 0:kernel-3.10.0-327.36.3.el7 >>> type(rpms.get_max('kernel')) <class 'insights.parsers.installed_rpms.InstalledRpm'> >>> rpms.get_min('kernel') 0:kernel-3.10.0-267.el7 >>> rpm = rpms.get_max('kernel') >>> rpm 0:kernel-3.10.0-327.36.3.el7 >>> type(rpm) <class 'insights.parsers.installed_rpms.InstalledRpm'> >>> rpm.package == 'kernel-3.10.0-327.36.3.el7' True >>> rpm.nvr == 'kernel-3.10.0-327.36.3.el7' True >>> rpm.source >>> rpm.name 'kernel' >>> rpm.version '3.10.0' >>> rpm.release '327.36.3.el7' >>> rpm.arch 'x86_64' >>> rpm.epoch '0' >>> from insights.parsers.installed_rpms import InstalledRpm >>> rpm2 = InstalledRpm.from_package('kernel-3.10.0-267.el7') >>> rpm == rpm2 False >>> rpm > rpm2 True >>> rpm < rpm2 False
-
corrupt
¶ True if RPM database is corrupted, else False.
Type: bool
-
errors
= None¶ List of input lines that indicate an error acquiring the data on the client.
Type: list
-
packages
= None¶ Dictionary of RPMs keyed by package name.
Note
The
packages
could be empty, e.g. when rpm database corrupt. When doing exclusion check, make sure thepackages
is NOT empty, e.g.:>>> if rpms.packages and "pkg_name" not in rpms.packages: >>> pass
Type: dict (InstalledRpm)
-
unparsed
= None¶ List of input lines that raised an exception during parsing.
Type: list
-
-
insights.parsers.installed_rpms.
KNOWN_ARCHITECTURES
= ['x86_64', 'i386', 'i486', 'i586', 'i686', 'src', 'ia64', 'ppc', 'ppc64', 's390', 's390x', 'amd64', '(none)', 'noarch', 'alpha', 'alphaev4', 'alphaev45', 'alphaev5', 'alphaev56', 'alphaev6', 'alphaev67', 'alphaev68', 'alphaev7', 'alphapca56', 'arm64', 'armv5tejl', 'armv5tel', 'armv6l', 'armv7hl', 'armv7hnl', 'armv7l', 'athlon', 'armhfp', 'geode', 'ia32e', 'nosrc', 'ppc64iseries', 'ppc64le', 'ppc64p7', 'ppc64pseries', 'sh3', 'sh4', 'sh4a', 'sparc', 'sparc64', 'sparc64v', 'sparcv8', 'sparcv9', 'sparcv9v', 'aarch64']¶ List of recognized architectures.
This list is taken from the PDC (Product Definition Center) available here https://pdc.fedoraproject.org/rest_api/v1/arches/.
Type: list
-
insights.parsers.installed_rpms.
Rpm
¶
-
class
insights.parsers.installed_rpms.
RpmList
[source]¶ Bases:
object
Mixin class providing
__contains__
,get_max
,get_min
,newest
, andoldest
implementations for components that handle rpms.-
get_max
(package_name)[source]¶ Returns the highest version of the installed package with the given name.
Parameters: package_name (str) -- Installed RPM package name such as ‘bash’ Returns: Installed RPM with highest version Return type: InstalledRpm
-
get_min
(package_name)[source]¶ Returns the lowest version of the installed package with the given name.
Parameters: package_name (str) -- Installed RPM package name such as ‘bash’. Returns: Installed RPM with lowest version Return type: InstalledRpm
-
is_hypervisor
¶ Warning
This method is deprecated, and will be removed from 3.3.0. Please use
insights.parsers.virt_what.VirtWhat
which uses the command virt-what to check the hypervisor type.bool: True if “.el[6|7]ev” exists in “vdsm”.release, else False.
-
newest
(package_name)¶ Returns the highest version of the installed package with the given name.
Parameters: package_name (str) -- Installed RPM package name such as ‘bash’ Returns: Installed RPM with highest version Return type: InstalledRpm
-
oldest
(package_name)¶ Returns the lowest version of the installed package with the given name.
Parameters: package_name (str) -- Installed RPM package name such as ‘bash’. Returns: Installed RPM with lowest version Return type: InstalledRpm
-