aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2017-10-12 14:22:55 +0200
committerBryn M. Reeves <bmr@redhat.com>2017-10-31 15:44:17 +0000
commit4d1e5ffd2e6e4e9b4d4509af212c11a9ead58740 (patch)
treef80ac89b6d5dd060fe3e26342bbd2cfca6d4cce8
parent62d6435198403abb65b925e7bf63fc39f5394e6d (diff)
downloadsos-4d1e5ffd2e6e4e9b4d4509af212c11a9ead58740.tar.gz
[openstack_[glance|heat]] run commands only if service is running
Collect "glance-manage db_version" and similar commands from the two plugins only if the relevant services are running. Otherwise the commands get stuck and timeout. Resolves: #1124 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/openstack_glance.py29
-rw-r--r--sos/plugins/openstack_heat.py40
2 files changed, 40 insertions, 29 deletions
diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py
index 0a2bdc1b..642b4593 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -31,12 +31,6 @@ class OpenStackGlance(Plugin):
var_puppet_gen = "/var/lib/config-data/puppet-generated/glance_api"
def setup(self):
- # Glance
- self.add_cmd_output(
- "glance-manage db_version",
- suggest_filename="glance_db_version"
- )
-
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
self.add_copy_spec([
@@ -64,12 +58,23 @@ class OpenStackGlance(Plugin):
vars_any = [p in os.environ for p in [
'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
- if not (all(vars_all) and any(vars_any)):
- self.soslog.warning("Not all environment variables set. Source "
- "the environment file for the user intended "
- "to connect to the OpenStack environment.")
- else:
- self.add_cmd_output("openstack image list --long")
+ # collect commands output only if the openstack-glance-api service
+ # is running
+ service_status = self.get_command_output(
+ "systemctl status openstack-glance-api.service"
+ )
+ if service_status['status'] == 0:
+ self.add_cmd_output(
+ "glance-manage db_version",
+ suggest_filename="glance_db_version"
+ )
+ if not (all(vars_all) and any(vars_any)):
+ self.soslog.warning("Not all environment variables set. "
+ "Source the environment file for the user "
+ "intended to connect to the OpenStack "
+ "environment.")
+ else:
+ self.add_cmd_output("openstack image list --long")
def postproc(self):
protect_keys = [
diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py
index a73916b2..66a7f410 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -29,24 +29,30 @@ class OpenStackHeat(Plugin):
var_puppet_gen = "/var/lib/config-data/puppet-generated/heat"
def setup(self):
- # Heat
- self.add_cmd_output(
- "heat-manage db_version",
- suggest_filename="heat_db_version"
- )
-
- vars_all = [p in os.environ for p in [
- 'OS_USERNAME', 'OS_PASSWORD']]
- vars_any = [p in os.environ for p in [
- 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
-
- if not (all(vars_all) and any(vars_any)):
- self.soslog.warning("Not all environment variables set. Source "
- "the environment file for the user intended "
- "to connect to the OpenStack environment.")
- else:
- self.add_cmd_output("openstack stack list")
+ # collect commands output only if the openstack-heat-api service
+ # is running
+ service_status = self.get_command_output("systemctl status "
+ "openstack-heat-api.service")
+ if service_status['status'] == 0:
+ self.add_cmd_output(
+ "heat-manage db_version",
+ suggest_filename="heat_db_version"
+ )
+
+ vars_all = [p in os.environ for p in [
+ 'OS_USERNAME', 'OS_PASSWORD']]
+
+ vars_any = [p in os.environ for p in [
+ 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
+
+ if not (all(vars_all) and any(vars_any)):
+ self.soslog.warning("Not all environment variables set. "
+ "Source the environment file for the user "
+ "intended to connect to the OpenStack "
+ "environment.")
+ else:
+ self.add_cmd_output("openstack stack list")
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):