Yum List Command
The parsers contains in this module are:
YumListInstalled - Command yum list installed
YumListAvailable - Command yum list available
- class insights.parsers.yum_list.YumListAvailable(context)[source]
Bases:
YumListBaseThe
YumListAvailableclass parses the output of theyum list availablecommand. Each line is parsed and stored in aYumListRpmobject.Input and usage examples are identical to
YumListInstalledbut with “Installed” replaced with “Available” wherever applicable.
- class insights.parsers.yum_list.YumListBase(context, package_status)[source]
Bases:
CommandParser,RpmListBase class for the
yum list [installed|available]commands. Each line is parsed and stored in aYumListRpmobject.Note
YumListBaseshares theinsights.parsers.installed_rpms.RpmListinterface withinsights.parsers.installed_rpms.InstalledRpms. The only difference isYumListBasetakes the output ofyum listas its source data, and theYumListRpminstances it produces contain a.repoattribute.- expired_cache
Indicates if the yum repo cache is expired.
- Type:
bool
- package_status
Indicates if the list is of installed or available packages.
- Type:
str
- parse_content(content)[source]
yum listoutput 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. Sinceyum listis 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.
- class insights.parsers.yum_list.YumListInstalled(context)[source]
Bases:
YumListBaseThe
YumListInstalledclass parses the output of theyum list installedcommand. Each line is parsed and stored in aYumListRpmobject.Sample input data:
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast 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, versionlockExamples
>>> type(installed_rpms) <class 'insights.parsers.yum_list.YumListInstalled'> >>> 'GeoIP' in installed_rpms True >>> installed_rpms.get_max('GeoIP') 0:GeoIP-1.5.0-11.el7 >>> installed_rpms.expired_cache True >>> type(installed_rpms.get_max('GeoIP')) <class 'insights.parsers.yum_list.YumListRpm'> >>> rpm1 = installed_rpms.get_max('GeoIP') >>> rpm1.package == 'GeoIP-1.5.0-11.el7' True >>> rpm1.nvr == 'GeoIP-1.5.0-11.el7' True >>> rpm1.source >>> rpm1.name 'GeoIP' >>> rpm1.version '1.5.0' >>> rpm1.release '11.el7' >>> rpm1.arch 'x86_64' >>> rpm1.epoch '0' >>> from insights.parsers.yum_list import YumListRpm >>> rpm2 = YumListRpm.from_package('GeoIP-1.6.0-11.el7.x86_64') >>> rpm1 == rpm2 False >>> rpm1 > rpm2 False >>> rpm1 < rpm2 True
- class insights.parsers.yum_list.YumListRpm(data)[source]
Bases:
InstalledRpmThe same as
insights.parsers.installed_rpms.InstalledRpmbut with an additional.repoattribute.- repo
yum / dnf repository name, if available.
- Type:
str