VMware Cloud Community
LuckyT
Contributor
Contributor

How to convert String to vCO Object type?

Hi All,

          Can someone help me how to convert String to vCO Object Type?

For example:

I will pass VM name as string to workflow and then convert that into VC:VirtualMachine object in Scriptable task & then assign to sub workflow (PowerOff VM) as VC:VirtualMachine.

Thanks in advance.

11 Replies
OscarDavey
Hot Shot
Hot Shot

To Converter Workflows please check this :

VMware vCenter Orchestrator Plug-In Documentation Center

Hope this helped .

Best regards

Your Oscar

Reply
0 Kudos
tschoergez
Leadership
Leadership

Hi,

you have to actually search the inventory for the VM with the given name (be careful, there might be not unique!).

For the you can use VcPlugin.getAllVirtualMachines() with an xpath filter in a scriptable task,

or the Action com.vmware.library.vc.vm.getAllVMsMatchingRegexp from the library.

Also have a look at these resources:

http://www.vmwarelearning.com/orchestrator

Case insensitive search for VM by name (the examples here actually should solve your problem)

cheers,

Joerg

Reply
0 Kudos
LuckyT
Contributor
Contributor

Thanks for your reply.

Actually, I want to call workflow from Java code and pass Input as VM (VC:VirtualMachine) object, i tried with below code,

SdkObject obj = new SdkObject();

obj.setType("VC:VirtualMachine"); 

obj.setId("VCIP/vm-744");

context = new ExecutionContextBuilder().addParam("vm",obj).build();

WorkflowExecution execution = executionService.execute(workflow, context);

but it is pass null to VM input parameter in vCO workflow.

So i thought to pass Vm name as string and within workflow script i will convert that into VC:VirtualMachine object type. but i'm not able to do this.

Can anyone help me resolve this issue or on the workaround?

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee

LuckyT:

The ID of a Virtual Machine actually looks like this through the SOAP api:

dunes://service.dunes.ch/CustomSDKObject?id='vcenter.yourdomain.lab/vm-744'&dunesName='VC:VirtualMachine'

Try using that format on your line that sets the ID... See if that helps.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
LuckyT
Contributor
Contributor

Thanks.

I'm using the same format, but using through Java:

obj.setType("VC:VirtualMachine"); 

obj.setId("VCIP/vm-744");

Can you suggest?

Reply
0 Kudos
babygilr24
Contributor
Contributor

[ SPAM DELETED BY ADMIN]

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Burke - this style of IDs ('dunes://...') is not supported in vCO REST API.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee

I'm not a JAVA developer so I can't help much more Smiley Wink My id example was based on the SOAP API.

Hopefully one of our community members more familiar with Java will be able to further assist you.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
LuckyT
Contributor
Contributor

Can anyone help on this? I'm not able send SDKObject (VM Name) to vCO from my java code.

Reply
0 Kudos
GiulianoBertell
Contributor
Contributor

LuckyT did you ever find the solution for this one? I have the same problem, but calling via POST

Giuliano Bertello
Reply
0 Kudos
vm2cloud
VMware Employee
VMware Employee

I found this guide to work http://www.vzare.com/?p=3560

Reply
0 Kudos