Hello,
I'm trying to create a VmGroup and populate it with some VM in order to configure DRS to keep some virtual machines together.
I wrote it in this way:
def add_vm_to_vm_group(self, vm, cluster):
# check if VmGroup Exists windows_group = filter(lambda x: x.name == 'Windows', filter(lambda x: x.__class__.__name__ == 'vim.cluster.VmGroup', cluster.configurationEx.group)
)
spec = vim.cluster.ConfigSpecEx()
if windows_group:
operation = "edit" vm = vm if type(vm) is list else [vm]
group_vm = vim.cluster.GroupSpec()
group_vm.info = windows_group[0]
else:
operation = "add" vm = []
group_vm = vim.cluster.GroupSpec()
group_vm.info = vim.cluster.VmGroup()
group_vm.operation = operation
if not windows_group:
group_vm.info.name = "Windows" group_vm.info.vm = vm
spec.groupSpec.append(group_vm)
task = cluster.ReconfigureComputeResource_Task(spec, True)
wait_for_task(task)
Actually, the group is created but it has no VM inside of it. Watching at the group_vm object I can see the VirtualMachine on the property and the request is made according to it. I receive no errors from vCenter but still I'm not able to add the virtual machine to the group.
Could someone help me? I'm going crazy about this...
Thanks!