vsphere-automation-sdk-python: Error when trying to list all the vm's running.

Environment

  • sdk package version: nsx-vmc-aws-integration-python-sdk 2.5.1.0.1.15419398 nsx-vmc-policy-python-sdk 2.5.1.0.1.15419398 pyvmomi 6.7.3 vapi-client-bindings 3.2.0 vapi-common-client 2.14.0 vapi-runtime 2.14.0 vconnector 0.6.0 vmc-client-bindings 1.23.0 vmc-draas-client-bindings 1.3.0 vSphere-Automation-SDK 1.21.0
  • python version: Python 3.7.6
  • vSphere version: vSphere-Automation-SDK 1.21.0

  • Operating System/Shell (used to run SDK-based apps): Mac OS(10.14.6)

Steps or code snippet to reproduce

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

session.verify = False

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

vsphere_client = create_vsphere_client(server='aa.bbb.yyy.xxx', username='name@organisation.org', password=pwd, session=session)

print(vsphere_client.vcenter.VM.list())

Actual behavior:

Traceback (most recent call last):
  File "hosts.py", line 13, in <module>
    print(vsphere_client.vcenter.VM.list())
  File "/usr/local/lib/python3.7/site-packages/com/vmware/vcenter_client.py", line 5153, in list
    'filter': filter,
  File "/usr/local/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke
    return self._api_interface.native_invoke(ctx, _method_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 298, in native_invoke
    self._rest_converter_mode)
com.vmware.vapi.std.errors_client.InternalServerError: {messages : [LocalizableMessage(id='vapi.bindings.method.impl.unexpected', default_message='Provider method implementation threw unexpected exception: null', args=['null'], params=None, localized=None)], data : None, error_type : None}

Expected behavior:

All the Vm’s should be listed up

However when I do this I get the bunch of VM’s which are up. I don’t know are they both doing same thing ?

from __future__ import print_function
from vconnector.core import VConnector
from config import *

client = VConnector(
     user='name@organisation.org',
     pwd=pwd,
     host='aa.bbb.yyy.xxx')
client.connect()
vms = client.get_vm_view()
print(vms.view)

client.disconnect()

Moreover in Vsphere - api explorer the code for fetching requests are also not given as well as no way to generate token.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (10 by maintainers)

Most upvoted comments

Can you try it in a new virtual environment? Not that what you have done is incorrect, just to make sure there are no conflicting versions.