Blame SOURCES/sos-bz1457191-navicli-noniteractively.patch

a02485
From ca24d4602ce46312343f1f6c6f4b270fb6092e21 Mon Sep 17 00:00:00 2001
a02485
From: Pavel Moravec <pmoravec@redhat.com>
a02485
Date: Wed, 15 Apr 2020 17:09:52 +0200
a02485
Subject: [PATCH] [navicli] replace interactive prompt by plugin option
a02485
a02485
List of ClariiOn IP addresses should be provided via
a02485
-k navicli.ipaddrs plugopt, as a space separated list.
a02485
a02485
Closes: #405
a02485
Resolves: #2020
a02485
a02485
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
a02485
Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
a02485
---
a02485
 sos/plugins/navicli.py | 30 +++++-------------------------
a02485
 1 file changed, 5 insertions(+), 25 deletions(-)
a02485
a02485
diff --git a/sos/plugins/navicli.py b/sos/plugins/navicli.py
a02485
index 8e5dee50..5b6d766d 100644
a02485
--- a/sos/plugins/navicli.py
a02485
+++ b/sos/plugins/navicli.py
a02485
@@ -19,6 +19,8 @@ class Navicli(Plugin, RedHatPlugin):
a02485
 
a02485
     plugin_name = 'navicli'
a02485
     profiles = ('storage', 'hardware')
a02485
+    option_list = [("ipaddrs", "list of space separated CLARiiON IP addresses",
a02485
+                    '', "")]
a02485
 
a02485
     def check_enabled(self):
a02485
         return is_executable("navicli")
a02485
@@ -57,30 +59,8 @@ class Navicli(Plugin, RedHatPlugin):
a02485
 
a02485
     def setup(self):
a02485
         self.get_navicli_config()
a02485
-        CLARiiON_IP_address_list = []
a02485
-        CLARiiON_IP_loop = "stay_in"
a02485
-        while CLARiiON_IP_loop == "stay_in":
a02485
-            try:
a02485
-                ans = input("CLARiiON SP IP Address or [Enter] to exit: ")
a02485
-            except Exception:
a02485
-                return
a02485
-            if self.exec_cmd("navicli -h %s getsptime" % (ans,))['status']:
a02485
-                CLARiiON_IP_address_list.append(ans)
a02485
-            else:
a02485
-                if ans != "":
a02485
-                    print("The IP address you entered, %s, is not to an "
a02485
-                          "active CLARiiON SP." % ans)
a02485
-                if ans == "":
a02485
-                    CLARiiON_IP_loop = "get_out"
a02485
-        # Sort and dedup the list of CLARiiON IP Addresses
a02485
-        CLARiiON_IP_address_list.sort()
a02485
-        for SP_address in CLARiiON_IP_address_list:
a02485
-            if CLARiiON_IP_address_list.count(SP_address) > 1:
a02485
-                CLARiiON_IP_address_list.remove(SP_address)
a02485
-        for SP_address in CLARiiON_IP_address_list:
a02485
-            if SP_address != "":
a02485
-                print(" Gathering NAVICLI information for %s..." %
a02485
-                      SP_address)
a02485
-                self.get_navicli_SP_info(SP_address)
a02485
+        for ip in set(self.get_option("ipaddrs").split()):
a02485
+            if self.exec_cmd("navicli -h %s getsptime" % (ip))['status'] == 0:
a02485
+                self.get_navicli_SP_info(ip)
a02485
 
a02485
 # vim: set et ts=4 sw=4 :
a02485
-- 
a02485
2.21.3
a02485