VMware Cloud Community
mindSHIFT
Contributor
Contributor

Extract Virtual Hardware Details from a vApp Template using non-REST based APIs

We are using both .net SDK for vCloud Director as well as vOrchestrator workflows and API, and running into the following  challenges:

1.     Abstracted Virtual Hardware properties (CPU, RAM, Storage) for a vApp Template seem to be exposed only through the OVF download/extraction. We do not want to instantiate a vApp/VM from a Template just to extract this information. Seems like a waste of computing and storage resources and the time it takes to instantiate. The downloadOVFFile does not seem to work unless the vApp Template has been enabled for download which in itself is a time consuming operation and therefore unacceptable.

2.     The only possibility we see is to go through a complete series of REST based connection and a subsequent call to vApp Template with "/ovf" appended to the URL, and then parsing the XML OVF Descriptor to extract the necessary information, other than, of course, resorting to manual maintenance of the properties elsewhere at the time the template is created, which again is an inferior and a last resort solution.

Is there a better and easy way to get this information?

Please advise.

Reply
0 Kudos
3 Replies
Burke-
VMware Employee
VMware Employee

The following code is from a simple workflow I just wrote in vCO. The Scriptable task takes an array of vCloud:VApp objects as its input. The variable name is "vapps". The code below iterates through each vApp object in the array, retreiving a list of VMs in that vApp, then logs details about that VM to the


System.log("------------------------ vAPP VMs -------------------------------");
var totalVMs = 0;
for each (vapp in vapps){
    System.log("");
    System.log("=======  vApp: "+vapp.name+"  =======");
    var vappVms = vapp.getChildrenVms();
    if (vappVms != null){
        System.log("vApp VM Count: "+vappVms.length);
        totalVMs += vappVms.length;
        for each (vm in vappVms){
            System.log("");
            System.log("=== vm name: "+vm.name+" ===");
            System.log("vm description: "+vm.description);
            System.log("vm id: "+vm.id);
            System.log("vm status: "+vm.status);
            System.log("vm CPUs: "+vm.cpu.noOfCpus);
            System.log("vm Memory (MB): "+vm.memory.memorySize);
            if (vm.networkCards != null){
                System.log("vm NIC Count: "+vm.networkCards.length);
            }
            var vmDisks = vm.disks;
            // Check each disk in the returned array and log their bus type and size
            for each (vmDisk in vmDisks){
                try{
                    System.log("Disk Bus Type: "+vmDisk.hardDiskBusType);
                    System.log("Disk Size (MB): "+vmDisk.hardDiskSize);
                }catch(err){
                    //System.log("Error detected on vmDisk: "+vmDisk+" ("+err+")");
                }
            }
        }
    }   
}
System.log("Total VM Count: "+totalVMs);

The code from above generated the following output in my test environment:

[2011-04-14 16:22:55.049] [I] ------------------------ vAPP VMs -------------------------------
[2011-04-14 16:22:55.049] [I]
[2011-04-14 16:22:55.050] [I] =======  vApp: Win2008test1  =======
[2011-04-14 16:22:55.068] [I] vApp VM Count: 1
[2011-04-14 16:22:55.068] [I]
[2011-04-14 16:22:55.069] [I] === vm name: Win2008-test1 ===
[2011-04-14 16:22:55.069] [I] vm description: Elastic Profile:2008
[2011-04-14 16:22:55.069] [I] vm id: vm-436185217
[2011-04-14 16:22:55.070] [I] vm status: 8
[2011-04-14 16:22:55.248] [I] vm CPUs: 1
[2011-04-14 16:22:55.249] [I] vm Memory (MB): 2048
[2011-04-14 16:22:55.249] [I] vm NIC Count: 1
[2011-04-14 16:22:55.251] [I] Disk Bus Type: lsilogicsas
[2011-04-14 16:22:55.251] [I] Disk Size (MB): 12288
[2011-04-14 16:22:55.252] [I]
[2011-04-14 16:22:55.252] [I] =======  vApp: transferTest  =======
[2011-04-14 16:22:55.270] [I] vApp VM Count: 1
[2011-04-14 16:22:55.271] [I]
[2011-04-14 16:22:55.271] [I] === vm name: testTransfer ===
[2011-04-14 16:22:55.271] [I] vm description:
[2011-04-14 16:22:55.272] [I] vm id: vm-871209103
[2011-04-14 16:22:55.272] [I] vm status: 8
[2011-04-14 16:22:55.494] [I] vm CPUs: 1
[2011-04-14 16:22:55.494] [I] vm Memory (MB): 512
[2011-04-14 16:22:55.494] [I] vm NIC Count: 1
[2011-04-14 16:22:55.496] [I] Disk Bus Type: lsilogicsas
[2011-04-14 16:22:55.496] [I] Disk Size (MB): 20
[2011-04-14 16:22:55.497] [I]
[2011-04-14 16:22:55.497] [I] =======  vApp: Multi-VMs  =======
[2011-04-14 16:22:55.546] [I] vApp VM Count: 3
[2011-04-14 16:22:55.547] [I]
[2011-04-14 16:22:55.547] [I] === vm name: LLSP ===
[2011-04-14 16:22:55.547] [I] vm description:
[2011-04-14 16:22:55.548] [I] vm id: vm-1287538996
[2011-04-14 16:22:55.548] [I] vm status: 8
[2011-04-14 16:22:55.818] [I] vm CPUs: 1
[2011-04-14 16:22:55.818] [I] vm Memory (MB): 512
[2011-04-14 16:22:55.819] [I] vm NIC Count: 1
[2011-04-14 16:22:55.820] [I] Disk Bus Type: lsilogic
[2011-04-14 16:22:55.820] [I] Disk Size (MB): 1024
[2011-04-14 16:22:55.821] [I]
[2011-04-14 16:22:55.821] [I] === vm name: LLSP-2 ===
[2011-04-14 16:22:55.821] [I] vm description:
[2011-04-14 16:22:55.822] [I] vm id: vm-1344478521
[2011-04-14 16:22:55.822] [I] vm status: 8
[2011-04-14 16:22:56.145] [I] vm CPUs: 1
[2011-04-14 16:22:56.146] [I] vm Memory (MB): 512
[2011-04-14 16:22:56.147] [I] vm NIC Count: 1
[2011-04-14 16:22:56.148] [I] Disk Bus Type: lsilogic
[2011-04-14 16:22:56.148] [I] Disk Size (MB): 1024
[2011-04-14 16:22:56.149] [I] Disk Bus Type: lsilogic
[2011-04-14 16:22:56.149] [I] Disk Size (MB): 4096
[2011-04-14 16:22:56.150] [I]
[2011-04-14 16:22:56.150] [I] === vm name: LLSP-1 ===
[2011-04-14 16:22:56.150] [I] vm description:
[2011-04-14 16:22:56.151] [I] vm id: vm-414915561
[2011-04-14 16:22:56.151] [I] vm status: 8
[2011-04-14 16:22:56.534] [I] vm CPUs: 1
[2011-04-14 16:22:56.534] [I] vm Memory (MB): 512
[2011-04-14 16:22:56.536] [I] vm NIC Count: 2
[2011-04-14 16:22:56.537] [I] Disk Bus Type: lsilogic
[2011-04-14 16:22:56.537] [I] Disk Size (MB): 1024
[2011-04-14 16:22:56.538] [I] Disk Bus Type: lsilogic
[2011-04-14 16:22:56.538] [I] Disk Size (MB): 2048
[2011-04-14 16:22:56.539] [I] Disk Bus Type: buslogic
[2011-04-14 16:22:56.540] [I] Disk Size (MB): 4096
[2011-04-14 16:22:56.540] [I]
[2011-04-14 16:22:56.541] [I] =======  vApp: XP-Pro-TESTApp-2011-03-09-02:05:34-BCK  =======
[2011-04-14 16:22:56.566] [I] vApp VM Count: 1
[2011-04-14 16:22:56.566] [I]
[2011-04-14 16:22:56.567] [I] === vm name: XP-Pro ===
[2011-04-14 16:22:56.567] [I] vm description: Windows XP Professional SP2
[2011-04-14 16:22:56.568] [I] vm id: vm-2145020091
[2011-04-14 16:22:56.568] [I] vm status: 8
[2011-04-14 16:22:56.805] [I] vm CPUs: 1
[2011-04-14 16:22:56.805] [I] vm Memory (MB): 256
[2011-04-14 16:22:56.806] [I] vm NIC Count: 1
[2011-04-14 16:22:56.813] [I] Disk Bus Type: buslogic
[2011-04-14 16:22:56.813] [I] Disk Size (MB): 1536
[2011-04-14 16:22:56.814] [I] Total VM Count: 6

- Hope you find this helpful Smiley Wink

http://www.vcoteam.info / http://blogs.vmware.com/orchestrator/

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
mindSHIFT
Contributor
Contributor

Thank you, Burke. I appreciate the response. However, in the situation I explained, we do not have a vApp yet, only a "vApp Template". How can we retrieve the same info from the "vApp Template" without instantiating it into a vApp.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee

lol...oops... Good question indeed! I'm not sure if that is currently possible. I'll keep poking around and see if I come up with anything.. in the meantime, I hope we hear from someone else with a bright idea Smiley Wink

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos