which import the UcsSdk python module
Message-ID: <5aa94266.9lFJMSNMA5885nlU%ab(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: cb002ecdcc44533302d3c5844e1fb283aae5e2dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cb002ecdcc4453…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Mar 14 16:04:45 2018 +0100
5789 FIX agent_ucs_bladecenter: removed legacy debug feature, which import the UcsSdk
python module
Change-Id: I02fc21899ff6044af72e76e123c77ac1b08dea3d
---
.werks/5789 | 10 +++++++
agents/special/agent_ucs_bladecenter | 56 +++++++++---------------------------
2 files changed, 24 insertions(+), 42 deletions(-)
diff --git a/.werks/5789 b/.werks/5789
new file mode 100644
index 0000000..c8f9aea
--- /dev/null
+++ b/.werks/5789
@@ -0,0 +1,10 @@
+Title: agent_ucs_bladecenter: removed legacy debug feature, which import the UcsSdk
python module
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1521039829
+Class: fix
+
+
diff --git a/agents/special/agent_ucs_bladecenter b/agents/special/agent_ucs_bladecenter
index 872b69f..8459513 100755
--- a/agents/special/agent_ucs_bladecenter
+++ b/agents/special/agent_ucs_bladecenter
@@ -50,7 +50,7 @@ OPTIONS:
short_options = 'hu:p:'
long_options = [
- 'help', 'username=', 'password=', 'debug',
'ucssdk', 'no-cert-check'
+ 'help', 'username=', 'password=', 'debug',
'no-cert-check'
]
try:
@@ -63,16 +63,12 @@ opt_debug = False
opt_username = ""
opt_password = ""
opt_verify = True
-opt_ucssdk = False
for o,a in opts:
if o in [ '--debug' ]:
opt_debug = True
elif o in [ '-u', '--username' ]:
opt_username = a
- elif o in [ '--ucssdk' ]:
- opt_ucssdk = True
- from UcsSdk import *
elif o in [ '-p', '--password' ]:
opt_password = a
elif o in [ '--no-cert-check' ]:
@@ -156,21 +152,8 @@ class Server:
return self.communicate(payload, {"classname": classname})
-if not opt_ucssdk:
- handle = Server(host_address)
- handle.login(opt_username, opt_password)
-else:
- # Use the UcsSdk to query the data. This loads 35MB(!) of python code...
- try:
- handle = UcsHandle()
- if opt_debug:
- handle.SetDumpXml() # Debug telegrams
- handle.Login(host_address, username = opt_username, password = opt_password)
- except:
- sys.stderr.write("Cannot connect to UCS Bladecenter. Maybe you provided
" \
- "the wrong credentials. Please check your connection
settings " \
- "and try again")
-
+handle = Server(host_address)
+handle.login(opt_username, opt_password)
for entry, fields in [
## FANS
@@ -225,28 +208,17 @@ for entry, fields in [
print entry
continue
- if not opt_ucssdk:
- response = handle.get_class(entry)
- elements = get_pattern('<%(entry)s (.*?)/>' %
{"entry": entry}, response)
- for element in elements:
- sys.stdout.write("%s\t" % entry)
- values = []
- for field in fields:
- tmp_field = field[0].lower()+ field[1:] # workaround
- value = get_pattern('%s="(.*?)"' % tmp_field,
element)[0]
- if value:
- values.append("%s %s" % (field, value))
- print "\t".join(values)
- else:
- # Use UcsSdk to query the data (used for debugging)
- for obj in handle.GetManagedObject(None, entry):
- sys.stdout.write("%s\t" % entry)
- values = []
- for field in fields:
- value = getattr(obj, field)
- if value:
- values.append("%s %s" % (field, value))
- print "\t".join(values)
+ response = handle.get_class(entry)
+ elements = get_pattern('<%(entry)s (.*?)/>' % {"entry":
entry}, response)
+ for element in elements:
+ sys.stdout.write("%s\t" % entry)
+ values = []
+ for field in fields:
+ tmp_field = field[0].lower()+ field[1:] # workaround
+ value = get_pattern('%s="(.*?)"' % tmp_field,
element)[0]
+ if value:
+ values.append("%s %s" % (field, value))
+ print "\t".join(values)
except Exception, e:
print e
if opt_debug: