Search in sources :

Example 11 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class AbstractVmProviderProxy method chooseDcForCheckingIfGetNamesFromExternalProviderSupported.

private void chooseDcForCheckingIfGetNamesFromExternalProviderSupported() {
    Version chosenDataCenterVersion = null;
    Guid chosenDataCenterId = provider.getAdditionalProperties().getStoragePoolId();
    if (chosenDataCenterId == null) {
        // find data center with highest version
        for (StoragePool sp : storagePoolDao.getAllByStatus(StoragePoolStatus.Up)) {
            if (chosenDataCenterVersion == null || chosenDataCenterVersion.less(sp.getCompatibilityVersion())) {
                chosenDataCenterVersion = sp.getCompatibilityVersion();
                chosenDataCenterId = sp.getId();
            }
        }
        provider.getAdditionalProperties().setStoragePoolId(chosenDataCenterId);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.core.compat.Version) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class AddEmptyStoragePoolCommand method setDataCenterDetails.

private void setDataCenterDetails() {
    StoragePool dc = getParameters().getStoragePool();
    setCompatibilityVersion(dc.getCompatibilityVersion().toString());
    setQuotaEnforcementType(dc.getQuotaEnforcementType().name());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Example 13 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class AddStoragePoolWithStoragesCommand method executeCommand.

@Override
protected void executeCommand() {
    if (updateStorageDomainsInDb()) {
        // setting storage pool status to maintenance
        StoragePool storagePool = getStoragePool();
        getCompensationContext().snapshotEntity(storagePool);
        TransactionSupport.executeInNewTransaction(() -> {
            getStoragePool().setStatus(StoragePoolStatus.Maintenance);
            getStoragePool().setStoragePoolFormatType(masterStorageDomain.getStorageFormat());
            storagePoolDao.update(getStoragePool());
            getCompensationContext().stateChanged();
            StoragePoolStatusHandler.poolStatusChanged(getStoragePool().getId(), getStoragePool().getStatus());
            return null;
        });
        // Following code performs only read operations, therefore no need for new transaction
        boolean result = false;
        // Once we create a storage pool with multiple hosts, the engine should connect all
        // the hosts in the storage pool,
        // since the engine picks a random host to fetch all the unregistered disks.
        boolean isStoragePoolCreated = false;
        retVal = null;
        for (VDS vds : getAllRunningVdssInPool()) {
            setVds(vds);
            for (Guid storageDomainId : getParameters().getStorages()) {
                // now the domain should have the mapping
                // with the pool in db
                StorageDomain storageDomain = storageDomainDao.getForStoragePool(storageDomainId, getStoragePool().getId());
                storageHelperDirector.getItem(storageDomain.getStorageType()).connectStorageToDomainByVdsId(storageDomain, getVds().getId());
            }
            if (!isStoragePoolCreated) {
                // but didn't throw exception
                if (!cleanDirtyMetaDataIfNeeded()) {
                    result = false;
                } else {
                    retVal = addStoragePoolInIrs();
                    if (!retVal.getSucceeded() && retVal.getVdsError().getCode() == EngineError.StorageDomainAccessError) {
                        log.warn("Error creating storage pool on vds '{}' - continuing", vds.getName());
                        continue;
                    }
                    result = retVal.getSucceeded();
                }
                isStoragePoolCreated = true;
            }
        }
        setSucceeded(result);
        if (!result) {
            if (retVal != null && retVal.getVdsError().getCode() != null) {
                throw new EngineException(retVal.getVdsError().getCode(), retVal.getVdsError().getMessage());
            } else {
                // command
                throw new EngineException(EngineError.ENGINE_ERROR_CREATING_STORAGE_POOL);
            }
        }
        registerOvfStoreDisks();
    }
    // Create pool phase completed, no rollback is needed here, so compensation information needs to be cleared!
    TransactionSupport.executeInNewTransaction(() -> {
        getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
        return null;
    });
    freeLock();
    // if create succeeded activate
    if (getSucceeded()) {
        activateStorageDomains();
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid)

Example 14 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class RemoveStoragePoolCommand method connectAllHostToPoolAndDomain.

/**
 * @param masterDomain
 *            Connect all hosts to the pool and to the domains
 */
protected void connectAllHostToPoolAndDomain(final StorageDomain masterDomain) {
    final List<VDS> vdsList = getAllRunningVdssInPool();
    final StoragePool storagePool = getStoragePool();
    SynchronizeNumberOfAsyncOperations sync = new SynchronizeNumberOfAsyncOperations(vdsList.size(), null, new ActivateDeactivateSingleAsyncOperationFactory() {

        @Override
        public ISingleAsyncOperation createSingleAsyncOperation() {
            return Injector.injectMembers(new ConnectVDSToPoolAndDomains(vdsList, masterDomain, storagePool));
        }

        @Override
        public void initialize(List parameters) {
        // no need to initilalize params
        }
    });
    sync.execute();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) SynchronizeNumberOfAsyncOperations(org.ovirt.engine.core.utils.SynchronizeNumberOfAsyncOperations) ISingleAsyncOperation(org.ovirt.engine.core.utils.ISingleAsyncOperation) List(java.util.List)

Example 15 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class GetAvailableStoragePoolVersionsQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    if (getParameters().getId() != null) {
        ArrayList<Version> result = new ArrayList<>();
        StoragePool storagePool = storagePoolDao.get(getParameters().getId());
        if (storagePool != null) {
            List<Cluster> clusters = clusterDao.getAllForStoragePool(storagePool.getId(), getUserID(), getParameters().isFiltered());
            for (Version supportedVer : Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)) {
                // decrease version
                if (supportedVer.compareTo(storagePool.getCompatibilityVersion()) < 0) {
                    continue;
                }
                boolean versionOk = true;
                // check all clusters are not grater than this ver
                for (Cluster cluster : clusters) {
                    if (supportedVer.compareTo(cluster.getCompatibilityVersion()) > 0) {
                        versionOk = false;
                        break;
                    }
                }
                if (versionOk) {
                    result.add(supportedVer);
                }
            }
        }
        getQueryReturnValue().setReturnValue(result);
    } else {
        getQueryReturnValue().setReturnValue(new ArrayList<>(Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)));
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.core.compat.Version) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HashSet(java.util.HashSet)

Aggregations

StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)239 Guid (org.ovirt.engine.core.compat.Guid)83 ArrayList (java.util.ArrayList)78 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)60 Test (org.junit.Test)59 List (java.util.List)46 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)34 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)31 QueryType (org.ovirt.engine.core.common.queries.QueryType)31 Frontend (org.ovirt.engine.ui.frontend.Frontend)31 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)28 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)28 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)27 Linq (org.ovirt.engine.ui.uicommonweb.Linq)26 Arrays (java.util.Arrays)25 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)25