Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
TurboTurtle committed Nov 3, 2020
1 parent 55ca9a8 commit e6c6549
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions sos/report/plugins/saphana.py
Expand Up @@ -13,11 +13,9 @@
class saphana(Plugin, RedHatPlugin):

short_desc = 'SAP HANA'

plugin_name = 'saphana'
profiles = ['sap']

files = ['/hana']
profiles = ('sap',)
files = ('/hana',)

def setup(self):

Expand All @@ -32,7 +30,6 @@ def setup(self):

for sid in sids:
sidadm = '%sadm' % sid.lower()

prefix = 'su - %s -c' % sidadm

self.add_cmd_output('%s "HDB info"' % prefix,
Expand All @@ -49,31 +46,26 @@ def setup(self):
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

0 comments on commit e6c6549

Please sign in to comment.