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

For over an array of VMs?

$
0
0

Hoping someone would throw up a quick example script for something I'm trying to do.  I've instantiated a vApp (vCloud Director 5.5) and called the action to get an array of the VMs in that vApp.  No problem so far.  What I want to do is iterate over that array of VMs and depending on the VM name change the hostname of the VM before I power it up (so it's customized when it powers on).  I've written a script, pulling in an attribute (vappVMNames) that contains the previously mentioned array:

for each (var vm in vappVMNames){

if (vm == "VMname1"){

taskResult = System.getModule("com.vmware.library.vCloud.vApp.VM.Guest").changeComputerName(vm."newhost1");

}

else if (vm == "VMname2"){

taskResult = System.getModule("com.vmware.library.vCloud.vApp.VM.Guest").changeComputerName(vm."newhost2");

}

else if (vm == "VMname3"){

taskResult = System.getModule("com.vmware.library.vCloud.vApp.VM.Guest").changeComputerName(vm."newhost3");

}

}

Basically I looked at the existing workflow for changing a single vApp VM hostname (it contains a couple of scripts and a wait...I've attempted a similar change for the other script which updates the vm) and attempted to modify it to handle the array of VMs.  Can anyone offer some guidance here?  The ForEach workflow doesn't seem like it'd fit my needs at I'm trying to change each VM to a distinct hostname based on its VM name (it'd be a no-brainer if I wanted all of them to have the same hostname).

 

TIA!


Viewing all articles
Browse latest Browse all 6251

Trending Articles



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