pyVmomi.SoapAdapter.ParserError: xml document parse error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
I get this error when querying the vSAN health summary. I'm using pyVmomi version 6.7.1.2018.12
Traceback (most recent call last):
File "/usr/share/java/pycharm-community/helpers/pydev/pydevd.py", line 1741, in <module>
main()
File "/usr/share/java/pycharm-community/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/usr/share/java/pycharm-community/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/juan/devel/scripts/vmware/vsan-get-disk-health.py", line 75, in <module>
cluster=cluster, includeObjUuids=True, fetchFromCache=True)
File "/home/juan/.local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/home/juan/.local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/home/juan/.local/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1365, in InvokeMethod
raise exc
pyVmomi.SoapAdapter.ParserError: 'xml document: <pyVmomi.SoapAdapter.GzipReader instance at 0x7facf6235b00> parse error at: line:2, col:29212'
Debugging the code I see that the response is chunked and only gets a fragment of the xml. That could be the reason of the incorrect parsing? or am I doing something wrong?
This is a fragment of the code I'm running, it fails at the line healthSummary = vhs.QueryClusterHealthSummary(...)
vc = {"host": "vcenter.example.com",
"port": 443,
"user": "Administrator@vsphere.local",
"password": "123456",
}
clusters = ["Cluster 1", "Cluster 2"]
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
si = SmartConnect(host=vc["host"],
user=vc["user"],
pwd=vc["password"],
port=vc["port"],
sslContext=context)
if not si:
sys.exit("Could not connect to {h}".format(h=vc["host"]))
atexit.register(Disconnect, si)
# Detecting whether the host is vCenter or ESXi.
aboutInfo = si.content.about
apiVersion = vsanapiutils.GetLatestVmodlVersion(vc["host"])
if aboutInfo.apiType == 'VirtualCenter':
majorApiVersion = aboutInfo.apiVersion.split('.')[0]
if int(majorApiVersion) < 6:
print('The Virtual Center with version %s (lower than 6.0) is not supported.'
% aboutInfo.apiVersion)
sys.exit(-1)
# Get vSAN health system from the vCenter Managed Object references.
vcMos = vsanapiutils.GetVsanVcMos(
si._stub, context=context, version=apiVersion)
vhs = vcMos['vsan-cluster-health-system']
for c in clusters:
cluster = getClusterInstance(c, si)
healthSummary = vhs.QueryClusterHealthSummary(
cluster=cluster, includeObjUuids=True, fetchFromCache=True)
clusterStatus = healthSummary.clusterStatus
print("Cluster %s Status: %s" % (c, clusterStatus.status))
for hostStatus in clusterStatus.trackedHostsStatus:
print("Host %s Status: %s" % (hostStatus.hostname, hostStatus.status))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pyVmomi/SoapAdapter.py at InvokeMethod and the GzipReader referenced by the traceback, then review VmomiSupport.py around the call path. Reproduce the vSAN QueryClusterHealthSummary request using the supplied example and inspect how its chunked response is handled. Done means the parsing failure is explained and a verified fix or clear reproduction boundary is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100