Skip to content

Commit

Permalink
Merge pull request #16 from Napsty/pywbem-versions
Browse files Browse the repository at this point in the history
Distinguish between pywbem 0.7 and 0.8
  • Loading branch information
Napsty committed Apr 11, 2016
2 parents d8a95f8 + 496ae6c commit ec7db64
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions check_esxi_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider
# Copyright (c) 2010-2015 Claudio Kuenzler
# Copyright (c) 2010-2016 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin
Expand Down Expand Up @@ -231,6 +231,10 @@
#@ Reason : Removed unused sensor_value variable and string import.
#@ Reason : Added global hosturl variable declaration after imports.
#@---------------------------------------------------
#@ Date : 20160411
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Distinguish between pywbem 0.7 and 0.8 (which is now released)
#@---------------------------------------------------

import sys
import time
Expand All @@ -239,7 +243,7 @@
import pkg_resources
from optparse import OptionParser,OptionGroup

version = '20151111'
version = '20160411'

NS = 'root/cimv2'
hosturl = ''
Expand Down Expand Up @@ -589,7 +593,7 @@ def handler(signum, frame):
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
pywbemversion = pkg_resources.get_distribution("pywbem").version
verboseoutput("Found pywbem version "+pywbemversion)
if '0.7.0' in pywbemversion:
if '0.7.' in pywbemversion:
try:
conntest = pywbem.WBEMConnection(hosturl, (user,password))
c = conntest.EnumerateInstances('CIM_Card')
Expand All @@ -601,7 +605,7 @@ def handler(signum, frame):
verboseoutput("Connection worked")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
# pywbem 0.8.0 and later
elif '0.8.0' in pywbemversion:
elif '0.8.' in pywbemversion:
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)

# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
Expand Down

0 comments on commit ec7db64

Please sign in to comment.