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

Still not getting correct datastore

$
0
0

I have this script below that is still not returning the correct datastore. It returns HDS-ESXi-UCS-0403 instead of HDS-ESXi-UCS-0408 which has more free space. They are both attached to the Non-Production cluster.

When I look in vSphere I see 0403 as Capacity 2.50TB and Free as 1.10TB and I see 0408 as Capacity 2.50TB and Free as 1.75TB

 

bestFreeSpace = 0;

datastore = null;

dsCapacity = null;

dsFreeSpace = null;

percentFree = null;

Cluster = VcPlugin.getAllClusterComputeResources(null, "Non-Production")[0];

 

for(i in Cluster.datastore){     

     selectedDatastore = Cluster.datastore[i];     

           if ( selectedDatastore.name.toLowerCase().indexOf("hds-esxi-ucs-04") == 0 ) {          

               dsCapacity = selectedDatastore.summary.capacity / 1024 / 1024 / 1024;          

               dsFreeSpace = selectedDatastore.summary.freeSpace / 1024 / 1024 / 1024;          

               percentFree = dsFreeSpace / dsCapacity * 100;                      

                   

               if ( percentFree > 25 ){                                

                     if ( dsFreeSpace > bestFreeSpace ) {                    

                              bestFreeSpace = dsFreeSpace;                     
                              datastore = selectedDatastore;               

                       }          

               }     

           }

}

 

if ( datastore==null ) {       throw "No datastore found which has over 25% free space!";  }


Viewing all articles
Browse latest Browse all 6251

Trending Articles



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