vmware / vmware/pyvmomi

Facing Parse error while querying config options of a VM using EnvironmentBrowser

Open
#915 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

Facing Parse error while trying to query config options of a vm using environment browser. The Function is working fine in MOB console and a Html is returned with all the values but pyvmomi is throwing the parse error. This issue is only seen in case of vSphere 7 and is working fine for vSphere 6.x. .

pyvmomi version : 7.0

Following is the stack trace produced when running the python file error.py
which invokes this function :
<vm_object>.environmentBrowser.QueryConfigOptionEx()

python3 error.py

Traceback (most recent call last):
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 742, in EndElementHandler
obj = GuessWsdlType(name)
File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 1192, in GuessWsdlType
raise UnknownWsdlTypeError(name)
pyVmomi.VmomiSupport.UnknownWsdlTypeError: 'VirtualQAT'During handling of the above exception, another exception occurred:Traceback (most recent call last):
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 514, in ParseData
parser.ParseFile(data)
File "../Modules/pyexpat.c", line 473, in EndElement
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 744, in EndElementHandler
raise TypeError(data)
TypeError: VirtualQATDuring handling of the above exception, another exception occurred:Traceback (most recent call last):
File "getAllVMs.py", line 29, in <module>
details = vms[0].environmentBrowser.QueryConfigOptionEx()
File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1388, in InvokeMethod
raise exc
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1378, in InvokeMethod
obj = deserializer.Deserialize(fd, info.result)
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 845, in Deserialize
ParseData(self.parser, response)
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 525, in ParseData
reraise(ParserError, pe, tb)
File "mydir/python3.6/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 514, in ParseData
parser.ParseFile(data)
File "../Modules/pyexpat.c", line 473, in EndElement
File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 744, in EndElementHandler
raise TypeError(data)
pyVmomi.SoapAdapter.ParserError: 'xml document: <http.client.HTTPResponse object at 0x7f235aa39390> parse error at: line:7, col:90985'python3 error.py
Traceback (most recent call last):
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 742, in EndElementHandler
  obj = GuessWsdlType(name)
 File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 1192, in GuessWsdlType
  raise UnknownWsdlTypeError(name)
pyVmomi.VmomiSupport.UnknownWsdlTypeError: 'VirtualQAT'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 514, in ParseData
  parser.ParseFile(data)
 File "../Modules/pyexpat.c", line 473, in EndElement
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 744, in EndElementHandler
  raise TypeError(data)
TypeError: VirtualQAT
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "getAllVMs.py", line 29, in <module>
  details = vms[0].environmentBrowser.QueryConfigOptionEx()
 File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
  self.f(*(self.args + (obj,) + args), **kwargs)
 File "mydir/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
  return self._stub.InvokeMethod(self, info, args)
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1388, in InvokeMethod
  raise exc
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1378, in InvokeMethod
  obj = deserializer.Deserialize(fd, info.result)
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 845, in Deserialize
  ParseData(self.parser, response)
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 525, in ParseData
  reraise(ParserError, pe, tb)
 File "mydir/python3.6/site-packages/six.py", line 702, in reraise
  raise value.with_traceback(tb)
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 514, in ParseData
  parser.ParseFile(data)
 File "../Modules/pyexpat.c", line 473, in EndElement
 File "mydir/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 744, in EndElementHandler
  raise TypeError(data)
pyVmomi.SoapAdapter.ParserError: 'xml document: <http.client.HTTPResponse object at 0x7f235aa39390> parse error at: line:7, col:90985'

File : error.py

from pyVim import connect
from pyVmomi import vmodl
from pyVmomi import vim
import traceback

def get_all_vms(config):
    vms = []
    try:
        service_instance = connect.SmartConnectNoSSL(host=config['host'], user=config['user'],
                                                     pwd=config['password'], port=int(config['port']))
        content = service_instance.RetrieveContent()
        container = content.rootFolder
        view_type = [vim.VirtualMachine]
        recursive = True
        container_view = content.viewManager.CreateContainerView(container, view_type, recursive)
        children = container_view.view
        for child in children:
            vms.append(child)
    except vmodl.MethodFault as error:
        print("Caught vmodl fault : " + error.msg)
    finally:
        return vms


if __name__ == "__main__":
    config = {'host': 'esxi_ip', 'user': 'user_name', 'password': '', 'port': 'esxi_port'}
    vms = get_all_vms(config)
    try:
        details = vms[0].environmentBrowser.QueryConfigOptionEx()
    except Exception as e:
        print(traceback.format_exc())`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the QueryConfigOptionEx call in error.py, then inspect the deserialization paths named in pyVmomi/SoapAdapter.py and pyVmomi/VmomiSupport.py. Reproduce against vSphere 7 and compare the response handling with vSphere 6.x; done means the vSphere 7 response containing VirtualQAT parses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.