VMware {code} Community
jmacdonagh
Contributor
Contributor

VirtualCenter will only clone 4 VMs at a time, and will only create MORs for 8 at a time

Hi,

In my application, I may need to clone 8+ VMs and set permissions on each before they are finished. Now, the VirtualMachineCloneSpec does not have an option to set permissions, so I would have to call SetEntityPermissions with its MOR. This works fine with 1-8 clones at a time (with 8, the first 4 will actually clone while the other 4 say "In Progress" and wait. However, all 8 show up in the Inventory view, which means I can use FindByInventoryPath to get its MOR). However, if I do more than 8, then the other tasks will be "queued" and no entry is put in the Inventory view. Essentially, my code does this (highly psuedo-coded Smiley Wink 😞

num = 16

for(1 to num)

CloneVM_Task(...)

.. Monitor task until its marked as "running", that way we know that its in the inventory

SetEntityPermissions(FindByInventoryPath(path), ...)

Now, obviously my code will have issues here if num > 8. Essentially the part where my code waits around for the task to be in a state where an entity is created in the inventory will sit there for a long time. Since this is running from an ASP.net website, that may cause problems.

So, how do I raise the maximum number of tasks that will be active at once? Ideally, I would like to set it to unlimited, so I'll never has this problem. Note: I don't mind only have 4 clone at once, I just want to make sure that every CloneVM task will create an entry in the inventory relatively quickly.

Or, can anyone think of a better way to clone a VM and set permissions right then and there? Maybe the VirtualMachineCloneSpec.config.extraConfig?

Thanks,

Johann

0 Kudos
3 Replies
jmacdonagh
Contributor
Contributor

Well, I tried everything I could think of, but nothing worked.

What I am doing now is spawning off a thread after I call Clone_VM. The thread waits until it gets a MOR to the path, and then sets the permissions. Kinda clunky, but it works.

As a side note, I found a funny bug in VC. If I deploy off a relatively large number of VMs (say 8+), then obviously spawn off that many threads. However, some of the threads will successfully find the item in the inventory, but when they run SetEntityPermission, the web service actually tells me that I violated a FK constraint in the VC database. I even tried waiting 10 seconds after my thread determines that the item exists in the inventory, but I still ran into problems. So now, I wait until the task is successful, and then I set the permissions.

0 Kudos
akutz
Hot Shot
Hot Shot

FYI - in vpxd.cfg on the VC and ESX servers you can find:

The above section is from VC. The ESX servers set this value to 10 by default. Perhaps tweaking this value will help? This is NOT the timeout value, which is also 30 for short-running tasks. This value can be set from the VI client under VC settings.

jmacdonagh
Contributor
Contributor

Yeah, I had already tried to set that. I set it to 65536, but it didn't make a difference.

So far, the multi-threading approach seems to work. Let's hope I don't run into any problems Smiley Wink

0 Kudos