use of org.ovirt.engine.core.common.vdscommands.FormatStorageDomainVDSCommandParameters in project ovirt-engine by oVirt.
the class RemoveStoragePoolCommand method regularRemoveStorageDomains.
private boolean regularRemoveStorageDomains(List<StorageDomain> storageDomains) {
boolean retVal = true;
final StorageDomain masterDomain = storageDomains.stream().filter(s -> s.getStorageDomainType() == StorageDomainType.Master).findFirst().orElse(null);
lockStorageDomain(masterDomain);
// destroying a pool is an SPM action. We need to connect all hosts
// to the pool. Later on, during spm election, one of the hosts will
// lock the pool
// and the spm status will be FREE. Only then we can invoke the
// destroy verb.
connectAllHostToPoolAndDomain(masterDomain);
List<VDS> vdss = getAllRunningVdssInPool();
for (StorageDomain storageDomain : storageDomains) {
if (storageDomain.getStorageDomainType() != StorageDomainType.Master) {
if (!removeDomainFromPool(storageDomain, vdss.get(0))) {
log.error("Unable to detach storage domain '{}' '{}'", storageDomain.getStorageName(), storageDomain.getId());
retVal = false;
}
}
}
masterDomainDetachWithDestroyPool(masterDomain);
runSynchronizeOperation(new DisconnectStoragePoolAsyncOperationFactory());
setSucceeded(true);
if (!getStoragePool().isLocal() || !masterDomain.isLocal()) {
for (VDS vds : vdss) {
storageHelperDirector.getItem(masterDomain.getStorageType()).disconnectStorageFromDomainByVdsId(masterDomain, vds.getId());
}
} else {
try {
runVdsCommand(VDSCommandType.FormatStorageDomain, new FormatStorageDomainVDSCommandParameters(vdss.get(0).getId(), masterDomain.getId()));
} catch (EngineException e) {
// Do nothing, exception already printed at logs
}
storageHelperDirector.getItem(masterDomain.getStorageType()).disconnectStorageFromDomainByVdsId(masterDomain, vdss.get(0).getId());
removeDomainFromDb(masterDomain);
}
return retVal;
}
Aggregations