Search in sources :

Example 21 with StorageDomain

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);
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 22 with StorageDomain

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;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain)

Example 23 with StorageDomain

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();
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Example 24 with StorageDomain

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;
}
Also used : FormatStorageDomainVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.FormatStorageDomainVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 25 with StorageDomain

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;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS)

Aggregations

StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)345 ArrayList (java.util.ArrayList)108 Guid (org.ovirt.engine.core.compat.Guid)103 Test (org.junit.Test)91 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)75 List (java.util.List)58 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)58 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)49 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)47 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)46 QueryType (org.ovirt.engine.core.common.queries.QueryType)43 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)42 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)41 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)41 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)40 VDS (org.ovirt.engine.core.common.businessentities.VDS)39 Frontend (org.ovirt.engine.ui.frontend.Frontend)39 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)36 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)36 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)35