vmware / vmware/pyvmomi

Autostart Manager Reconfiguration failed

Open
#220 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

VMware Staff Assist Needed
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

When configuring Autostart Options for a virtual machine the virtual machine is not found.

def set_host_autostart(host, vm):

defaults = { 'start_delay': 120, 'stop_delay': 65535, 'start_action': 'powerOn', 'stop_action': 'GuestShutdown' }
asm = host.configManager.autoStartManager

asm_spec = vim.host.AutoStartManager.Config()
asm_spec.defaults = vim.host.AutoStartManager.SystemDefaults(enabled=True, startDelay=defaults['start_delay'],
                                                                           stopDelay=defaults['stop_delay'],
                                                                           stopAction=defaults['stop_action'])

power_info = vim.host.AutoStartManager.AutoPowerInfo(key=vm,
                                                     waitForHeartbeat=vim.host.AutoStartManager.AutoPowerInfo.WaitHeartbeatSetting.systemDefault,
                                                            startOrder=1,
                                                            startDelay=defaults['start_delay'],
                                                            stopDelay=defaults['stop_delay'],
                                                            startAction=defaults['start_action'],
                                                            stopAction=defaults['stop_action'])
asm_spec.powerInfo = [power_info]

print asm_spec

asm.ReconfigureAutostart(asm_spec)

print asm_spec:

(vim.host.AutoStartManager.Config) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   defaults = (vim.host.AutoStartManager.SystemDefaults) {
      dynamicType = <unset>,
      dynamicProperty = (vmodl.DynamicProperty) [],
      enabled = true,
      startDelay = 120,
      stopDelay = 65535,
      waitForHeartbeat = <unset>,
      stopAction = 'GuestShutdown'
   },
   powerInfo = (vim.host.AutoStartManager.AutoPowerInfo) [
      (vim.host.AutoStartManager.AutoPowerInfo) {
         dynamicType = <unset>,
         dynamicProperty = (vmodl.DynamicProperty) [],
         key = 'vim.VirtualMachine:vm-182',
         startOrder = 1,
         startDelay = 120,
         waitForHeartbeat = 'systemDefault',
         startAction = 'powerOn',
         stopDelay = 65535,
         stopAction = 'GuestShutdown'
      }
   ]
}

Raised Error:

Traceback (most recent call last):
  File "./create_vm.py", line 346, in <module>
    main()
  File "./create_vm.py", line 341, in main
    set_host_autostart(host, vm)
  File "./create_vm.py", line 176, in set_host_autostart
    asm.ReconfigureAutostart(asm_spec)
  File "build/bdist.linux-x86_64/egg/pyVmomi/VmomiSupport.py", line 566, in <lambda>
  File "build/bdist.linux-x86_64/egg/pyVmomi/VmomiSupport.py", line 375, in _InvokeMethod
  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1300, in InvokeMethod
pyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'The object has already been deleted or has not been completely created',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   obj = 'vim.VirtualMachine:vm-2'
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the set_host_autostart function in create_vm.py and inspect how the vm argument is obtained before asm.ReconfigureAutostart is called. Compare that object with the AutoPowerInfo key and vSphere API expectations; the issue is done when a valid virtual machine can be configured without ManagedObjectNotFound.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.