From f95f8a74a01bd4f81904578e542c5facdb5d8541 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 18 Sep 2014 21:32:26 +0100 Subject: [emc,navicl] move navicli collection into its own plugin. Related: #257. Signed-off-by: Bryn M. Reeves --- sos/plugins/emc.py | 78 ------------------------------------------ sos/plugins/navicli.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 78 deletions(-) create mode 100644 sos/plugins/navicli.py diff --git a/sos/plugins/emc.py b/sos/plugins/emc.py index 1c71b95f..5757c8f7 100644 --- a/sos/plugins/emc.py +++ b/sos/plugins/emc.py @@ -81,38 +81,6 @@ class Emc(Plugin, RedHatPlugin): "powermt dump" ]) - def get_navicli_config(self): - """ EMC Navisphere Host Agent NAVICLI specific information - files - """ - self.add_copy_specs([ - "/etc/Navisphere/agent.config", - "/etc/Navisphere/Navimon.cfg", - "/etc/Navisphere/Quietmode.cfg", - "/etc/Navisphere/messages/[a-z]*", - "/etc/Navisphere/log/[a-z]*" - ]) - - def get_navicli_SP_info(self, SP_address): - """ EMC Navisphere Host Agent NAVICLI specific - information - CLARiiON - commands - """ - self.add_cmd_outputs([ - "navicli -h %s getall" % SP_address, - "navicli -h %s getsptime -spa" % SP_address, - "navicli -h %s getsptime -spb" % SP_address, - "navicli -h %s getlog" % SP_address, - "navicli -h %s getdisk" % SP_address, - "navicli -h %s getcache" % SP_address, - "navicli -h %s getlun" % SP_address, - "navicli -h %s getlun -rg -type -default -owner -crus " - "-capacity" % SP_address, - "navicli -h %s lunmapinfo" % SP_address, - "navicli -h %s getcrus" % SP_address, - "navicli -h %s port -list -all" % SP_address, - "navicli -h %s storagegroup -list" % SP_address, - "navicli -h %s spportspeed -get" % SP_address - ]) - def check_enabled(self): self.packages = ["EMCpower"] self.files = ["/opt/Navisphere/bin", "/proc/emcp"] @@ -138,52 +106,6 @@ class Emc(Plugin, RedHatPlugin): print(" Gathering additional EMC PowerPath information...") self.get_pp_config() - # If Navisphere Host Agent is installed collect CLARiiON specific - # information - if os.path.isdir("/opt/Navisphere/bin"): - print("") - print("The EMC CLARiiON Navisphere Host Agent is installed.") - self.add_custom_text("EMC CLARiiON Navisphere Host Agent is " - "installed.
") - self.get_navicli_config() - print(" Gathering Navisphere NAVICLI Host Agent information...") - print(" Please enter a CLARiiON SP IP address. In order to " - "collect") - print(" information for both SPA and SPB as well as multiple") - print(" CLARiiON arrays (if desired) you will be prompted " - "multiple times.") - print(" To exit simply press [Enter]") - print("") - add_about_emc = "yes" - CLARiiON_IP_address_list = [] - CLARiiON_IP_loop = "stay_in" - while CLARiiON_IP_loop == "stay_in": - ans = input("CLARiiON SP IP Address or [Enter] to exit: ") - # Check to make sure the CLARiiON SP IP address provided is - # valid - p = Popen("navicli -h %s getsptime" % (ans,), - shell=True, stdout=PIPE, stderr=PIPE, - close_fds=True) - out, err = p.communicate() - if p.returncode == 0: - CLARiiON_IP_address_list.append(ans) - else: - if ans != "": - print("The IP address you entered, %s, is not to an " - "active CLARiiON SP." % ans) - if ans == "": - CLARiiON_IP_loop = "get_out" - # Sort and dedup the list of CLARiiON IP Addresses - CLARiiON_IP_address_list.sort() - for SP_address in CLARiiON_IP_address_list: - if CLARiiON_IP_address_list.count(SP_address) > 1: - CLARiiON_IP_address_list.remove(SP_address) - for SP_address in CLARiiON_IP_address_list: - if SP_address != "": - print(" Gathering NAVICLI information for %s..." % - SP_address) - self.get_navicli_SP_info(SP_address) - # Only provide About EMC if EMC products are installed if add_about_emc != "no": self.about_emc() diff --git a/sos/plugins/navicli.py b/sos/plugins/navicli.py new file mode 100644 index 00000000..22f595ba --- /dev/null +++ b/sos/plugins/navicli.py @@ -0,0 +1,92 @@ +# Copyright (C) 2008 EMC Corporation. Keith Kearnan +# Copyright (C) 2014 Red Hat, Inc., Bryn M. Reeves + +# 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 +# the Free Software Foundation; either version 2 of the License, or + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +from sos.plugins import Plugin, RedHatPlugin, os +from sos.utilities import is_executable + + +# Just for completeness sake. +from six.moves import input + + +class Navicli(Plugin, RedHatPlugin): + """ EMC Navicli + """ + + plugin_name = 'navicli' + profiles = ('storage', 'hardware') + + def check_enabled(self): + return is_executable("navicli") + + def get_navicli_config(self): + """ EMC Navisphere Host Agent NAVICLI specific information - files + """ + self.add_copy_specs([ + "/etc/Navisphere/agent.config", + "/etc/Navisphere/Navimon.cfg", + "/etc/Navisphere/Quietmode.cfg", + "/etc/Navisphere/messages/[a-z]*", + "/etc/Navisphere/log/[a-z]*" + ]) + + def get_navicli_SP_info(self, SP_address): + """ EMC Navisphere Host Agent NAVICLI specific + information - CLARiiON - commands + """ + self.add_cmd_outputs([ + "navicli -h %s getall" % SP_address, + "navicli -h %s getsptime -spa" % SP_address, + "navicli -h %s getsptime -spb" % SP_address, + "navicli -h %s getlog" % SP_address, + "navicli -h %s getdisk" % SP_address, + "navicli -h %s getcache" % SP_address, + "navicli -h %s getlun" % SP_address, + "navicli -h %s getlun -rg -type -default -owner -crus " + "-capacity" % SP_address, + "navicli -h %s lunmapinfo" % SP_address, + "navicli -h %s getcrus" % SP_address, + "navicli -h %s port -list -all" % SP_address, + "navicli -h %s storagegroup -list" % SP_address, + "navicli -h %s spportspeed -get" % SP_address + ]) + + def setup(self): + self.get_navicli_config() + CLARiiON_IP_address_list = [] + CLARiiON_IP_loop = "stay_in" + while CLARiiON_IP_loop == "stay_in": + ans = input("CLARiiON SP IP Address or [Enter] to exit: ") + if self.check_ext_prog("navicli -h %s getsptime" % (ans,)): + CLARiiON_IP_address_list.append(ans) + else: + if ans != "": + print("The IP address you entered, %s, is not to an " + "active CLARiiON SP." % ans) + if ans == "": + CLARiiON_IP_loop = "get_out" + # Sort and dedup the list of CLARiiON IP Addresses + CLARiiON_IP_address_list.sort() + for SP_address in CLARiiON_IP_address_list: + if CLARiiON_IP_address_list.count(SP_address) > 1: + CLARiiON_IP_address_list.remove(SP_address) + for SP_address in CLARiiON_IP_address_list: + if SP_address != "": + print(" Gathering NAVICLI information for %s..." % + SP_address) + self.get_navicli_SP_info(SP_address) + +# vim: et ts=4 sw=4 -- cgit