VMware Cloud Community
royalgr
Contributor
Contributor
Jump to solution

Add VM to vApp in orchestrator script API

Does anyone know how to add a VM to vApp in orchestrator script API? I've searched the forums and found topics about using Cloud Director, but i dont have that available to me.

I figured out how to create a vApp from a resourcePool, But i dont know how to add VM's i create after that to the vApp i made. Any Ideas?

Reply
0 Kudos
1 Solution

Accepted Solutions
royalgr
Contributor
Contributor
Jump to solution

I got it!

array = new Array();

array[0] = VM;

vApp.moveIntoResourcePool(array);

View solution in original post

Reply
0 Kudos
9 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Take a look at VcVirtualApp#registerChildVm_Task(...) scripting method.

royalgr
Contributor
Contributor
Jump to solution

I tried this out and everything looks good but it didnt actually do anything. I used the .vmx file as the datastore path and just used the vm name for the name. Anything you think im doing wrong?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Could you share the sample workflow/javascript code you are using?

Also, could you check the version/build numbers of vCO server and VC plug-in in your environment? They should be listed in vCO configurator; on 'General' and 'Plugins' tabs.

Reply
0 Kudos
royalgr
Contributor
Contributor
Jump to solution

My scheme is simple. I pass in a VirtualApp (vApp) and a VirtualMachine (VM)

then i call vApp.registerChildVM_Task(VM.config.files.vmPathName);

I've also tried vApp.registerChildVM_Task(VM.config.files.vmPathName, VM.name, null);

I'm using Version 5.1.1 of vmware, vCO Library 1.1.0

Thanks for your help

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

registerChildVM_Task() returns a task object. Could you log its properties (in vCO scripting node); maybe there is an error message or an error code?


Also, there should be some task logs/events in vCenter. could you check if the task is listed as finished successfully there?

Reply
0 Kudos
royalgr
Contributor
Contributor
Jump to solution

I dont think i was getting this yesterday, but now I'm getting an error "The specified key, name, or identifier already exists"

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

I ran it in my 5.5 environment and got the same error Smiley Sad An idiomatic example of useless error message.

Not sure why such error is thrown; maybe the folks on vCenter forum could have an idea what's happening (I think registerChildVM_Task is part of vSphere API and vCO only redirects to it).

royalgr
Contributor
Contributor
Jump to solution

oh.. well at least im not crazy lol

Reply
0 Kudos
royalgr
Contributor
Contributor
Jump to solution

I got it!

array = new Array();

array[0] = VM;

vApp.moveIntoResourcePool(array);

Reply
0 Kudos