Highlighted
Contributor
Contributor

The object has already been deleted or has not been completely created - pyvmomi

Hi Team,

I'm using pyvmomi, facing one issue intermittently. I'm using following function to get the VM object by passing VM Name, this method sometime throws "The object 'vim.VirtualMachine:vm-4078' has already been deleted or has not been completely created" error (This error occurs at line  if c.name == vm_name: line). Any suggestion on handling this issue is much appreciated. Thanks.

def get_vm_by_name(self, content, vm_name=None😞

   try:

         vm_obj = None
         container = content.viewManager.CreateContainerView(content.rootFolder, [vim.VirtualMachine], True)

          for c in container.view:

              if vm_name:

                  if c.name == vm_name:

                      vm_obj = c

                      break

        return vm_obj

   except Exception as ex:

   raise Exception("failed to get vm details")

Please note that, same API had returned result for the same VM few seconds before.

VSphere version 6.7.0.20000

Tags (1)
0 Kudos
0 Replies