VMware {code} Community
qingxin
Contributor
Contributor

How to use the second parameter ManagedObjectReference host of powerOnVMTask

Hi,

I am a new developer from another country. These days I encounter a problem that: I want to invoke a vm by the API powerOnVMTask in the class VimPortType.

I successfully do it with the second parameter value as null. But I donot know how to use the second parameter "host". Is it mean that if I indicate host value, the vm will be poweroned on that host? Or other meaning?

I googled for 2 days but can not find out the answer. Could anybody help me answer this question? I will be very happy if anybody pay attention to my question. Thank you very much!

Reply
0 Kudos
3 Replies
lamw
Community Manager
Community Manager

As noted in the API reference for PowerOnVM_Task, the second option is optional and is primarily used if you're in a cluster in which multiple ESX(i) host exists and can communicate with the same storage the VM in question is on, you can specify which host the VM is powered on. To do so, you just need to get a reference to the host and pass that into the 2nd parameter, if you're working with a standalone, then you don't need to worry about it.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

qingxin
Contributor
Contributor

Hi William,

Thank you for your help.

My Inventory has one Datacenter. Under it, is one Cluster. Three hosts exist in this Cluster: pal-eesx-01.abc.local, pal-eesx-02.abc.local, pal-eesx-03.abc.local

If click one Virtual Machine, I can see from "Summary" tag on the right part of the screen that Host: pal-eesx-03.abc.local

If I set the host parameter as pal-eesx-02.abc.local, Will this vm be powered on 02.abc.local?

Looking forward for your reply Smiley Happy

Reply
0 Kudos
lamw
Community Manager
Community Manager

As mentioned in the previous reply, if you meet all requirements then yes it will be.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos