Open moonbaseDelta opened 3 years ago
Sorry, not sure I understand the issue. So what is the error you experienced? Did you fix the code yourself or was something inside pywbem broken and fixed?
The API in pywbem changed in 1.0.0.
From https://pywbem.readthedocs.io/en/stable_1.1/changes.html#pywbem-1-0-0b1
"Made all sub-namespaces within the pywbem namespace private, except for pywbem.config. Specifically, renamed the following modules by prepending an underscore character: cim_constants.py, cim_http.py, cim_obj.py, cim_operations.py, cim_types.py, cim_xml.py, exceptions.py, mof_compiler.py, moflextab.py, mofparsetab.py, tupleparse.py, tupletree.py. Using these sub-namespaces had been deprecated in pywbem 0.8.0.
This change is compatible for users that followed the recommendation to import only the symbols from the pywbem namespace. Users that imported symbols from these sub-namespace should now import them from the pywbem namespace. If you miss a symbol in the pywbem namespace, it was likely a symbol that is not part of the public pywbem API. (See issue https://github.com/pywbem/pywbem/issues/1925)"
workaround is to stick with an earlier version of pywbem, e.g.
pip install pywbem==0.17.6
Or apply this patch, which should work with pywbem 0.8.0 and later:
# diff -Naur check_esxi_hardware.py check_esxi_hardware.py.new
--- check_esxi_hardware.py 2021-06-03 09:01:40.092496740 +0100
+++ check_esxi_hardware.py.new 2021-06-03 08:53:03.202992912 +0100
@@ -738,7 +738,7 @@
if vendor=='auto':
try:
c=wbemclient.EnumerateInstances('CIM_Chassis')
- except pywbem.cim_operations.CIMError as args:
+ except pywbem._cim_operations.CIMError as args:
if ( args[1].find('Socket error') >= 0 ):
print("UNKNOWN: {}".format(args))
sys.exit (ExitUnknown)
@@ -751,7 +751,7 @@
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
- except pywbem.cim_http.AuthError as arg:
+ except pywbem._cim_http.AuthError as arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
print("UNKNOWN: Authentication Error")
@@ -773,7 +773,7 @@
verboseoutput("Check classe "+classe)
try:
instance_list = wbemclient.EnumerateInstances(classe)
- except pywbem.cim_operations.CIMError as args:
+ except pywbem._cim_operations.CIMError as args:
if ( args[1].find('Socket error') >= 0 ):
print("UNKNOWN: {}".format(args))
sys.exit (ExitUnknown)
@@ -786,7 +786,7 @@
GlobalStatus = ExitUnknown
print("UNKNOWN: {}".format(args))
sys.exit (GlobalStatus)
- except pywbem.cim_http.AuthError as arg:
+ except pywbem._cim_http.AuthError as arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
print("UNKNOWN: Authentication Error")
Thx @philrandal for sharing the knowledge. Will take a closer look at this. Maybe either ditch support for the old pywbem 0.7.x or have the connection check twice depending on the pywbem version.
You could have separate try ... except blocks depending on pywbem version, for backwards compatibility
Yes, that's what I meant with "check twice depending on the pywbem version". It's basically only RHEL and CentOS which still ship the old pywbem :-/
Hi, I've got those import errors, but investigating current version of pywbem gived me a clue that those two should be
pywbem._cim_http
andpywbem._cim_operations
. That fix inside code worked for py3 and py2.