VMware {code} Community
rattanat
Contributor
Contributor

Multithreading with VI perl toolkit

Hi,

Would it be possible to perform concurrent VM tasks in threads when using VI perl toolkit? Do I need to connect to the server in each thread to make it work or just once and creates multiple threads to do the task? Any suggestion?

Thanks,

0 Kudos
3 Replies
StefanPahrmann

Hi,

Perl has support for multithreading, this should work, but my guess is that you have to connect with each thread. With the VI-perltoolkit you basically just send and receive xml-files, so there is nothing you can run with threads.

But you can create more concurrent sessions if that will help (and with each session start a new thread)?

-Stefan

0 Kudos
jnhall
Enthusiast
Enthusiast

By default with ithreads (the standard no longer new Perl threading mechanism) data works as with fork(), so you can create a connection once and then use it in whichever threads you fork.

Normally you would use threads to spawn and/or monitor long running chores, often those that return Task objects.

I've used threads with Toolkit in the past and haven't found anything that doesn't work, although I haven't used them in any serious way. If there's anything thread-unsafe it probably relates to the XML library. That said, I don't think that we guarantee Perl Toolkit is thread-safe. If you find bugs related to threading and Toolkit, please report them to us.

0 Kudos
hrobinson
VMware Employee
VMware Employee

If what you are trying to do is to start concurrent tasks on VirtualCenter or ESX, there is really no need to using multi-threading.

With VI Perl Toolkit, we tried to simplify the interface by making all operations (e.g. PowerOn_VM) as blocking. You can, however, start asynchronous operations on a server (or multiple servers) and monitor the task completion state.

Read this part of the user guide as a start.

This should get you started without having to necessarily add threads to perl.

H

0 Kudos