VMware Cloud Community
ericr999
Enthusiast
Enthusiast
Jump to solution

Workflow executions organisation

Hello,

I'm almost sure that what I'm going to ask is impossible to do, and I understand why. But I'm asking to see if anyone has any ideas about it.

Basically we have a super huge workflow that builds a VM. The process is started via the REST API, from a custom Portal, a bit like a homemade VRA, but with less features.

So when we start the process, the "Portal" will send all the values in order to build the VM.

We were wondering if there could a way to regroup all executions based on a input value, let's say by VM name. When the workflow is started the VM name is simply a string.

I know that it's impossible to reorganize the workflow executions by inputs, because we could create workflows without any inputs.

I could probably do a workflow to gathers the input of workflow executions and dump everything in the console. But I still have to run it, and then correlate the info received in output and with the workflow executions. Its not very practical, but it could probably work.

Basically the point with this, is to see per vm what was the executions and when, and make it more easier to see that VM the workflow failed 2 times, 1 failed attempt and the second one passed because something had to be fixed manually.

Thanks for your input! Smiley Happy

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This can be done fairly easy with some scripting. Check the following sample that enumerates the executions of a given workflow (variable wf is the input in the code below), orders/groups the executions based on the value of the input parameter vmName (variable inp in the code below), and then prints some execution details.

var inp = "vmName";

var executions = wf.executions;

executions.sort(function(a, b) {

  return a.getInputParameters().get(inp).localeCompare(b.getInputParameters().get(inp));

});

for each (var execution in executions) {

  System.log("execution id: " + execution.id);

  System.log(inp + " -> " + execution.getInputParameters().get(inp));

  System.log("completed on: " + execution.endDate);

  System.log("completion status: " + execution.state);

  System.log("------------");

}

You cannot do something similar with a single REST request because all the REST API that return list of executions do not contain execution's input parameters, so you cannot filter/sort the result of the REST API call.

View solution in original post

Reply
0 Kudos
7 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This can be done fairly easy with some scripting. Check the following sample that enumerates the executions of a given workflow (variable wf is the input in the code below), orders/groups the executions based on the value of the input parameter vmName (variable inp in the code below), and then prints some execution details.

var inp = "vmName";

var executions = wf.executions;

executions.sort(function(a, b) {

  return a.getInputParameters().get(inp).localeCompare(b.getInputParameters().get(inp));

});

for each (var execution in executions) {

  System.log("execution id: " + execution.id);

  System.log(inp + " -> " + execution.getInputParameters().get(inp));

  System.log("completed on: " + execution.endDate);

  System.log("completion status: " + execution.state);

  System.log("------------");

}

You cannot do something similar with a single REST request because all the REST API that return list of executions do not contain execution's input parameters, so you cannot filter/sort the result of the REST API call.

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Hi Ilian,

That's exactly what I was thinking about. I know its doable, but can we do something like this but from within the interface of VRO ?

So in the Run View, we could see all the Execution ids, and at the same time, see their status and reorganize them by input values, per example vmName.

But from what i know the GUI of VRO doesn't allow that and it would probably be impossible to allow this.

I've been asked this in my team so we could see more clearly what has failed vs as completed successfully, based on the vmName. We would have a complete picture and a second.

If I run the workflow proposed, I still have to run it and identify which workflow executions fit with the values retrieved.

Thanks for the code at least I will not have to do that code! Smiley Wink

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

That part returns null for some reason.

execution.getInputParameters().get(inp)

Any idea why ?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Are you getting null for all executions of this workflow, or only for one particular execution? Could you dump the keys/value of Properties object returned by just to make sure that parameters there are the expected ones?

If you get null only for some executions, what is the completion status of these executions? I vague remember that some vRO versions may return empty values for input/output parameters if the execution is still running/not completed.

For the other question - you are correct, there is no option to group executions by input parameter value in vRO workflow designer UI.

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

I'm really getting null only when doing the getInputParameters on all the executions.

[2017-04-12 13:36:13.367] [I] ------------

[2017-04-12 13:36:13.370] [I] execution id: 8a908f945a3d3ccb015a4d8f6a9603de

[2017-04-12 13:36:13.391] [I] LTROTEST305 -> null

[2017-04-12 13:36:13.394] [I] completed on: 2017-02-17 14:32:32

[2017-04-12 13:36:13.400] [I] completion status: failed

[2017-04-12 13:36:13.402] [I] ------------

[2017-04-12 13:36:13.405] [I] execution id: 8a908f945a714f63015b57fcca271460

[2017-04-12 13:36:13.424] [I] LTROTEST305 -> null

[2017-04-12 13:36:13.427] [I] completed on: 2017-04-10 09:11:14

[2017-04-12 13:36:13.432] [I] completion status: failed

[2017-04-12 13:36:13.435] [I] ------------

All of these workflows executions are completed.

From what I saw in the API Explorer it will return a type of ch.dunes.scripting.jsmodel.JSProperties, but can't seem to find any documentation regarding this.

Don't even know if there's a get method there.

Thanks!

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

In API Explorer, search for Properties scripting object.

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Have you ever heard of the errorCode 18 ? The issue was 18 inches in front of the screen! Smiley Wink

I took your code did a few modification, and some of them I shouldn't have done... Smiley Wink

Thanks again, at least I've learned a few things!! hehe

Reply
0 Kudos