You seem to be failing horribly if the host address is an
IPv6 address:
Traceback (most recent call last):
File "./check_esxi_hardware.py", line 554, in <module>
instance_list = wbemclient.EnumerateInstances(classe)
File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 404, in EnumerateInstances
**params)
File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 168, in imethodcall
verify_callback = self.verify_callback)
File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 112, in wbem_request
host, port, ssl = parse_url(url)
File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 65, in parse_url
port = int(s[1])
ValueError: invalid literal for int() with base 10: 'a18'</module>
The reason is quite clear in cim_http.py:65 ... you
treat the first colon as the port delimiter, while for
IPv6 addresses you'd need to honour the [ ] as host delimiter.
I have a fix for IPv6 support and will address this shortly.
Because some support for IPv6 addresses had been added to cim_http.py, I have verified that with my new testcases for parse_url(), and it turns out that the existing code still has these issues:
The scheme component in the URL is not parsed case insensitively as required by RFC3986, resulting in an exception because the part after HTTP: is treated as the port number.
IPv6 addresses are not parsed correctly, for example in "http://[2001:db8::7348]", the "db8" portion is parsed as the port number.
The zone index (aka scope ID) of IPv6 addresses is not supported.
The format of IPv6 addresses in URIs should conform to RFC6874, while the host string passed to the lower level http functions must conform to RFC4007. The difference are the use of brackets (which must be stripped) and the separator for the zone index (which must be changed from -eth0 to %eth0. The current code does not do that.
Not really a bug, but it would be convenient if trailing path segments would be tolerated (and stripped); the current code raises an exception when trailing path segments are used together with port numbers, because the trailing path segment is treated as part of the port number.
The attached patch adds a testsuite for cim_xml.parse_url() (via a new file testsuite/test_cim_http.py), and fixes the issues mentioned above in cim_xml.parse_url(). The fixed code in cim_xml.parse_url() has been used by us for nearly two years now.
-> Please review and test the patch.
Adjusted the new testsuite/test_cim_http.py to be consistent with other testcases.
Committed the fix as r707.