I would like to monitor a Vrtual Center and get a notification when a VM is created or deleted on one of the ESX host that are managed by the Virtual Center.In other words I need to keep track of all the VMs on the VC. But I do not want to keep polling the VC to find out. I would like to have a process that can get notified by the VC whenever a VM is created or deleted. IS this doable?
I have looked at the EventManger and Alarms and they do not seem to provide this. The EventManger seems to record events. The alarm seems to me to be limited to only specific alarms (not create/delete VM).
If you have a SNMP trap receiver, u can register with VC to receive SNMP trap notifications whenever some event occurs on VC, as in ur case. Refer to VI Client docs on how to do this.
What type of integration are you creating? If you are using the SDK you would register PropertyFilter objects looking for this data in the PropertyCollector and then wait on waitOnUpdates() until you get an ObjectUpdate back.
Attached is a quick sample script that repeatedly queries the event manager (every 10 seconds) and collects events when a VM is created or deleted.
I am not a get updates wizard, but you could use this or the EventHistoryCollector to perform a better polling loop.
Here's a typical output if you create and remove a VM.
Event type: VmCreatedEvent: Created virtual machine New Virtual Machine on pmstaff-esx2.eng.vmware.com in New Datacenter
Event type: VmRemovedEvent: Removed New Virtual Machine on pmstaff-esx2.eng.vmware.com from New Datacenter
It depends what you are trying to do, but sure it will tell you when a new VM is added or removed. I think the ObjectUpdateKind is ObjectUpdateKind.enter for when added. You can monitor the missing set for when removed.
But sure, the events stuff might be more useful and lighter weight if this is all you are doing.