VMware {code} Community
myelaman
Enthusiast
Enthusiast

how to get the uuid of the virtual machine that got deleted from the VM Deleted event

Hi,

I have a requirement of getting the removed vm instance uuid when I get com.vmware.vim25.VmRemovedEvent. I tried as follows:

case "com.vmware.vim25.VmRemovedEvent":

       VmRemovedEvent vmDelEvent = (VmRemovedEvent) event;

       VirtualMachine vm = (VirtualMachine) MorUtil

                      .createExactManagedEntity(si.getServerConnection(), vmDelEvent.getVm().vm);

       VirtualMachineConfigInfo vmConfigInfo = vm.getConfig()

But getting the below exception when I am trying to retrieve configInfo. Is it becasue the vm already removed?

  exception in vmjava.rmi.RemoteException: VI SDK invoke exception:com.vmware.vim25.ManagedObjectNotFound

Please suggest me how to find the deleted vm config information.

Reply
0 Kudos
1 Reply
stumpr
Virtuoso
Virtuoso

Yes, it's deleted.  You won't be able to get the UUID unless you saved it prior to the delete.  I don't think that UUID information is packed into the data of the delete event, unfortunately.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos