Module: check_mk
Branch: master
Commit: 72cd48f387fd3acc5cc17fe98f9c2a2d56be2a16
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=72cd48f387fd3a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Mar 9 17:30:14 2016 +0100
3006 FIX agent_vsphere: fixed exception when providing the wrong login credentials
---
.werks/3006 | 9 +++++++++
ChangeLog | 1 +
agents/special/agent_vsphere | 13 +++++++------
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/.werks/3006 b/.werks/3006
new file mode 100644
index 0000000..05d6022
--- /dev/null
+++ b/.werks/3006
@@ -0,0 +1,9 @@
+Title: agent_vsphere: fixed exception when providing the wrong login credentials
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1457540970
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index c2684d2..99ccb73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -72,6 +72,7 @@
* 3092 FIX: isc_dhcpd: fixed incorrect handling of timezones
* 3259 FIX: ad_replication: fixed wrong timestamp handling
* 3094 FIX: cisco_temperature: fixed duplicated sensors on some devices...
+ * 3006 FIX: agent_vsphere: fixed exception when providing the wrong login
credentials
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index 87eb4a7..64d34cc6 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -1147,15 +1147,16 @@ def login():
reply_code, repy_msg, reply_headers, reply_data = \
query_server(payload, payload_params = {"username":
encode_url(user),
"password":
encode_url(secret)})
- server_cookie = reply_headers.get("Set-Cookie")
- if host_cookie_path:
- cookie_file = file(host_cookie_path, "w")
- os.chmod(host_cookie_path, 0600)
- cookie_file.write(server_cookie)
-
if "InvalidLogin" in reply_data:
global error
error = "Cannot login to vSphere Server. Login response is not
'OK'. Please check the credentials"
+ else:
+ server_cookie = reply_headers.get("Set-Cookie")
+ if host_cookie_path and server_cookie:
+ cookie_file = file(host_cookie_path, "w")
+ os.chmod(host_cookie_path, 0600)
+ cookie_file.write(server_cookie)
+
# .--Main----------------------------------------------------------------.