General error while connecting to vCenter Server

This post was originally published on this site

Hey,

When I’m trying connect to a vCenter server* via the official vsphere automation SDK’s code I’m getting the following error: “com.vmware.vapi.std.errors_client.InternalServerError: {messages : [LocalizableMessage(id=’vapi.security.authorization.exception’, default_message=”Exception in invoking authorization handler ‘com.vmware.vcenter.datacenter.list'”, args=[“‘com.vmware.vcenter.datacenter.list'”], params=None, localized=None)], data : None, error_type : INTERNAL_SERVER_ERROR}

I tried to debug the code and I found that the error which I get is duo to the last line of code.

 

*vCenter is the appliance version, connected with internal NAT and port forwarding

 

Here is the full code, from the SDK’s official github (GitHub – vmware/vsphere-automation-sdk-python: Python samples, language bindings, and API reference documentation for vS… ):

 

import requests

import urllib3 from vmware.vapi.vsphere.client
import create_vsphere_client session = requests.session()
# Disable cert verification for demo purpose.
# This is not recommended in a production environment.
session.verify = False
# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning# Connect to a vCenter Server using username and password

vsphere_client = create_vsphere_client(server=‘<vc_ip>’, username=‘<vc_username>’, password=‘<vc_password>’, session=session)

# List all VMs inside the vCenter Server

vsphere_client.vcenter.VM.list()

 

*Obviously inserted my own vcenter address, username and password (which checks out)

*All code including comments were written by the SDK writers.

 

Thanks,

Alon Zinger

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.