aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2019-12-17 12:44:07 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-04-07 16:43:35 -0400
commite4977719b7c35190b3c2099ad46f965265c8257b (patch)
tree66d0b51d14af3be93b6bdf6a52efcf434298ecff
parentb5b82007576f15f6c07f5bf2b8e10587b2fa1d20 (diff)
downloadsos-e4977719b7c35190b3c2099ad46f965265c8257b.tar.gz
[podman] Update plugin to utilize policy container runtime
Updates the plugin to use the new `ContainerRuntime` abstraction provided by the loaded `Policy` rather than shelling out again to get the same data loaded during `Policy` initialization. Resolves: #1873 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/plugins/podman.py27
1 files changed, 7 insertions, 20 deletions
diff --git a/sos/plugins/podman.py b/sos/plugins/podman.py
index c00a63ee..10e39b0c 100644
--- a/sos/plugins/podman.py
+++ b/sos/plugins/podman.py
@@ -74,24 +74,19 @@ class Podman(Plugin, RedHatPlugin, UbuntuPlugin):
"podman network inspect %s" % net for net in nets
], subdir='networks')
- ps_cmd = 'podman ps -q'
- if self.get_option('all'):
- ps_cmd = "%s -a" % ps_cmd
-
- fmt = '{{lower .Repository}}:{{lower .Tag}} {{lower .ID}}'
- img_cmd = "podman images --format='%s'" % fmt
- vol_cmd = 'podman volume ls -q'
-
- containers = self._get_podman_list(ps_cmd)
- images = self._get_podman_list(img_cmd)
- volumes = self._get_podman_list(vol_cmd)
+ containers = [
+ c[0] for c in self.get_containers(runtime='podman',
+ get_all=self.get_option('all'))
+ ]
+ images = self.get_container_images(runtime='podman')
+ volumes = self.get_container_volumes(runtime='podman')
for container in containers:
self.add_cmd_output("podman inspect %s" % container,
subdir='containers')
for img in images:
- name, img_id = img.strip().split()
+ name, img_id = img
insp = name if 'none' not in name else img_id
self.add_cmd_output("podman inspect %s" % insp, subdir='images')
@@ -104,14 +99,6 @@ class Podman(Plugin, RedHatPlugin, UbuntuPlugin):
self.add_cmd_output("podman logs -t %s" % con,
subdir='containers')
- def _get_podman_list(self, cmd):
- ret = []
- result = self.exec_cmd(cmd)
- if result['status'] == 0:
- for ent in result['output'].splitlines():
- ret.append(ent)
- return ret
-
def postproc(self):
# Attempts to match key=value pairs inside container inspect output
# for potentially sensitive items like env vars that contain passwords.