aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2015-07-28 13:50:54 +0200
committerBryn M. Reeves <bmr@redhat.com>2015-08-03 17:22:34 +0100
commit10059897ceb0755bab844011f11ea6c6af8794ae (patch)
tree2efdaf954051640c4623cfeaea3836093cafb2c6
parentb3faad3f82ee1f735e2221bb2f39b8b8aeaf0e86 (diff)
downloadsos-10059897ceb0755bab844011f11ea6c6af8794ae.tar.gz
[sapnw] Add check if saphostctrl is not present
Split listing&collecting instances and dbs from lengthy setup(). Break execution when "inst_out = self.get_cmd_output_now" returns None. db_out is already checked this way. Resolves: #614 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/sapnw.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/sos/plugins/sapnw.py b/sos/plugins/sapnw.py
index 59beff21..d2c93ec1 100644
--- a/sos/plugins/sapnw.py
+++ b/sos/plugins/sapnw.py
@@ -32,20 +32,16 @@ class sapnw(Plugin, RedHatPlugin):
files = ['/usr/sap']
- def setup(self):
-
+ def collect_list_instances(self):
# list installed instances
inst_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
-function ListInstances",
suggest_filename="SAPInstances")
- # list installed sap dbs
- db_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
- -function ListDatabases",
- suggest_filename="SAPDatabases")
+ if not inst_out:
+ return
sidsunique = set()
-
- # Cycle through all the instances, get 'sid' 'instance_number'
+ # Cycle through all the instances, get 'sid', 'instance_number'
# and 'vhost' to determine the proper profile
p = open(inst_out, "r").read().splitlines()
for line in p:
@@ -101,10 +97,15 @@ class sapnw(Plugin, RedHatPlugin):
% (sid, line), suggest_filename="%s_dbclient"
% sid)
+ def collect_list_dbs(self):
+ # list installed sap dbs
+ db_out = self.get_cmd_output_now("/usr/sap/hostctrl/exe/saphostctrl \
+ -function ListDatabases",
+ suggest_filename="SAPDatabases")
if not db_out:
return
- dbl = open(db_out, "r").read().splitlines()
+ dbl = open(db_out, "r").read().splitlines()
for line in dbl:
if "Instance name" in line:
fields = line.strip().split()
@@ -135,9 +136,12 @@ class sapnw(Plugin, RedHatPlugin):
sid = fields[2][:-1]
self.add_copy_spec("/sybase/%s/ASE*/%s.cfg" % (sid, sid))
- # if sapconf available run it in check mode
- if os.path.isfile("/usr/bin/sapconf"):
- self.add_cmd_output(
- "/usr/bin/sapconf -n", suggest_filename="sapconf_checkmode")
+ def setup(self):
+ collect_list_instances()
+ collect_list_dbs()
+
+ # run sapconf in check mode
+ self.add_cmd_output("sapconf -n",
+ suggest_filename="sapconf_checkmode")
# vim: et ts=4 sw=4