VMware Cloud Community
manfriday
Enthusiast
Enthusiast
Jump to solution

Get all running vcenter tasks? - getAllTasks() ?

Hi,

I need to get a list of ann running vcenter tasks.

I think I need to use something like

vcTasks = Vcplugin.getAllTasks();

Not sure what parrameters I need to pass it in order to get the list.

specifically I need to get a list of any running cloning tasks.

Thanks!

Jason

Reply
0 Kudos
1 Solution

Accepted Solutions
dvatov
VMware Employee
VMware Employee
Jump to solution

This should work for you

var hosts = VcPlugin.vimHosts;
var tm = hosts[0].taskManager;
tasks = tm.recentTask;
System.log(tasks.length);
for (var i in tasks) {
   System.log(tasks[i].info.name);
}
'name' property for me is CloneVM_Task. In 'info' you can find other interesting properties - for example on which object the task was started. There is a bug in VcPlugin.getAllTasks() that will be addressed in the next release.

View solution in original post

11 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Hi,

Don't you get all of them without passing any specific parameter ?

If so you can iterate through each of them and check their status and their type.

There may be a way to specify a xPath query to do it but I am not sure about the syntax. It was covered previously on this forum for finding VMs.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
manfriday
Enthusiast
Enthusiast
Jump to solution

I would have thought sending passing no parrameters would have returned an array of all running tasks too..

I have defined "tasks" as a array of VC:Task

var tasks = new Array();

tasks = VcPlugin.getAllTasks();

System.log(tasks.length);

this outputs:

[I] 0

regardless of whether there is a task running at the time. It looks like the array is just not being filled with anything.

I imagine I am doing something dumb. I am prepared to feel embarrased.

Smiley Happy

Reply
0 Kudos
manfriday
Enthusiast
Enthusiast
Jump to solution

starting to think the getAllTasks() method is bugged.

Does VMWare support orchestrator or is it 'installation only' support?

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Fully supported. You can open a support request at GSS.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

Hi!

I also gave it a try and I can reproduce your result: Nothing comes back from the method...

So: Open a support call...

Regards,

Joerg

manfriday
Enthusiast
Enthusiast
Jump to solution

well, at least I know I aint crazy! )at least in this regard)

Smiley Happy

Thanks guys

Reply
0 Kudos
Kelly_Cooke
VMware Employee
VMware Employee
Jump to solution

VMware's support of Orchestrator covers installation, configuration, and limited support for system default workflows/plug-ins.

If you require support for the scripts within a workflow or how to create or troubleshoot a workflow PSO stands ready to assist.

--Kelly Cooke

Enterprise Applications – Orchestrator Escalation Engineer

VMware

Reply
0 Kudos
manfriday
Enthusiast
Enthusiast
Jump to solution

hopefully vmware can either confirm or deny that this is a bug without me having to break out my credit card?

Reply
0 Kudos
Kelly_Cooke
VMware Employee
VMware Employee
Jump to solution

We will absolutely work with you to confirm or deny if the issue is a bug. We will try and reproduce the behavior in our lab environment and engage our Development team when we find a bug.

I am familure with the SR you have submitted for this issue and myself and the TSE you are working with will test your workflow in the lab and engage Develupment as needed.

--Kelly Cooke

Enterprise Applications – Orchestrator Escalation Engineer

Vmware

Reply
0 Kudos
dvatov
VMware Employee
VMware Employee
Jump to solution

This should work for you

var hosts = VcPlugin.vimHosts;
var tm = hosts[0].taskManager;
tasks = tm.recentTask;
System.log(tasks.length);
for (var i in tasks) {
   System.log(tasks[i].info.name);
}
'name' property for me is CloneVM_Task. In 'info' you can find other interesting properties - for example on which object the task was started. There is a bug in VcPlugin.getAllTasks() that will be addressed in the next release.
manfriday
Enthusiast
Enthusiast
Jump to solution

You sir, are the man. You rock with a steady beat.

based on your insight I was able to create my own "getAllTasks" action:

var hosts = VcPlugin.allSdkConnections;
var tm = hosts[0].taskManager;
var allTasks = tm.recentTask;
return allTasks;

I read that allSdkConnections replaced the deprecated vimHosts, so I used that.

Seems to work fine.

Thanks for taking the time to help me out!

Jason

Reply
0 Kudos