String groupName, String nodeName, List<DiskSpec> badDisks) {
ClusterCreate spec = configMgr.getClusterConfig(clusterName);
NodeEntity nodeEntity =
clusterEntityMgr.findByName(clusterName, groupName, nodeName);
VcHost targetHost = VcResourceUtils.findHost(nodeEntity.getHostName());
List<VcDatastore> validDatastores =
filterDatastores(targetHost, spec, groupName);
// initialize env for placement algorithm
int totalSizeInGB = 0;
Map<AbstractDatastore, Integer> usage =
new HashMap<AbstractDatastore, Integer>(validDatastores.size());
List<AbstractDatastore> pools =
new ArrayList<AbstractDatastore>(validDatastores.size());
for (VcDatastore ds : validDatastores) {
totalSizeInGB += ds.getFreeSpace() >> 30;
AbstractDatastore ads =
new AbstractDatastore(ds.getName(),
(int) (ds.getFreeSpace() >> 30));
pools.add(ads);
usage.put(ads, 0);
}
int requiredSizeInGB = 0;
for (DiskSpec disk : badDisks) {
requiredSizeInGB += disk.getSize();
}
if (totalSizeInGB < requiredSizeInGB) {
throw ClusterHealServiceException.NOT_ENOUGH_STORAGE(nodeName,
"" + requiredSizeInGB + " GB storage is required on host "
+ targetHost.getName() + ", but only " + totalSizeInGB
+ " GB available");
}
List<DiskEntity> goodDisks = clusterEntityMgr.getDisks(nodeName);