Blame SOURCES/sos-bz1195608-sapnw-cmd-output-check.patch

c81b6a
From 24fb011755e655127b7e09f4c02275539666b4b2 Mon Sep 17 00:00:00 2001
c81b6a
From: Pavel Moravec <pmoravec@redhat.com>
c81b6a
Date: Wed, 29 Jul 2015 14:47:19 +0200
c81b6a
Subject: [PATCH] [sapnw] uses a deprecated Sets module
c81b6a
c81b6a
Use built-in set class instead of deprecated Set for sidsunique
c81b6a
c81b6a
Resolves: #608
c81b6a
c81b6a
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
c81b6a
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
c81b6a
---
c81b6a
 sos/plugins/sapnw.py | 3 +--
c81b6a
 1 file changed, 1 insertion(+), 2 deletions(-)
c81b6a
c81b6a
diff --git a/sos/plugins/sapnw.py b/sos/plugins/sapnw.py
c81b6a
index e18978f..59beff2 100644
c81b6a
--- a/sos/plugins/sapnw.py
c81b6a
+++ b/sos/plugins/sapnw.py
c81b6a
@@ -13,7 +13,6 @@
c81b6a
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c81b6a
 
c81b6a
 import os
c81b6a
-from sets import Set
c81b6a
 from sos.plugins import Plugin, RedHatPlugin
c81b6a
 
c81b6a
 
c81b6a
@@ -44,7 +43,7 @@ class sapnw(Plugin, RedHatPlugin):
c81b6a
                                          -function ListDatabases",
c81b6a
                                          suggest_filename="SAPDatabases")
c81b6a
 
c81b6a
-        sidsunique = Set([])
c81b6a
+        sidsunique = set()
c81b6a
 
c81b6a
         # Cycle through all the instances, get 'sid' 'instance_number'
c81b6a
         # and 'vhost' to determine the proper profile
c81b6a
-- 
c81b6a
1.8.3.1
c81b6a
c81b6a
From 10059897ceb0755bab844011f11ea6c6af8794ae Mon Sep 17 00:00:00 2001
c81b6a
From: Pavel Moravec <pmoravec@redhat.com>
c81b6a
Date: Tue, 28 Jul 2015 13:50:54 +0200
c81b6a
Subject: [PATCH] [sapnw] Add check if saphostctrl is not present
c81b6a
c81b6a
Split listing&collecting instances and dbs from lengthy setup().
c81b6a
c81b6a
Break execution when "inst_out = self.get_cmd_output_now" returns None.
c81b6a
c81b6a
db_out is already checked this way.
c81b6a
c81b6a
Resolves: #614
c81b6a
c81b6a
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
c81b6a
---
c81b6a
 sos/plugins/sapnw.py | 30 +++++++++++++++++-------------
c81b6a
 1 file changed, 17 insertions(+), 13 deletions(-)
c81b6a
c81b6a
diff --git a/sos/plugins/sapnw.py b/sos/plugins/sapnw.py
c81b6a
index 59beff2..d2c93ec 100644
c81b6a
--- a/sos/plugins/sapnw.py
c81b6a
+++ b/sos/plugins/sapnw.py
c81b6a
@@ -32,20 +32,16 @@ class sapnw(Plugin, RedHatPlugin):
c81b6a
 
c81b6a
     files = ['/usr/sap']
c81b6a
 
c81b6a
-    def setup(self):
c81b6a
-
c81b6a
+    def collect_list_instances(self):
c81b6a
         # list installed instances
c81b6a
         inst_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
c81b6a
                                            -function ListInstances",
c81b6a
                                            suggest_filename="SAPInstances")
c81b6a
-        # list installed sap dbs
c81b6a
-        db_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
c81b6a
-                                         -function ListDatabases",
c81b6a
-                                         suggest_filename="SAPDatabases")
c81b6a
+        if not inst_out:
c81b6a
+            return
c81b6a
 
c81b6a
         sidsunique = set()
c81b6a
-
c81b6a
-        # Cycle through all the instances, get 'sid' 'instance_number'
c81b6a
+        # Cycle through all the instances, get 'sid', 'instance_number'
c81b6a
         # and 'vhost' to determine the proper profile
c81b6a
         p = open(inst_out, "r").read().splitlines()
c81b6a
         for line in p:
c81b6a
@@ -101,10 +97,15 @@ class sapnw(Plugin, RedHatPlugin):
c81b6a
                         % (sid, line), suggest_filename="%s_dbclient"
c81b6a
                         % sid)
c81b6a
 
c81b6a
+    def collect_list_dbs(self):
c81b6a
+        # list installed sap dbs
c81b6a
+        db_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
c81b6a
+                                         -function ListDatabases",
c81b6a
+                                         suggest_filename="SAPDatabases")
c81b6a
         if not db_out:
c81b6a
             return
c81b6a
-        dbl = open(db_out, "r").read().splitlines()
c81b6a
 
c81b6a
+        dbl = open(db_out, "r").read().splitlines()
c81b6a
         for line in dbl:
c81b6a
             if "Instance name" in line:
c81b6a
                 fields = line.strip().split()
c81b6a
@@ -135,9 +136,12 @@ class sapnw(Plugin, RedHatPlugin):
c81b6a
                     sid = fields[2][:-1]
c81b6a
                     self.add_copy_spec("/sybase/%s/ASE*/%s.cfg" % (sid, sid))
c81b6a
 
c81b6a
-        # if sapconf available run it in check mode
c81b6a
-        if os.path.isfile("/usr/bin/sapconf"):
c81b6a
-            self.add_cmd_output(
c81b6a
-                "/usr/bin/sapconf -n", suggest_filename="sapconf_checkmode")
c81b6a
+    def setup(self):
c81b6a
+        collect_list_instances()
c81b6a
+        collect_list_dbs()
c81b6a
+
c81b6a
+        # run sapconf in check mode
c81b6a
+        self.add_cmd_output("sapconf -n",
c81b6a
+                            suggest_filename="sapconf_checkmode")
c81b6a
 
c81b6a
 # vim: et ts=4 sw=4
c81b6a
-- 
c81b6a
1.8.3.1
c81b6a
c81b6a
From 1f83971325629cb3f470dac74de1be49f095118e Mon Sep 17 00:00:00 2001
c81b6a
From: Pavel Moravec <pmoravec@redhat.com>
c81b6a
Date: Tue, 4 Aug 2015 10:44:37 +0200
c81b6a
Subject: [PATCH] [sapnw] call self methods properly
c81b6a
c81b6a
Call methods from the self class within "self." scope.
c81b6a
c81b6a
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
c81b6a
---
c81b6a
 sos/plugins/sapnw.py | 4 ++--
c81b6a
 1 file changed, 2 insertions(+), 2 deletions(-)
c81b6a
c81b6a
diff --git a/sos/plugins/sapnw.py b/sos/plugins/sapnw.py
c81b6a
index d2c93ec..be8c4b9 100644
c81b6a
--- a/sos/plugins/sapnw.py
c81b6a
+++ b/sos/plugins/sapnw.py
c81b6a
@@ -137,8 +137,8 @@ class sapnw(Plugin, RedHatPlugin):
c81b6a
                     self.add_copy_spec("/sybase/%s/ASE*/%s.cfg" % (sid, sid))
c81b6a
 
c81b6a
     def setup(self):
c81b6a
-        collect_list_instances()
c81b6a
-        collect_list_dbs()
c81b6a
+        self.collect_list_instances()
c81b6a
+        self.collect_list_dbs()
c81b6a
 
c81b6a
         # run sapconf in check mode
c81b6a
         self.add_cmd_output("sapconf -n",
c81b6a
-- 
c81b6a
1.8.3.1
c81b6a