Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Remove a NIC from multiple vCloud VMs

$
0
0

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:

 

 

if (vm.Status != VclVMStatus.POWERED_OFF.value) {
throw "VM is not powered off";
}
var found = false;
var len=vms.length;
for (var i=0; i < len; i++ )
{
var VM = vms[i];
var nics = VM.getNetworkCards();
System.log(nics);
var newNics = new Array();
for (i = 0; i < nics.length; i++) {
if (nics[i].itemResource.elementName.value != nicName) {
newNics.push(nics[i]);
} else {
found = true;
}
}
if (!found) {
throw "Invalid NIC name";
}
task = VM.updateNetworkCards(newNics);
}

 

 

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



Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>