VMware Cloud Community
jvm2016
Hot Shot
Hot Shot

getting vms in datastore_vRO

Hi All ,

Iam in process of utilizing default action items in Orchestrator.

I want to develop the workflow of getting vms in a given datastore.

i did following.

1:draged action element between start and stop schema elements.

2:set action element for getALLVMSodDatastore.

3:create input parmeter as following

pastedImage_1.png

4:create output parameter as folowing .

pastedImage_2.png

5:below is the binding of action element

pastedImage_3.png

However workflow failed .

pastedImage_4.png

Please suggest what needs to be edited.

also whats the difference when we perform same task using

a:vsphere client

b:powercli

c:orchestrator

any help is much appreciated.

Reply
0 Kudos
13 Replies
iiliev
VMware Employee
VMware Employee

Hi,

vmnames name is a bit misleading; perhaps a better name would be something like vms or something similar.

The error is because you have set the type of vmnames to be VC:VirtualMachine, but the output result of action getAllVMsOfDatastore is Array/VC:VirtualMachine. So you are trying to convert an array with several elements in it to a single object, which is an invalid conversion. So you need to change the type of vmnames to Array/VC:VirtualMachine.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

Hello LLian,

thnaks for reply .

i created a new output parameter as follows.

pastedImage_0.png

however when i try to bind this to action element iamnot able to find this . not able to bind newly created "vms" parameter to action element .

pastedImage_1.png

pastedImage_2.png

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

The second screenshot shows actionResult to be of type VC:VirtualMachine, which is wrong; it should be Array/VC:VirtualMachine. That's why you cannot bind it.

Try to delete the action element and drag&drop it again.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

Thanks that worked .however i was planning to create this workflow to get vms in one datastore and migrate to another .

i thought of dragingone more action item and set to storage vmotion but i think that action element is not available but i see a default workflow of  storage vmotion of vms.

is it possible to pass info from  array "vms" to duplicated workflow of storage VMotion.

or do we need to put scriptable task to do storage vmotion.

Please suggest.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Do you have in mind the workflow 'Mass migrate virtual machines with vMotion' ? Its input parameter vms is of type Array/VC:VirtualMachine, so yes, it will be possible to pass your array vms as input to this workflow (your array and one of the workflow input parameter have the same type).

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

Hi  Ilian Iliev,

could you please describe the steps to do it .

i want  to storage vmotion to  another datastore whatevere virtual machines are in "vms" an out put parameter we created in last workflow .

i have duplicated the storagevmotion workflow but there is no option to drag it like action element .

how would i pass stored values in "vms" to storage vmotion workflow.??

Please suggest in detail.

thanks in advance.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

There is an option to drag workflows for sure. In fact, more than one Smiley Happy

The first option - in the palette on the left, there is an item labelled 'Workflow element'. You can drag it and drop on the workflow schema, and it will open a dialog with workflow inventory tree chooser where you can locate and select your workflow.

The second option - in the palette on the left, there is another tab labelled 'All Workflows' (the second one from the bottom). When you click on it, it will open a panel with workflow inventory tree; you can locate your workflow there, and then drag and drop it onto the schema.

OK, lets suppose that you created a workflow with the following items:

(start) --> (action getAllVMsOfDatastore) --> (workflow for storage vmotion) --> (end)

So the task is to get the array of VC:VirtualMachine objects returned as output from the second element (action), and pass it as input to the third element (workflow). To do so, you can create an attribute of type Array/VC:VirtualMachine (go to 'General' tab in the workflow editor; at the bottom there is 'Attributes' table, and you can create a new attribute clicking on the leftmost icon). Give some name to this attribute and set its type to VC:VirtualMachine. Then go back to the 'Schema' tab of the workflow editor, open the action element for edit, click on 'Visual Binding' tab, and connect the actionResult OUT element in the central table to the attribute in the Out attributes table on the right. The repeat the same for the workflow element, but this time you need to connect the attribute in In Atributes table on the left to the corresponding IN element in the table in the center.

The above steps ensure that the array with VMs returned from the action will be stored into workflow attribute, and when the execution go to workflow element, it will get its input array with VMs from the workflow attribute.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

Thanks for your response .

following is what i did.

1:dragedworkflow as suggested by you and final schema looked like below.

pastedImage_0.png

2:created attribute however i dont know is there any way to assign IN/OUT attribute.

pastedImage_1.png

3:iamnot able to bind in action element as newly created attribute dows not show in out attribute.its showing UNDER IN Attibutes.

pastedImage_2.png

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Attribute should appear in both In and Out attributes.

It seems you are doing something wrong during the drag and parameter binding. Why is your workflow element marked as invalid on the schema? When you drop action/workflow element, do you setup/promote parameters?

I'd suggest to create a new empty workflow and try again.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

I created new workflow .

pastedImage_0.png

There is a default workflow of relocatevm to different datastore but i want to check how attributes are used to pass values between different scema elements.

so following is what has been created .

input parameters:

pastedImage_1.png

output parameters:No out put parameters

Attribute:

pastedImage_2.png

visual binding from action element (getVMs of datstore)

pastedImage_3.png

visual binding of workflow element (copy of relocate virtual machines)

pastedImage_6.png

errors:

pastedImage_5.png

could you check this and suggest what can be the issue .

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

'Cannot read property "runtime" from null' points to the following scripting code in the decision element on line #1 of item 3 in workflow 'Copy of Relocate virtual machine disks'

vmState = vm.runtime.powerState.value;

So the above error means the input parameter vm is null.

The parameter is null because from the screenshots it seems you are taking the output of the action, which is of type Array/VC:VirtualMachine, and trying to pass it as input to the workflow parameter vm, which is of type VC:VirtualMachine. That is, you are trying to pass an array of objects and use it as a single object, which is not correct.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

I have made type consistent across entire workflow including action element and workflow.

so type is VC:Virtualmachine not array as currently iam testing and there is only one vm in source datastore.

also for workflow element i have left three IN parameters Null as these were optinnal.

pastedImage_0.png

However it still failed though validation is fine .

error:

pastedImage_1.png

could you please fix it .if iam able to run this workflow this will encorage me to create more.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

It still looks like you are trying to store output of the action, which is of type Array/VC:VirtualMachine, to the attribute temp, which is of type VC:VirtualMachine.

Of course this won't work; an array, even containing a single element, cannot be converted to a single element.

Reply
0 Kudos