aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2019-11-21 15:34:49 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-04-07 16:43:35 -0400
commitf6e87578edbfa5251d9369e95dc9efc1a2306178 (patch)
treee71d49da662e92fbdbad67bfdfda999a9d456187
parent5cd6d894d5de22308a689ccc2fc44ebe6e181697 (diff)
downloadsos-f6e87578edbfa5251d9369e95dc9efc1a2306178.tar.gz
[Openstack] Update plugins to use ContainerRuntime methods
Removes the duplicated container runtime checks from individual plugins, and updates them to use the new methods exposed in `Plugin`, thus reducing the number of times sos calls out to the runtime. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/plugins/openstack_cinder.py11
-rw-r--r--sos/plugins/openstack_glance.py11
-rw-r--r--sos/plugins/openstack_heat.py11
-rw-r--r--sos/plugins/openstack_manila.py12
-rw-r--r--sos/plugins/openstack_nova.py11
-rw-r--r--sos/plugins/openstack_placement.py11
6 files changed, 7 insertions, 60 deletions
diff --git a/sos/plugins/openstack_cinder.py b/sos/plugins/openstack_cinder.py
index 0a941f2e..ebb4eb8f 100644
--- a/sos/plugins/openstack_cinder.py
+++ b/sos/plugins/openstack_cinder.py
@@ -37,7 +37,7 @@ class OpenStackCinder(Plugin):
if in_ps:
break
- in_container = self.running_in_container()
+ in_container = self.container_exists('.*cinder_api')
if in_container:
cinder_config = cinder_config_opt % self.var_puppet_gen
@@ -69,15 +69,6 @@ class OpenStackCinder(Plugin):
"/var/log/httpd/cinder*.log",
])
- def running_in_container(self):
- for runtime in ["docker", "podman"]:
- container_status = self.exec_cmd(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 84f0a952..30c2cfdc 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -42,7 +42,7 @@ class OpenStackGlance(Plugin):
# collect commands output only if the openstack-glance-api service
# is running
- in_container = self.running_in_container()
+ in_container = self.container_exists('glance_api')
if self.is_service_running('openstack-glance-api') or in_container:
glance_config = ""
@@ -70,15 +70,6 @@ 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.exec_cmd(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 091510c8..a00ebebc 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -26,7 +26,7 @@ class OpenStackHeat(Plugin):
# collect commands output only if the openstack-heat-api service
# is running
- in_container = self.running_in_container()
+ in_container = self.container_exists('.*heat_api')
if self.is_service_running('openstack-heat-api') or in_container:
heat_config = ""
@@ -79,15 +79,6 @@ class OpenStackHeat(Plugin):
self.var_puppet_gen + "_api_cfn/var/spool/cron/heat",
])
- def running_in_container(self):
- for runtime in ["docker", "podman"]:
- container_status = self.exec_cmd(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_manila.py b/sos/plugins/openstack_manila.py
index 9e4ca9e3..dcd49d2f 100644
--- a/sos/plugins/openstack_manila.py
+++ b/sos/plugins/openstack_manila.py
@@ -23,7 +23,8 @@ class OpenStackManila(Plugin):
def setup(self):
config_dir = "%s/etc/manila" % (
- self.var_puppet_gen if self.running_in_container() else ''
+ self.var_puppet_gen if self.container_exists('.*manila_api') else
+ ''
)
manila_cmd = "manila-manage --config-dir %s db version" % config_dir
self.add_cmd_output(manila_cmd, suggest_filename="manila_db_version")
@@ -46,15 +47,6 @@ class OpenStackManila(Plugin):
"/var/log/manila/*.log",
])
- def running_in_container(self):
- for runtime in ["docker", "podman"]:
- container_status = self.exec_cmd(runtime + " ps")
- if container_status['status'] == 0:
- for line in container_status['output'].splitlines():
- if line.endswith("manila_api"):
- return True
- return False
-
def apply_regex_sub(self, regexp, subst):
self.do_path_regex_sub("/etc/manila/*", regexp, subst)
self.do_path_regex_sub(
diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py
index 2de53b41..b1ea8b5d 100644
--- a/sos/plugins/openstack_nova.py
+++ b/sos/plugins/openstack_nova.py
@@ -29,7 +29,7 @@ class OpenStackNova(Plugin):
# collect commands output only if the openstack-nova-api service
# is running
- in_container = self.running_in_container()
+ in_container = self.container_exists('.*nova_api')
if self.is_service_running('openstack-nova-api') or in_container:
nova_config = ""
@@ -121,15 +121,6 @@ class OpenStackNova(Plugin):
self.var_puppet_gen + "_libvirt/var/lib/nova/.ssh/config",
])
- def running_in_container(self):
- for runtime in ["docker", "podman"]:
- container_status = self.exec_cmd(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(
diff --git a/sos/plugins/openstack_placement.py b/sos/plugins/openstack_placement.py
index a82d82b8..a0293a7d 100644
--- a/sos/plugins/openstack_placement.py
+++ b/sos/plugins/openstack_placement.py
@@ -24,7 +24,7 @@ class OpenStackPlacement(Plugin):
# collect commands output only if the openstack-placement-api service
# is running
- in_container = self.running_in_container()
+ in_container = self.container_exists('.*placement_api')
if self.is_service_running('openstack-placement-api') or in_container:
placement_config = ""
@@ -59,15 +59,6 @@ class OpenStackPlacement(Plugin):
self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
])
- def running_in_container(self):
- for runtime in ["docker", "podman"]:
- container_status = self.exec_cmd(runtime + " ps")
- if container_status['status'] == 0:
- for line in container_status['output'].splitlines():
- if line.endswith("placement_api"):
- return True
- return False
-
def apply_regex_sub(self, regexp, subst):
self.do_path_regex_sub("/etc/placement/*", regexp, subst)
self.do_path_regex_sub(