Hi,
I am a newbie to vCO and extremely raw with JavaScript (a great combination). My production environment consist of vCenter 5.0, vCD 5.1 and vCO 5.1. I have the vCD plugin installed and working with Orchestrator. I am trying to build a workflow which removes NIC1 (Network adapter 1) from an array of vCloud VMs. I took a copy of the vCloud Director Library Workflow (Remove a NIC) and edited the input parameter vms to be an Array/vCloud:VM. I have amended the scriptable taks so that it loops through the VMs in the array and returns their network cards. It appears that the NICs are being returned as a UID (I returned this to the screen via a System.Log). This UID obviously does not match with what I input to the workflow when executing - I specify "Network adapter 1" and my workflow fails with an error "No primary network connection found; majorErrorCode=400; minorErrorCode=BAD_REQUEST; vendorSpecificErrorCode=null; (Workflow:Remove a NIC 1 / Remove Nic (item0)#22)" Here is the code I am running:
As I mentioned earlier I am a complete newb to vCO\JavaScript and would really appreciate some input\advice. If there is a better method of removing network adapter 1 from an array of vCloud VMs, or if somebody has already developed a workflow for this, I would be most grateful for your help.
Thanks
Try this :
var section = vm.getNetworkConnectionSection();
System.log("Primary card was NIC : " + section.primaryNetworkConnectionIndex);
section.primaryNetworkConnectionIndex = 1;
task = vm.updateSection(section);
Worked here.
moved to the Orchestrator forums (away for the Plugin Development forums)
Welcome.
The way you would typically use vCO would be different :
This way you everage library elements wihtout having to write much code. The warning will give you the error message on each VM so you can check if this was specific to a VM or if you have a mismatch for all of them.
Christophe.
Thanks cdecanini,
I have had made steady progress using the Foreach element as you suggested. I am now passing an array of VMs which are successfully looping and calling the "Remove a NIC". I am trying to remove Network adapter 1, but this is set to the primary NIC so my workflow errors with "No primary network connection found". If I change the primary NIC to nic0 in vCD and run my workflow again, Network adapter 1 successfully removes for all VMs in the array. Do you know how the primary NIC can be changed in vCO via a workflow or JavaScript? I would like to incorporate this into my Remove a NIC workflow so the primary NIC is changed prior to removing Network adapter 1. Your help again would be most appreciated.
Thanks
I will try to have a look at that next week since it was not possible today.
Christophe.
Thanks Christophe that would be much appreciated.
Try this :
var section = vm.getNetworkConnectionSection();
System.log("Primary card was NIC : " + section.primaryNetworkConnectionIndex);
section.primaryNetworkConnectionIndex = 1;
task = vm.updateSection(section);
Worked here.
Thanks Christophe,
I am currently testing this and will let you know how it goes. Your input is very much appreciated.
Worked a treat.
Thanks Christophe