første xml update
[virt-orchestrator.git] / vFLOWER / content / Actions / com.vmware.library.vc.cluster / getAllClusterComputeResourceForVimHost.action.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <dunes-script-module name="getAllClusterComputeResourceForVimHost" result-type="Array/VC:ClusterComputeResource" api-version="3.1.0" id="423f39fc-fcf2-46cc-9fff-8e2ef86baf91" version="0.3.0" allowed-operations="fv">
3     <description>Get all the ClusterComputeResource in a VimHost</description>
4
5     <param n="vimHost" t="VC:SdkConnection"/>
6
7     <script encoded="false">
8 var result = new Array();
9 findComputeResourceInDataCenterFolder(vimHost.rootFolder);
10 return result;
11
12
13 function findComputeResourceInDataCenterFolder(hostFolder) {
14         for each (var dc in hostFolder.childEntity) {
15                 if (dc instanceof VcDatacenter) {
16                         findComputeResourceInDataCenter(dc);
17                 }
18         }
19         
20         for each (var folder in hostFolder.childEntity) {
21                 if (folder instanceof VcFolder) {
22                         findComputeResourceInDataCenterFolder(folder);
23                 }
24         }
25 }
26
27 function findComputeResourceInDataCenter (datacenter) {
28         findComputeResourceInHostFolder(datacenter.hostFolder);
29 }
30
31 function findComputeResourceInHostFolder (hostFolder) {
32         for each (var item in hostFolder.childEntity) {
33                 if (item instanceof VcClusterComputeResource) {
34                         result.push(item);
35                 }
36         }
37                 
38         for each (var folder in hostFolder.childEntity) {
39                 if (folder instanceof VcFolder) {
40                         findComputeResourceInHostFolder(folder);
41                 }
42         }
43 }
44     </script>
45 </dunes-script-module>