use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class DisconnectHostFromStoragePoolServersCommand method disconnectStorageByType.
private void disconnectStorageByType(StorageType storageType, List<StorageServerConnections> connections) {
/*
* HE SD should only be connected/disconnected by the HE tools, not
* by the engine.
*/
Set<String> heIds = storageDomainDao.getHostedEngineStorageDomainIds().stream().map(storageDomainDao::get).map(StorageDomain::getStorageStaticData).map(StorageDomainStatic::getStorage).collect(Collectors.toSet());
connections = connections.stream().filter(c -> !heIds.contains(c.getId())).collect(Collectors.toList());
storageHelperDirector.getItem(storageType).prepareDisconnectHostFromStoragePoolServers(getParameters(), connections);
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.DisconnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), getStoragePool().getId(), storageType, connections));
setSucceeded(vdsReturnValue.getSucceeded());
if (!vdsReturnValue.getSucceeded()) {
storageHelperDirector.getItem(storageType).isConnectSucceeded((HashMap<String, String>) vdsReturnValue.getReturnValue(), connections);
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class ReconstructMasterDomainCommand method connectVdsToNewMaster.
/**
* performs any connect related operations if needed before attempting
* to connect/refresh pool information.
*/
private boolean connectVdsToNewMaster(VDS vds) {
StorageDomain masterDomain = getNewMasterStorageDomain();
if (vds.getId().equals(getVds().getId()) || storageHelperDirector.getItem(masterDomain.getStorageType()).connectStorageToDomainByVdsId(masterDomain, vds.getId())) {
return true;
}
log.error("Error while trying connect host {} to the needed storage server during the reinitialization" + " of Data Center '{}'", vds.getId(), getStoragePool().getId());
return false;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class RecoveryStoragePoolCommand method validate.
@Override
protected boolean validate() {
StoragePoolValidator storagePoolValidator = createStoragePoolValidator();
if (!validate(storagePoolValidator.exists()) || !validate(new StorageDomainValidator(getStorageDomain()).isInProcess()) || !validate(storagePoolValidator.isAnyDomainInProcess()) || !validate(storagePoolValidator.isNotInStatus(StoragePoolStatus.Uninitialized))) {
return false;
}
if (getStorageDomain() != null && getStorageDomain().getStatus() == StorageDomainStatus.Active) {
addStorageDomainStatusIllegalMessage();
return false;
}
if (electNewMaster() != null) {
return failValidation(EngineMessage.STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN);
}
StorageDomain domain = loadTargetedMasterDomain();
if (domain.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL);
}
return initializeVds();
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain 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;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class RemoveStoragePoolCommand method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
StoragePoolValidator validator = createStoragePoolValidator();
if (!validate(validator.exists())) {
return false;
}
if (!validator.isNotInStatus(StoragePoolStatus.Up).isValid()) {
return failValidation(EngineMessage.ERROR_CANNOT_REMOVE_ACTIVE_STORAGE_POOL);
}
if (!validator.isInStatus(StoragePoolStatus.Uninitialized).isValid() && !getParameters().isForceDelete() && !initializeVds()) {
return false;
}
final List<StorageDomain> poolDomains = storageDomainDao.getAllForStoragePool(getStoragePool().getId());
if (!validateDomainsInMaintenance(poolDomains)) {
return false;
}
if (!getParameters().isForceDelete()) {
if (poolDomains.size() > 1) {
return failValidation(EngineMessage.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS);
}
if (!poolDomains.isEmpty() && !canDetachStorageDomainWithVmsAndDisks(poolDomains.get(0))) {
return false;
}
} else {
List<VDS> poolHosts = vdsDao.getAllForStoragePool(getParameters().getStoragePoolId());
sharedLocks = new HashMap<>();
for (VDS host : poolHosts) {
sharedLocks.put(host.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VDS, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
}
if (!poolHosts.isEmpty() && acquireLockInternal()) {
for (VDS host : poolHosts) {
if (host.getStatus() != VDSStatus.Maintenance) {
return failValidation(EngineMessage.ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE);
}
}
}
}
return true;
}
Aggregations