vmware-archive / vsphere-automation-sdk-.net

[DEPRECATED] Please see README. C# samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
68 stars 20 forks source link

how to set host for new vm ? #9

Closed masihnazari closed 6 years ago

masihnazari commented 6 years ago

hi is there any way to set which esxi host must be sellected when create new vm ? i have 2 host in DC1 but new vm always create in first esxi host in vcenter.

vinpai commented 6 years ago

You need to set the host in the PlacementSpec. Take a look at the CreateVM samples. https://github.com/vmware/vsphere-automation-sdk-.net/blob/master/vmware/samples/vcenter/helpers/PlacementHelper.cs

masihnazari commented 6 years ago

i set host with vmPlacementSpec.SetHost("server2.domain.com"); but i receive System.AggregateException: 'One or more errors occurred.' server2.domain.com is my server name shown in vcenter .

vinpai commented 6 years ago

The placement spec expects an id, not the hostname. Please post such queries in the communities https://code.vmware.com/forums/7504/vsphere-automation-sdk-for-.net.