latifshaikh
Contributor
Contributor

Do we have rest APIs for vsphere client or EXSi host? I don't have vcentre server, I am using vsphere hypervisor and vsphere client? Do I need to buy vcenter and then can I use rest apis of vcentre to perform vm operations?

Hi All,

Thanks in advance.

I want to automate EXSi steps like creating vlna, VMs and adding vSwitches and etc.

I don't have vcentre server purchased. Do I need it for this?

When I tried to login to EXSi using exsi login creds using rest api, I am getting below response.

curl -v -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'vmware-use-header-authn: test' --header 'vmware-api-session-id: null' -u 'root123' -p 'abc@123' 'https://exsitest.com/rest/com/vmware/cis/session' --insecure

Enter host password for user 'root':

* Rebuilt URL to: alef@123/

*   Trying 0.0.0.123...

* Immediate connect fail for 0.0.0.123: Invalid argument

* Closing connection 0

curl: (7) Couldn't connect to server

*   Trying 192.168.51.202...

* Connected to exsitest.com (192.168.51.202) port 443 (#1)

* found 148 certificates in /etc/ssl/certs/ca-certificates.crt

* found 592 certificates in /etc/ssl/certs

* ALPN, offering http/1.1

* SSL connection using TLS1.2 / ECDHE_RSA_AES_256_GCM_SHA384

* server certificate verification SKIPPED

* server certificate status verification SKIPPED

* common name: localhost.localdomain (does not match 'exsitest.com')

* server certificate expiration date OK

* server certificate activation date OK

* certificate public key: RSA

* certificate version: #3

* subject: C=US,ST=California,L=Palo Alto,O=VMware\, Inc,OU=VMware ESX Server Default Certificate,EMAIL=ssl-certificates@vmware.com,CN=localhost.localdomain,1.2.840.113549.1.9.2=#1321313534323337333434342c35363464373736313732363532303439366536333265

* start date: Fri, 16 Nov 2018 13:04:04 GMT

* expire date: Fri, 17 May 2030 13:04:04 GMT

* issuer: O=VMware Installer

* compression: NULL

* ALPN, server did not agree to a protocol

* Server auth using Basic with user 'root'

> POST /rest/com/vmware/cis/session HTTP/1.1

> Host: exsitest.com

> Authorization: Basic cm9vdDphbGVmQDEyMw==

> User-Agent: curl/7.47.0

> Content-Type: application/json

> Accept: application/json

> vmware-use-header-authn: test

> vmware-api-session-id: null

>

< HTTP/1.1 400 Bad Request

< Date: Tue, 20 Nov 2018 13:14:38 GMT

< Connection: close

< Content-Type: text/plain; charset=utf-8

< X-Frame-Options: DENY

< Content-Length: 0

<

* Closing connection 1

PS: I read somewhere in the document that for vsphere automation, I can use vCli and soapAPIs for Linux. Is that the final option if I decided to not to buy the vcentre license for now. Please confirm my this understanding and let me know if there are any other options available.

Thanks,

Latif