0

Is it possible to create VM (or any other tasks) by REST API with a server running ESX without vCenter?

Or it is essential to install vCenter on the server?

I checked these links but they use vCenter:

https://www.youtube.com/watch?v=14WeRVv3NDo https://blogs.vmware.com/code/2017/02/02/getting-started-vsphere-automation-sdk-rest/

Ali Dehqan
  • 461
  • 1
  • 8
  • 18

2 Answers2

3

VMs can be created through either the vSphere Client or the vSphere Management API. There is no requirement to install a vCenter server.

Example to create VMs through the vSphere Client: https://www.youtube.com/watch?v=ddUs5FsczzY

Example to create VMs through the open sourced pyvmomi SDK: https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/create_random_marvel_vms.py

Example to create a VM through the open sourced rbvmomi SDK: https://code.vmware.com/samples/781/create-vm?h=vm%20create

This can be done through several other SDKs as well with the usage of the CreateVM_Task method.

Additional information about this method is available here: http://pubs.vmware.com/vsphere-6-5/index.jsp?topic=/com.vmware.wssdk.apiref.doc/index.html&single=true

Then select 'All Methods' and search for 'CreateVM_Task'

Kyle Ruddy
  • 1,886
  • 1
  • 7
  • 5
  • thanks for your answer! well, I'm able to create vm (or any other tasks) by vSphere wizard, but the thing is I want to do it by an api, like this link: https://www.youtube.com/watch?v=14WeRVv3NDo as you can see in this link, it will connect to vCenter web clinet to do that. how can I do this without vCenter? I also checked this link: https://blogs.vmware.com/code/2017/02/02/getting-started-vsphere-automation-sdk-rest but it still connects to vCenter. – Ali Dehqan Jul 25 '17 at 21:55
  • The link you posted does indeed require the vCenter server. The vSphere Automation APIs are only available through the vCenter and/or PSC systems. The SDK examples I listed above can be pointed at an individual ESXi host as well. Same for the CreateVM_Task method, though through SOAP API and not REST. – Kyle Ruddy Jul 26 '17 at 16:57
  • 1
    Apologies, I see the edit to now include VM creation through REST API. Unfortunately, that is not available as of today. The ESXi hosts do not contain a RESTful endpoint. – Kyle Ruddy Jul 26 '17 at 21:22
2

Creating a VM should be fine with ESXi server directly, but you cannot clone an existing VM or template. The vSphere APIs can do that by connecting to your ESXi directly.

If you really want REST APIs, you can try a 3rd party: https://github.com/DoubleCloudInc/vim-rest-api/ (disclaimer: I am the author).

Steve JIN
  • 46
  • 2