Getting started on Rest API with VMWare ESXi 7.0.0

I followed the basic instructions / read the examples at

  • https://code.vmware.com/docs/12016/vmware-vcenter-server-management-programming-guide/GUID-EE3B04C5-3968-41FB-82BB-0908FE08781D.html
  • https://github.com/vmware/vsphere-automation-sdk-python
  • https://communities.vmware.com/thread/608909
  • https://vthinkbeyondvm.com/getting-started-with-vcenter-server-rest-apis-using-python/

And i read openstack rest API start/stop server

But i cant figure out how i can query the API. Im running the ESXi on a local VMWare VM on my laptop, the web GUI works fine but https://server/rest is just a blank site, and i cant query anything over the Python SDK either (using the example from the Github page and giving it the IP and credentials)

I'm just getting started with VMWare APIs and i really don't understand what went wrong.

EDIT: When using the Python SDK im getting the following error:

com.vmware.vapi.std.errors_client.OperationNotFound: {messages : [LocalizableMessage(id='vapi.provider.interface.unknown', default_message='Unknown interface: com.vmware.cis.session', args=['com.vmware.cis.session'], params=None, localized=None)], data : None, error_type : None}

EDIT2: calling the info from the server via this sample script i got from the vmware github works as well.

#!/usr/bin/env python
"""
Python program for flat text listing the VMs on an
ESX / vCenter, host one per line.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function

import sys
sys.path.insert(0, 'C:/Users/lpeschko/Documents/Python Projects/VMWareSDK/venv/Lib/site-packages')


import atexit
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim
from tools import cli

MAX_DEPTH = 10

def setup_args():

    """
    Get standard connection arguments
    """
    parser = cli.build_arg_parser()
    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)


def printvminfo(vm, depth=1):
    """
    Print information for a particular virtual machine or recurse into a folder
    with depth protection
    """

    # if this is a group it will have children. if it does, recurse into them
    # and then return
    if hasattr(vm, 'childEntity'):
        if depth > MAX_DEPTH:
            return
        vmlist = vm.childEntity
        for child in vmlist:
            printvminfo(child, depth+1)
        return

    summary = vm.summary
    print(summary.config.name)


def main():
    """
    Simple command-line program for listing the virtual machines on a host.
    """

    args = setup_args()
    si = None
    try:
        si = SmartConnectNoSSL(host=args.host,
                               user=args.user,
                               pwd=args.password,
                               port=int(args.port))
        atexit.register(Disconnect, si)
    except vim.fault.InvalidLogin:
        raise SystemExit("Unable to connect to host "
                         "with supplied credentials.")

    content = si.RetrieveContent()
    for child in content.rootFolder.childEntity:
        if hasattr(child, 'vmFolder'):
            datacenter = child
            vmfolder = datacenter.vmFolder
            vmlist = vmfolder.childEntity
            for vm in vmlist:
                printvminfo(vm)

# Start program
if __name__ == "__main__":
    main()

Solution 1:

you need to query vcenter api, afaik exsi doesn't host the api endpoints.