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);
}
}
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());
}
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();
}
}
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();
}
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)));
}
}
Aggregations