This is the code generated by the code capture feature.
from pyVmomi import vim
spec = vim.cluster.ConfigSpecEx()
spec.drsConfig = vim.cluster.DrsConfigInfo()
spec.drsConfig.defaultVmBehavior = "fullyAutomated"
spec.drsConfig.scaleDescendantsShares = 'disabled'
spec.drsConfig.vmotionRate = 1
spec.drsConfig.enabled = True
spec.drsConfig.enableVmBehaviorOverrides = True
spec_drsConfig_option_0 = vim.option.OptionValue()
spec_drsConfig_option_0.value = '1'
spec_drsConfig_option_0.key = 'TryBalanceVmsPerHost'
spec_drsConfig_option_1 = vim.option.OptionValue()
spec_drsConfig_option_1.key = 'MaxVcpusPerCore'
spec.drsConfig.option = [spec_drsConfig_option_0,
spec_drsConfig_option_1]
spec.proactiveDrsConfig = vim.cluster.ProactiveDrsConfigInfo()
spec.proactiveDrsConfig.enabled = True
spec.dpmConfig = vim.cluster.DpmConfigInfo()
spec.dpmConfig.hostPowerActionRate = 3
spec.dpmConfig.enabled = False
modify = True
managedObject.ReconfigureComputeResource_Task(spec, modify) # ClusterComputeResource-domain-c8
Error: C:\python>python drsTestThing.py
Traceback (most recent call last):
File "C:\python\drsTestThing.py", line 38, in <module>
managedObject.ReconfigureComputeResource_Task(spec, modify) # ClusterComputeResource-domain-c8
NameError: name 'managedObject' is not defined
So far I gave determined that the return of the ReconfigureComputeResource_Task function is a Task object according to this https://vdc-download.vmware.com/vmwb-repository/dcr-public/da47f910-60ac-438b-8b9b-6122f4d14524/16b7274a-bf8b-4b4c-a05e-746f2aa93c8c/doc/vim.ComputeResource.html and it must be called by a cluster object.
My issue is I don't understand how to make to make a cluster object and how that connects to vSphere and changes the configuration of the cluster.
Currently I am connecting to the host using SmartConnect from the pyVim library. I also have this working with powerCLI but the connect-vi server method hangs so I would like to accomplish this task with python.