Hi all,
could someone check the following simple workflow where in we want to find the names of vms in vcenter..
schema dia:
javascript code in scriptable task.
please suggest what neds to modified to get name of vms.
Hi,
Here is a working code snippet:
var allVMs = VcPlugin.getAllVirtualMachines();
for each (vm in allVMs) {
System.log("vmname: " + vm.name);
}
Differences compared to your code:
Hi,
Here is a working code snippet:
var allVMs = VcPlugin.getAllVirtualMachines();
for each (vm in allVMs) {
System.log("vmname: " + vm.name);
}
Differences compared to your code:
Thanks for your reply.
Iam checking this code. however from my past experince with powercli "foreach" also works and i belive same should hold good for JAVA script also.
could yu suggest if there any action element to check configured memory and vcpu size of vms .
Perhaps you have Array#forEach in mind? In this case, the code could look like:
var allVMs = VcPlugin.getAllVirtualMachines();
allVMs.forEach(function(vm) {
System.log("vmname: " + vm.name);
})
As for vcpu and memory, their values can be retrieved using vm.config.hardware.numCPU and vm.config.hardware.memoryMB, respectively.
i added few more lines to find mem and cpu of each vm and using api explorer i was able to find .
can yu suggest any way to outthis to text or csv file as we do in powershell.
also for each is correct as yu suggested not sure how foreach works earlier.
i added as above .how to out this to text or csv file.