Hello everybody,
I am discovering VCO. And i need your help.
How can i use string input as a VC attributes at the end ? Then use this return as input for another workflow.
The workflow i am trying to set up is:
1- Name of VM to search in vCenter: String as input (example: "TOTO")
2- Search "TOTO" virtual machine in the vCenter, if found then
3- Use this result to clone a VM TOTO
For step 1 and 2, it is working, i can search based on the string input and get a result.
But for step 3, i am using another workflow "Create virtual machine" and it takes in put a VC:VirtualMachine.
And it is not working because the type i get in step 2 is not compatible with the input for step 3.
Step 3 input is waiting for VC:VirtualMachine
And Step 2 output is Array/VC:VirtualMachine.
I tried to change the type input for step 3 as Array/VC:VirtualMachine.
Each time i got the error message :
TypeError: Cannot find function cloneVM_Task in object DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.vmo.plugin.vi4.model.VimVirtualMachine] -- VALUE : VirtualMachine<vm-907>'LYNC01'. (Dynamic Script Module name : cloneVM_1#13)
I don't want that the workflow use the search VC plugin, but i need to set input.
If someone has an idea.
Thx all.
Keep the input for step 3 as VcVirtualmachine (a single one), but add an additional step:
2.5: Get the first (or last, shouldn't matter: hopefully you only find exactly one 🙂 ) object from the array.
You can do that in Javascript, using the .pop() method of an array.
var sourceVM = foundVMs.pop() // sourceVM is of type VcVirtualMachine, foundVMs is Array/VcVirtualMachine
Cheers,
Joerg
Keep the input for step 3 as VcVirtualmachine (a single one), but add an additional step:
2.5: Get the first (or last, shouldn't matter: hopefully you only find exactly one 🙂 ) object from the array.
You can do that in Javascript, using the .pop() method of an array.
var sourceVM = foundVMs.pop() // sourceVM is of type VcVirtualMachine, foundVMs is Array/VcVirtualMachine
Cheers,
Joerg
Joerg is nearly correct, .pop() function will return the last instead of the first object of an array. To be correct you can use the .shift() function of an array, so it would look like:
You can do that in Javascript, using the .shift() method of an array.
var sourceVM = foundVMs.shift() // sourceVM is of type VcVirtualMachine, foundVMs is Array/VcVirtualMachine
Sorry Joerg 😉
Thx guys !!!
It is working !!!!