FYI - Got something to work!

Can see my VM is in VM overrides in VCenter with correct setting after 
running.

Code snippets below (vm_moid is the moid from vmware_guest_info output)

                vm_config_spec = vim.cluster.ConfigSpecEx()
                vm_config_spec.drsVmConfigSpec = 
[vim.cluster.DrsVmConfigSpec()]
                vm_config_spec.drsVmConfigSpec[0].operation = "add"
                vm_config_spec.drsVmConfigSpec[0].info = 
vim.cluster.DrsVmConfigInfo()
                vm_config_spec.drsVmConfigSpec[0].info.key = 
vim.VirtualMachine(self.params.get('vm_moid'))
                vm_config_spec.drsVmConfigSpec[0].info.behavior = 
self.params.get('drs_vm_behavior')
                vm_config_spec.drsVmConfigSpec[0].info.enabled = 
self.params.get('enable')

                try:
                    task = 
self.cluster.ReconfigureComputeResource_Task(vm_config_spec, True)
                    changed, result = wait_for_task(task)
. . .


On Wednesday, 2 November 2022 at 11:32:09 UTC-4 canadapatrick wrote:

> Trying to code module similar to vmware_cluster_drs but for specific VMs.
>
> I am trying to instead use drsVmConfigSpec and dasVmConfigSpec which calls 
> vim.cluster.DasVmConfigSpec / vim.cluster.DrsVmConfigSpec (info).
>
> info for both point to DrsVmConfigInfo and have a key property with type 
> key ManagedObjectReference ( then can pass VirtualMachine type and moid 
> value).
>
> Challenge is how to set the key to a ManagedObjectReference?
>
> See below for what works in PowerCLI:
>
> $spec.drsVmConfigSpec[0].info.key = New-Object 
> VMware.Vim.ManagedObjectReference
>
> How to do same in python?
>
> These don't work:
>
> <varname>.info.key = vmodl.ManagedObjectReference
>
> <varname>.info.key = VmomiSupport.GetWsdlType('urn:vim25', 
> 'ManagedObjectReference')
>
> Sample snippets of what we have tried and no success yet in setting key to 
> be the type of ManagedObjectReference.
>
> Also tried as array etc.
>
> cluster_config_spec = vim.cluster.ConfigSpecEx()
> cluster_config_spec.drsVmConfigSpec = vim.cluster.DrsVmConfigSpec()
> cluster_config_spec.drsVmConfigSpec.info = vim.cluster.DrsVmConfigInfo()
> cluster_config_spec.drsVmConfigSpec.info.key = vmodl.ManagedObjectReference
> cluster_config_spec.drsVmConfigSpec.info.key.type = "VirtualMachine"
> cluster_config_spec.drsVmConfigSpec.info.key.value = 
> self.params.get('vm_moid')
> cluster_config_spec.drsVmConfigSpec.info.enabled = self.enable_drs
> cluster_config_spec.drsVmConfigSpec.info.behavior = 
> self.params.get('drs_default_vm_behavior')
>
> Thanks for any suggestions or solution!
>
> Patrick
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/edc8889b-6d15-4361-8b77-d0c90f14ea5bn%40googlegroups.com.

Reply via email to