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

Script to get Datacenter Tree

$
0
0

Hi All,

 

I want to return full tree of the Datacenters through scriptable task.

example:

Datacenter1:

     Cluster1:

          Host1:

          Host2:

          VM1:

          VM2

 

When i try to enumerate Datacenter to get Cluster it fails. Can anyone can help on this?

 

MyScript:

 

var myDatacenters =  VcPlugin.getAllDatacenters();

for each (i=0;i<myDatacenters.length;i++)

{

 

    for each ( myCluster in myDatacenters[i].cluster ) 

    { 

 

        System.debug(cluster.name);

        for each ( myHostSystem in myCluster.host ) 

        { 

            System.debug(myHostSystem.name);

            for each ( myVMs in myHostSystem.vm ) 

            {

                if(myVMs.isTemplate==true)

                {

                    System.debug(myVMs.name);

                }

       

            } 

        }

 

    for each ( myDatastore in myCluster.datastore ) 

    { 

        System.debug(myDatastore.name);

         //mytotalDatastoreCapacity += myVcDatastore.summary.capacity; 

         //mytotalDatastoreFreeSpace += myVcDatastore.summary.freeSpace;

     

    }

 

    }

}


Viewing all articles
Browse latest Browse all 6251

Trending Articles



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