YumListInstalled - Command yum list installed

The YumListInstalled class parses the output of the yum list installed command. Each line is parsed and stored in a YumInstalledRpm object.

Sample input data:

Loaded plugins: product-id, search-disabled-repos, subscription-manager
Installed Packages
GConf2.x86_64                    3.2.6-8.el7             @rhel-7-server-rpms
GeoIP.x86_64                     1.5.0-11.el7            @anaconda/7.3
ImageMagick.x86_64               6.7.8.9-15.el7_2        @rhel-7-server-rpms
NetworkManager.x86_64            1:1.4.0-17.el7_3        installed
NetworkManager.x86_64            1:1.8.0-9.el7           installed
NetworkManager-config-server.noarch
                                 1:1.8.0-9.el7           installed
Uploading Enabled Repositories Report
Loaded plugins: priorities, product-id, rhnplugin, rhui-lb, subscription-
              : manager, versionlock

Examples

>>> type(rpms)
<class 'insights.parsers.yum_list_installed.YumListInstalled'>
>>> 'GeoIP' in rpms
True
>>> rpms.get_max('GeoIP')
0:GeoIP-1.5.0-11.el7
>>> rpms.expired_cache
True
>>> type(rpms.get_max('GeoIP'))
<class 'insights.parsers.yum_list_installed.YumInstalledRpm'>
>>> rpm = rpms.get_max('GeoIP')
>>> rpm.package
'GeoIP-1.5.0-11.el7'
>>> rpm.nvr
'GeoIP-1.5.0-11.el7'
>>> rpm.source
>>> rpm.name
'GeoIP'
>>> rpm.version
'1.5.0'
>>> rpm.release
'11.el7'
>>> rpm.arch
'x86_64'
>>> rpm.epoch
'0'
>>> from insights.parsers.yum_list_installed import YumInstalledRpm
>>> rpm2 = YumInstalledRpm.from_package('GeoIP-1.6.0-11.el7.x86_64')
>>> rpm == rpm2
False
>>> rpm > rpm2
False
>>> rpm < rpm2
True
class insights.parsers.yum_list_installed.YumInstalledRpm(data)[source]

Bases: insights.parsers.installed_rpms.InstalledRpm

The same as insights.parsers.installed_rpms.InstalledRpm but with an additional .repo attribute.

repo = None

yum / dnf repository name, if available.

Type

str

class insights.parsers.yum_list_installed.YumListInstalled(context)[source]

Bases: insights.core.CommandParser, insights.parsers.installed_rpms.RpmList

YumListInstalled shares the insights.parsers.installed_rpms.RpmList interface with insights.parsers.installed_rpms.InstalledRpms. The only difference is YumListInstalled takes the output of yum list installed as its source data, and the YumInstalledRpm instances it produces contain a .repo attribute.

expired_cache = None

Indicates if the yum repo cache is expired.

Type

bool

parse_content(content)[source]

yum list installed output is basically tabular with an ignorable set of rows at the top and a line “Installed Packages” that designates the following rows as data. Each column has a maximum width, and if any column overflows, the following columns wrap to the next line and indent to their usual starting positions. It’s also possible for the data rows to be followed by more lines that should be ignored. Since yum list installed is for human consumption, the footer lines can be syntactically ambiguous with data lines. We use heuristics to check for an invalid row to signal the end of data.