gfmarshall
Contributor
Contributor

ViSDK 2.5 (Java) - Is it possible to inject a Custom Task?

Hi,

I'm developing a ViClient plugin that initiates a backend process that will include ViSDK calls and I'd like to be able to monitor the task in ViClient like any other task. I don't really want to have different tasks in different places...

I assume it is possible to inject custom tasks into the task framework but I can't find any reference to this... does anybody know if this is possible, and if so, how?

Any help / suggestions would be most appreciated,

Gary

Tags (5)
0 Kudos
8 Replies
Steve_Jin
Expert
Expert

Yes. The CreateTask() method on TaskManager is for this purpose.

But, the taskTypeId parameter is related to a pre-registered extension via ExtentionManager. There is currently no good documentation on the ExtensionManager.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
gfmarshall
Contributor
Contributor

Thanks Steve,

But I'm a little confused. My java service will triggered from a button on a web page that is itself a registered extension. So, the user goes to the web page (through the ViClient), clicks the "run my task" button to initiate the java service. The service gets the TaskManager.

When it executes the CreateTask() method, should the taskTypeId field contain:

a) the extension_id of the parent web page, or

b) the extension_id of a second registered extension (the service)

Thanks in advance,

Gary

0 Kudos
Steve_Jin
Expert
Expert

Hi Gary,

This is indeed confusing. The taskTypeId should be from the taskList field of Extension

So far, there is no clear documentation on this.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
gfmarshall
Contributor
Contributor

Thanks Steve,

I thought as much. At least I know I haven't missed anything in the doco so I'll start exploring. Who knows where this might lead? I might gather enough material to start A Hack's Guide to the ViSDK Smiley Wink

Cheers,

Gary

0 Kudos
kuei74
Contributor
Contributor

Hi Gary,

I am trying to do the same thing. Do you find any way to inject a custom task?

Thanks.

0 Kudos
tos2k
Expert
Expert

I posted a script over here:

http://communities.vmware.com/message/1299887

Tos2k

0 Kudos
kuei74
Contributor
Contributor

Hi,

I was able to register a task type with my extension and create a custom task to run. However, it is always "queued" on my vCenter server. So how exactly does it make call to the external web service?

ManagedObjectReference vm1 = new ManagedObjectReference();

vm1.type = "VirtualMachine";

vm1.Value = "vm-221";

CreateTaskAction action = new CreateTaskAction();

action.cancelable = true;

action.taskTypeId = myExtention + "taskZero";

OnceTaskScheduler onceTaskScheduler = new OnceTaskScheduler();

ScheduledTaskSpec logScheduledTaskSpec = new ScheduledTaskSpec();

logScheduledTaskSpec.action = action;

logScheduledTaskSpec.description = "MyscheduledTask";

logScheduledTaskSpec.enabled = true;

logScheduledTaskSpec.name = "MyscheduledTask";

logScheduledTaskSpec.scheduler = onceTaskScheduler;

this.Service.CreateObjectScheduledTask(this.VimServiceContent.scheduledTaskManager,vm1, logScheduledTaskSpec);

Thanks.

0 Kudos
tos2k
Expert
Expert

It doesnt Smiley Wink

You create what ever task, create/run whatever job you are working on.

IN ADDITION you create a task (so in detail you create a task label with a progress bar, state, and start/end time) in vCenter, and update its progress according to your ongoing job.

Tos2k

0 Kudos