I would like to inventory a single VM's attributes, such as CPU, Memory, Disk, Network Adapter, IP Address using JavaScript. The following script will grab the VM object and display some of the attributes, but doesn't have the attributes I'm looking for.
var getVM = "LAB-TEST-VM1";
var strVMArray = System.getModule("com.vmware.library.vc.vm").getAllVMsMatchingRegexp(getVM);
var strVM=strVMArray[0];
// vcVirtualMachine attributes
System.log("Variable: " + strVM);
System.log("Computer: " + strVM.name);
System.log("Datastore: " + strVM.datastore);
System.log("vCenter Host: " + strVM.vimHost);
System.log("VM ID: " + strVM.id);
The above script produces the following output:
[2015-05-18 13:01:08.135] [I] Variable: DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.vmo.plugin.vi4.model.VimVirtualMachine] -- VALUE : VirtualMachine<vm-29806>'LAB-TEST-VM1'
[2015-05-18 13:01:08.135] [I] Computer: LAB-TEST-VM1
[2015-05-18 13:01:08.136] [I] Datastore: DynamicWrapper (Instance) : [VcDatastore]-[class com.vmware.vmo.plugin.vi4.model.VimDatastore] -- VALUE : Datastore<datastore-219>'HQ-LAB-VMFS2'
[2015-05-18 13:01:08.136] [I] vCenter Host: DynamicWrapper (Instance) : [VcSdkConnection]-[class com.vmware.vmo.plugin.vi4.VimHost] -- VALUE : hq-dev-vc01.acme.local
[2015-05-18 13:01:08.136] [I] VM ID: vm-29806
Q1. How can I obtain the attributes I'm looking for (CPU, RAM, Network Adapter, IP)?
Q2. How do I display only the value in the output displayed above, not the DynamicWrapper info?