开发者

How to create a VM using VSphere java API?

I want to write some java code to create a VM, install iso (or copy the existing vm set up if install iso is not possible) and assign disk spac开发者_如何转开发e, create login for the created VM.

I looked at Vsphere API examples in http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/samples/, it has power on/off of installed VM. I could not figure out how to create one with the API. I have two questions:

  1. What are the steps to create VM using API?
  2. What API or objects should be used to create VM programatically?

Appreciate your help.


I know i am about a year late, but when you download the SDK, you will have a sample how to create a VMdisk. Understand the code and then you can just do it your way :)

The link to the SDK.zip file http://communities.vmware.com/community/vmtn/developer/forums/java_toolkit

and inside the SDk, the VMDisk file: \SDK\vsphere-ws\java\JAXWS\samples\com\vmware\vm


You'll want to keep the VMware Web Services SDK documentation handy - unfortunately they changed formats recently so I'm not sure how good of deep links I can get for you. The specific method I've used is CreateVM_Task (you'll have to scroll down to find it on the Folder object). Alternatively, if you're using a resource pool, CreateChildVM_Task may be more applicable (again, scroll down to find it).

There is also a section of documentation on creating VMs that has some incomplete example code.

As far as where in the hierarchy to create the VM, that's up to you. Each host or cluster will have a vmfolder property that you can use to create VMs, or any other folder may work. Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜