Hello All,
I am using waitForUpdates() API to receive events from virtual center. I follow sample code provided here. (I use .NET SDK). Everything works OK, except that when I call waitForUpdates() for the first time (with strVersion = NULL), I receive a bunch of events from the past. My understanding is waitForUpdates() will wait for the "next" event(s). Is this an expected behavior ?
Thanks
~jx
Yes. You can check the change type with the op property of the PropertyChange.
http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vmodl.query.PropertyCollector.Change.html
Steve JIN, VMware Engineering
Hello Steve,
Thanks for the input. It did help, but I guess I need more information.
1) I could not find any documentation regarding this behavior. Can you please direct me to something besides the API doc ?
2) If we are supposed to receive past events, how many should we expect ? All events since VC was installed ?
3) Ideally we don't care about past events. Is there any way make it receive only new events ?
4) Suppose there was a VM by name "Guest1". It was added to the inventory and removed from inventory several times. Will all those "add"s and "remove"s appear as separate events in sequence?
Your help on this is appreciated.
Thanks
~j
1) I am not aware there is such a doc. Pls let me know if you find one.
2) You can actually filter out the events with the EventFilterSpec when you create the EventHistoryCollector. Check out:
3). Should be after #2.
4). I think so.
Steve JIN, VMware Engineering
Hi,
Regarding VMEventsMonitor.java example provided - when i create the EventHistoryCollector like that:
eventMonitor.createEventHistoryCollector();
PropertyFilterSpec eventFilterSpec = eventMonitor.createEventFilterSpec();
To be more specific, what should i add/change in order to track only new VMCreatedEvent events (starting from host current time and on)?
Thanks,
Benzi.
To get the events from a specified time, you can set the time.beginTime property of EventFilterSpec. This will collect only those events that have occurred after the specified begin time.
EventFilterSpecByTime timeSpec = new EventFilterSpecByTime(); timeSpec.setBeginTime(startTime); eventFilter.setTime(timeSpec); // set other parameters for querying events in filter spec _eventHistoryCollector = _service.createCollectorForEvents(_eventManager, eventFilter);
Hope this helps.
yes - it did help. thanks.
But once i get the desired VM event (VMReconfiguredEvent in my case) i can't see how i can get the exact event info/data (that was modified) from the event info. For example, if i add-hoc VNic to the VM i want to know which VNic was added and i want to get direct access to that new VNic data (maybe modify it). Is it possible in such direct way? Is it possible somehow via the VM reference given in the event?
Hi,
How do i get HostNetworkSystem related events? let's say when adding new Vswitch?
I suppose createEventHistoryCollector() in VMEventsMonitor.java should be changed to enable this.
Can you give an example?
I have tried changing the eventFilter.setType setting to HostSystem or HostNetworkSystem but it did not work. In fact, even if i deleted this setting at all i still got only VM related event so i am not sure what to change in this function in order to get also vswitch related events.
Benzi.