From 2b29530eb50ab1016937f5c28adaf4e2288e46be Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 29 Aug 2018 08:10:41 -0400 Subject: [plugins] Add Support for podman as well as docker. OpenStack daemons can now run in OCI containers launched by both podman and docker. Need to check both locations. Resolves: #1408 Signed-off-by: Daniel J Walsh Signed-off-by: Bryn M. Reeves --- sos/plugins/openstack_cinder.py | 25 ++++++++++++++----------- sos/plugins/openstack_glance.py | 16 ++++++++++------ sos/plugins/openstack_heat.py | 16 ++++++++++------ sos/plugins/openstack_nova.py | 15 ++++++++++----- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/sos/plugins/openstack_cinder.py b/sos/plugins/openstack_cinder.py index d90cde9b..f097fd5b 100644 --- a/sos/plugins/openstack_cinder.py +++ b/sos/plugins/openstack_cinder.py @@ -24,6 +24,8 @@ class OpenStackCinder(Plugin): var_puppet_gen = "/var/lib/config-data/puppet-generated/cinder" def setup(self): + cinder_config = "" + cinder_config_opt = "--config-dir %s/etc/cinder/" # check if either standalone (cinder-api) or httpd wsgi (cinder_wsgi) # is up and running @@ -34,17 +36,9 @@ class OpenStackCinder(Plugin): if in_ps: break - container_status = self.get_command_output("docker ps") - in_container = False - cinder_config = "" - if container_status['status'] == 0: - for line in container_status['output'].splitlines(): - if line.endswith("cinder_api"): - in_container = True - # if containerized we need to pass the config to the cont. - cinder_config = "--config-dir " + self.var_puppet_gen + \ - "/etc/cinder/" - break + in_container = self.running_in_container() + if in_container: + cinder_config = cinder_config_opt % self.var_puppet_gen # collect commands output if the standalone, wsgi or container is up if in_ps or in_container: @@ -81,6 +75,15 @@ class OpenStackCinder(Plugin): if self.get_option("verify"): self.add_cmd_output("rpm -V %s" % ' '.join(self.packages)) + def running_in_container(self): + for runtime in ["docker", "podman"]: + container_status = self.get_command_output(runtime + " ps") + if container_status['status'] == 0: + for line in container_status['output'].splitlines(): + if line.endswith("cinder_api"): + return True + return False + def apply_regex_sub(self, regexp, subst): self.do_path_regex_sub("/etc/cinder/*", regexp, subst) self.do_path_regex_sub( diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py index 5fcbbfd9..fa68dd8e 100644 --- a/sos/plugins/openstack_glance.py +++ b/sos/plugins/openstack_glance.py @@ -53,12 +53,7 @@ class OpenStackGlance(Plugin): "systemctl status openstack-glance-api.service" ) - container_status = self.get_command_output("docker ps") - in_container = False - if container_status['status'] == 0: - for line in container_status['output'].splitlines(): - if line.endswith("glance_api"): - in_container = True + in_container = self.running_in_container() if (service_status['status'] == 0) or in_container: glance_config = "" @@ -86,6 +81,15 @@ class OpenStackGlance(Plugin): else: self.add_cmd_output("openstack image list --long") + def running_in_container(self): + for runtime in ["docker", "podman"]: + container_status = self.get_command_output(runtime + " ps") + if container_status['status'] == 0: + for line in container_status['output'].splitlines(): + if line.endswith("glance_api"): + return True + return false + def apply_regex_sub(self, regexp, subst): self.do_path_regex_sub("/etc/glance/*", regexp, subst) self.do_path_regex_sub( diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py index c0e74202..26f3f511 100644 --- a/sos/plugins/openstack_heat.py +++ b/sos/plugins/openstack_heat.py @@ -30,12 +30,7 @@ class OpenStackHeat(Plugin): "systemctl status openstack-heat-api.service" ) - container_status = self.get_command_output("docker ps") - in_container = False - if container_status['status'] == 0: - for line in container_status['output'].splitlines(): - if line.endswith("heat_api"): - in_container = True + in_container = self.running_in_container() if (service_status['status'] == 0) or in_container: heat_config = "" @@ -97,6 +92,15 @@ class OpenStackHeat(Plugin): if self.get_option("verify"): self.add_cmd_output("rpm -V %s" % ' '.join(self.packages)) + def running_in_container(self): + for runtime in ["docker", "podman"]: + container_status = self.get_command_output(runtime + " ps") + if container_status['status'] == 0: + for line in container_status['output'].splitlines(): + if line.endswith("heat_api"): + return True + return False + def apply_regex_sub(self, regexp, subst): self.do_path_regex_sub( "/etc/heat/*", diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py index 91f0869c..d8ca0e2e 100644 --- a/sos/plugins/openstack_nova.py +++ b/sos/plugins/openstack_nova.py @@ -34,11 +34,7 @@ class OpenStackNova(Plugin): ) container_status = self.get_command_output("docker ps") - in_container = False - if container_status['status'] == 0: - for line in container_status['output'].splitlines(): - if line.endswith("nova_api"): - in_container = True + in_container = self.running_in_container() if (service_status['status'] == 0) or in_container: nova_config = "" @@ -131,6 +127,15 @@ class OpenStackNova(Plugin): if self.get_option("verify"): self.add_cmd_output("rpm -V %s" % ' '.join(self.packages)) + def running_in_container(self): + for runtime in ["docker", "podman"]: + container_status = self.get_command_output(runtime + " ps") + if container_status['status'] == 0: + for line in container_status['output'].splitlines(): + if line.endswith("nova_api"): + return True + return False + def apply_regex_sub(self, regexp, subst): self.do_path_regex_sub("/etc/nova/*", regexp, subst) self.do_path_regex_sub( -- cgit