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

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" = vim.cluster.VmGroup() = "Windows" = 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
A specified
was not
13/05/2015 09:58:18

What am I doing wrong?