VMware Cloud Community
mp3istk
Contributor
Contributor

Create workflow which will run the action on all VMS.

Hi guys,

I'm new with all the VRO world.

I'm trying to build a workflow which will check by date created all VMS, and then will check each VM if the specific value in custom attributes exist or nor.

If the value will not exist, the workflow will send an email to fix list of people.

 

It will really help me if you can show me a kind of diagram or something similar - how to it needs a look like .

Best regards,

Daniel M.

Reply
0 Kudos
2 Replies
domrein
Contributor
Contributor

Hi Daniel,

get all VMs from all connected vCenters, you can filter by adding a filter to the command:

var allVms = VcPlugin.getAllVirtualMachines();

The creation-time of the VM should be easy to get via the events - there is a "VmCreatedEvent". However this sometimes is not available -> prepare a fallback.

var spec = new VcEventFilterSpec(); 

spec.eventTypeId = ["VmCreatedEvent"]; 

spec.entity = new VcEventFilterSpecByEntity(); 

spec.entity.entity = vm; 

spec.entity.recursion = VcEventFilterSpecRecursionOption.self; 

 

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

if (events && events.length > 0) { 

  createDate = events[0].createdTime;

}

Accessing the custom attributes is a bit more complicated. I've already done this but I deleted it afterwards because I've done the task without them... So maybe someone else can help you here.

To send an email you should have a look at the snmp plugin, there are some sample workflows.

This may help you with further coding: vRO API Explorer by Dr Ruurd and Flores of ITQ

Regards

Dominik

Reply
0 Kudos
mp3istk
Contributor
Contributor

Thanks Dominik.

Reply
0 Kudos