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

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