1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2025-04-03 14:43:40 +02:00

Update to newer pywbem exception call

This commit is contained in:
Napsty 2025-02-14 14:05:25 +01:00
parent b06dc7a767
commit 1fe3fb3b6a

View File

@ -299,8 +299,8 @@
# Remove pywbem 0.7.0 compatibility
#@---------------------------------------------------
#@ Date : 20250214
#@ Author : Phil Randal and Claudio Kuenzler
#@ Reason : Update to newer pywbem exception call
#@ Author : Claudio Kuenzler
#@ Reason : Update to newer pywbem exception call, handle HTTPError
#@---------------------------------------------------
import sys
@ -752,7 +752,7 @@ else:
verboseoutput("pywbem is older than 1.0.0")
import pywbem.cim_operations as PywbemCimOperations
import pywbem.cim_http as PywbemCimHttp
import pywbem._exceptions as PywbemExceptions
import pywbem.exceptions as PywbemExceptions
# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
if on_windows == False and timeout > 0:
@ -784,6 +784,10 @@ if vendor=='auto':
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
except PywbemExceptions.HTTPError as args:
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
except PywbemCimHttp.AuthError as arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
@ -819,6 +823,10 @@ for classe in ClassesToCheck :
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
except PywbemExceptions.HTTPError as args:
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
except PywbemCimHttp.AuthError as arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown