aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schuppert <mschuppert@redhat.com>2017-03-16 08:58:07 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-03-28 14:05:28 +0100
commit8532e9c47939b872df8cb78f09b49ac5a57b62fd (patch)
treeb22f71e5c82ae64ad010a16f2cb1f5db467a972a
parent3d23564348799dfee88466f7439662c9d1e1b698 (diff)
downloadsos-8532e9c47939b872df8cb78f09b49ac5a57b62fd.tar.gz
[gnocchi] add_cmd_output block to be run only when ENVs set
add_cmd_output now gets only called if the needed ENV variables are set to be able to connect to an OpenStack env. Resolves: #956. Signed-off-by: Martin Schuppert <mschuppe@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/gnocchi.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/sos/plugins/gnocchi.py b/sos/plugins/gnocchi.py
index a29164b8..a386e789 100644
--- a/sos/plugins/gnocchi.py
+++ b/sos/plugins/gnocchi.py
@@ -1,4 +1,5 @@
# Copyright (C) 2016 Red Hat, Inc., Sachin Patil <psachin@redhat.com>
+# Copyright (C) 2017 Red Hat, Inc., Martin Schuppert <mschuppert@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -43,20 +44,21 @@ class GnocchiPlugin(Plugin, RedHatPlugin):
self.add_copy_spec_limit("/var/log/gnocchi/*.log",
sizelimit=self.limit)
- for os_var in ['OS_USERNAME', 'OS_PASSWORD', 'OS_TENANT_NAME']:
- if os_var not in os.environ:
- self.soslog.warning("%s not found in environment variables"
- " which is required to run gnocchi"
- " commands" % (os_var))
-
- self.add_cmd_output([
- "gnocchi --version",
- "gnocchi status",
- "gnocchi capabilities list",
- "gnocchi archive-policy list",
- "gnocchi resource list",
- "gnocchi resource-type list"
- ])
+ vars = [p in os.environ for p in [
+ 'OS_USERNAME', 'OS_PASSWORD', 'OS_TENANT_NAME']]
+ if not all(vars):
+ 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([
+ "gnocchi --version",
+ "gnocchi status",
+ "gnocchi capabilities list",
+ "gnocchi archive-policy list",
+ "gnocchi resource list",
+ "gnocchi resource-type list"
+ ])
def postproc(self):
self.do_file_sub(