aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-02-20 14:31:54 +0000
committerBryn M. Reeves <bmr@redhat.com>2018-02-20 14:31:54 +0000
commit6e69e104e51ed51f5bf44f5379ac225043d41238 (patch)
tree8b2a3b45d3e0cef986037e0bddf918a8dd1e2e94
parentb9ace2788c2f9c327ac519fa007bc08470f4fd2b (diff)
downloadsos-6e69e104e51ed51f5bf44f5379ac225043d41238.tar.gz
[policy] add optional 'release' value for packages
An a new optional field to the data gathered for installed packages to include the 'release' string provided by the platform package manager, and implement a change to the redhat policy family to add this to the RPM query command for those distributions. Policies wishing to implement this just need to ensure that there is an additional '|' separated field in the data returned by the specified query command. If the additional field is present it is assumed to contain a release value and is stored in the package dictionary for the 'release' key. For policies that do not define the additional field in query commands the 'release' key will always be set to None. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py8
-rw-r--r--sos/policies/redhat.py2
2 files changed, 8 insertions, 2 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index dc043105..559e4fbe 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -110,11 +110,17 @@ class PackageManager(object):
for pkg in pkg_list:
if '|' not in pkg:
continue
- name, version = pkg.split("|")
+ elif pkg.count("|") == 1:
+ name, version = pkg.split("|")
+ release = None
+ elif pkg.count("|") == 2:
+ name, version, release = pkg.split("|")
self.packages[name] = {
'name': name,
'version': version.split(".")
}
+ release = release if release else None
+ self.packages[name]['release'] = release
return self.packages
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index 2dfe0589..df0b2f33 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -39,7 +39,7 @@ class RedHatPolicy(LinuxPolicy):
vendor_url = "http://www.redhat.com/"
_redhat_release = '/etc/redhat-release'
_tmp_dir = "/var/tmp"
- _rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"'
+ _rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\\n"'
_rpmv_cmd = 'rpm -V'
_rpmv_filter = ["debuginfo", "-devel"]
_in_container = False