aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-11-01 11:57:07 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-11-03 13:41:58 -0500
commite6c65495c7d6efba9a12e44956443ce5aea013f2 (patch)
treea4902fd8c34d06a5e72f98168978963bd2cffcc4
parent55ca9a849121b9058f8e0768eb4d4bef84db49ab (diff)
downloadsos-e6c65495c7d6efba9a12e44956443ce5aea013f2.tar.gz
[saphana] Refactor collection loop for style guidelines
Updates the `saphana` plugin to be more readable and align with the standard sos plugin style guidelines. Related: #1071 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/saphana.py50
1 files changed, 21 insertions, 29 deletions
diff --git a/sos/report/plugins/saphana.py b/sos/report/plugins/saphana.py
index 60540dec..82c497b4 100644
--- a/sos/report/plugins/saphana.py
+++ b/sos/report/plugins/saphana.py
@@ -13,11 +13,9 @@ from sos.report.plugins import Plugin, RedHatPlugin
class saphana(Plugin, RedHatPlugin):
short_desc = 'SAP HANA'
-
plugin_name = 'saphana'
- profiles = ['sap']
-
- files = ['/hana']
+ profiles = ('sap',)
+ files = ('/hana',)
def setup(self):
@@ -32,7 +30,6 @@ class saphana(Plugin, RedHatPlugin):
for sid in sids:
sidadm = '%sadm' % sid.lower()
-
prefix = 'su - %s -c' % sidadm
self.add_cmd_output('%s "HDB info"' % prefix,
@@ -49,31 +46,26 @@ class saphana(Plugin, RedHatPlugin):
suggest_filename="%s_replicainfo" % sid)
if os.path.isdir("/hana/shared/%s/" % sid):
- i = os.listdir("/hana/shared/%s/" % sid)
- for inst in i:
+ for inst in os.listdir("/hana/shared/%s/" % sid):
if "HDB" in inst:
inst = inst.strip()[-2:]
-
- # get GREEN/RED status
- self.add_cmd_output(
- 'su - %s -c "sapcontrol -nr %s \
- -function GetProcessList"'
- % (sidadm, inst),
- suggest_filename="%s_%s_status"
- % (sid, inst)
- )
-
- path = '/usr/sap/%s/HDB%s/exe/python_support'
- path %= (sid, inst)
-
- if os.path.isdir("%s" % path):
- # SCALE OUT - slow
- self.add_cmd_output(
- 'su - %s -c "python \
- %s/landscapeHostConfiguration.py"'
- % (sidadm, path),
- suggest_filename="%s_%s_landscapeConfig"
- % (sid, inst)
- )
+ self.get_inst_info(sid, sidadm, inst)
+
+ def get_inst_info(self, prefix, sid, sidadm, inst):
+ proc_cmd = 'su - %s -c "sapcontrol -nr %s -function GetProcessList"'
+ status_fname = "%s_%s_status" % (sid, inst)
+ self.add_cmd_output(
+ proc_cmd % (sidadm, inst),
+ suggest_filename=status_fname
+ )
+
+ path = "/usr/sap/%s/HDB%s/exe/python_support" % (sid, inst)
+ if os.path.isdir(path):
+ py_cmd = 'su - %s -c "python %s/landscapeHostConfiguration.py"'
+ py_fname = "%s_%s_landscapeConfig" % (sid, inst)
+ self.add_cmd_output(
+ py_cmd % (sidadm, path),
+ suggest_filename=py_fname
+ )
# vim: et ts=4 sw=4