VMware {code} Community
schue
Contributor
Contributor
Jump to solution

Create VM instance on Cluster

Hi,

I want to create virtual machines on Cluster, not on a specified host.

My Problem is that the function VMCreate need an type "resourcePool" and I don't know how to create a resourcePool from a ClusterComputeResource.

Can anyone help me?

Thanks in advance

Henning

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

If you don't have/use resource pool, by default there is a default resource pool called resourcePool. You just need to get a reference to the root pool and that can be used as a param to CreateVM_Task().

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

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".

View solution in original post

0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

If you don't have/use resource pool, by default there is a default resource pool called resourcePool. You just need to get a reference to the root pool and that can be used as a param to CreateVM_Task().

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

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".

0 Kudos
schue
Contributor
Contributor
Jump to solution

Thanks again for your help!!

0 Kudos
Michalek
Contributor
Contributor
Jump to solution

0 Kudos
xyz222
Contributor
Contributor
Jump to solution

Your XML should look more like this:

<Virtual-Machines>

         <Virtual-Machine>

            <Name>$vmhostname</Name>

                <Host>$cluster_host</Host>

            <Datacenter>$vdatacenter</Datacenter>

                <Guest-Id>rhel6_64Guest</Guest-Id>

                <Datastore>$datastore</Datastore>

                <Disksize>$first_disk</Disksize>

                <Memory>$memory</Memory>

                <Number-of-Processor>$numprocs</Number-of-Processor>

         </Virtual-Machine>

</Virtual-Machines>

$cluster_host is a host in the cluster you wish to create the VM in. It wont necessarily create the vm on that host, as the cluster will decide the best place for the VM to go.

0 Kudos
Michalek
Contributor
Contributor
Jump to solution

Ok, I have found the problem thanks to You!

The value of the <Guest-Id> has to be for example "rhel6_64Guest" and not a random word... that is it!

0 Kudos