How to Find Available Resources in Each Host

  • The CPU capacity, Bandwidth and storage are referred as resources. These resources decreases when each VM allocated to a Host. The methods to get the available/remaining resources in a host:
  • Let “host” be the Host object.
    // get Host list from the datacenter.
    getHostList();
    int size = getHostList().size();
    for(int i=0; i<size; i++)
    {
    host = getHostList().get(j); // get each Host from the list
    int hid = host.getId();
    double mip = host.getAvailableMips(); //retrieves the available Cpu capacity
    long band = host.getBw(); //retrieves the available Bandwidth capacity
    long st = host.getStorage(); //retrieves the available Storage capacity
    }