joespirit
Contributor
Contributor

Searching Events with Orchestrator

Jump to solution

Hi

We are trying to automate what happens after a HA event has occurred. As an SP we need to be able to identify which VM's were affected and who the VM's belong to so we can advise the client of any potential issues.

This is a manual task at the moment done by going through the events on VC and searching for any VM's restarted by HA.

We are looking to use orchestrator to do this for us and email the clients whilst we concentrate on the issues.

I'm new to Orchestrator but have got my head round the workflows etc but its javascript that I'm really struggling with and although the API documentation is very in depth they don't have any examples associated with them to work from.

So after that introduction does anyone have a snippet of code that searches vcenter for events?

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Hi,

Here is a simple example demonstrating how to enumerate all events of given types (specified on the second line; if you don't specify this property all events will be processed) for a given entity (in this sample, 'vm' of type VC:VirtualMachine):

var spec = new VcEventFilterSpec();

spec.eventTypeId = ["DrsVmPoweredOnEvent","VmResourceReallocatedEvent"];

spec.entity = new VcEventFilterSpecByEntity();

spec.entity.entity = vm;

spec.entity.recursion = VcEventFilterSpecRecursionOption.self;

var events = vm.sdkConnection.eventManager.queryEvents(spec);

for each (var ev in events) {

    System.log("Event: " + ev);

}

So for your case you just need to figure out which entity contains the events you are interested in (perhaps a HostSystem?)  and whether you want to search events only for this entity or also for entity's children (int this case, the line 5 should specify VcEventFilterSpecRecursionOption.all).

View solution in original post

0 Kudos
4 Replies
Hazenet
Enthusiast
Enthusiast

Searching thru Events would be a manual or scheduled thing.

Have you considered using SNMP from vCenter to inform vRO about which VMs has been failed over?

That way vRO are informed about each an every VM that have been failed over by HA, when it actually happens.

0 Kudos
iiliev
VMware Employee
VMware Employee

Hi,

Here is a simple example demonstrating how to enumerate all events of given types (specified on the second line; if you don't specify this property all events will be processed) for a given entity (in this sample, 'vm' of type VC:VirtualMachine):

var spec = new VcEventFilterSpec();

spec.eventTypeId = ["DrsVmPoweredOnEvent","VmResourceReallocatedEvent"];

spec.entity = new VcEventFilterSpecByEntity();

spec.entity.entity = vm;

spec.entity.recursion = VcEventFilterSpecRecursionOption.self;

var events = vm.sdkConnection.eventManager.queryEvents(spec);

for each (var ev in events) {

    System.log("Event: " + ev);

}

So for your case you just need to figure out which entity contains the events you are interested in (perhaps a HostSystem?)  and whether you want to search events only for this entity or also for entity's children (int this case, the line 5 should specify VcEventFilterSpecRecursionOption.all).

View solution in original post

0 Kudos
joespirit
Contributor
Contributor

Perfect! Thank you!

0 Kudos
joespirit
Contributor
Contributor

We did take a look at this option but we weren't completely sure if the vcenter was to be on the problem host would it still send in the traps once it came back up etc.

Also searching through the events will give us more control so we don't want it fully automatic just in case it's a false positive etc.

Many thanks for the suggestion though

0 Kudos