VMware Cloud Community
joespirit
Contributor
Contributor
Jump to solution

Searching Events with Orchestrator

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?

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

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

Reply
0 Kudos
5 Replies
Hazenet
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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).

Reply
0 Kudos
joespirit
Contributor
Contributor
Jump to solution

Perfect! Thank you!

Reply
0 Kudos
joespirit
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
krishna20july
Contributor
Contributor
Jump to solution

Hi Guys,

I am new to Javascript and have a requirement which I need to fulfill as a part of my role .

The requirement is to see if the VM is poweredOFF/Shutdown over the period of  14 days . The way I see this , we can check for VM's "poweredoff" and "VMguestshutdown" events older than 14 days which gives a message having the poweroff/shutdown date, this needs to be done through vRO.

would really appreciate suggestions/

 

Reply
0 Kudos