Create a VmGroup and add a VM

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Create a VmGroup and add a VM

blackms
Hello, I'm trying to create a VmGroup and add a VM to it. I wrote those lines of code:

    def add_vm_to_vm_group(self, vm, cluster):
        vm = vm if type(vm) is list else [vm]
        spec = vim.cluster.ConfigSpecEx()
        group_vm = vim.cluster.GroupSpec()
        group_vm.operation = "add"
        group_vm.info = vim.cluster.VmGroup()
        group_vm.info.name = "Windows"
        group_vm.info.vm = vm
        spec.groupSpec = [group_vm]
        cluster.ReconfigureComputeResource_Task(spec, True)

On vCenter, the VmGroup named "Windows has been created. But it's empty and if I try to run again the code, the vCenter log an error:

Reconfigure cluster
dvcd01cluster01
A specified
parameter
was not
correct.  
VSPHERE.LOCAL\Administrator
13/05/2015 09:58:18

What am I doing wrong?