Search in sources :

Example 31 with StoragePoolIsoMap

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

the class DeactivateStorageDomainCommand method proceedStorageDomainTreatmentByDomainType.

/**
 * In case of master domain this method decide if to move master to other domain or move pool to maintenance (since
 * there is no master domain)
 *
 * @param newMaster The selected new master domain
 * @param lockNewMaster If true the new master domain will be locked
 * @return true if newMaster is the last master
 */
protected boolean proceedStorageDomainTreatmentByDomainType(final StorageDomain newMaster, final boolean lockNewMaster) {
    if (newMaster == null) {
        return true;
    }
    newMaster.getStorageStaticData().setLastTimeUsedAsMaster(System.currentTimeMillis());
    if (newMaster.getStorageDomainType() != StorageDomainType.Master) {
        executeInNewTransaction(() -> {
            StoragePoolIsoMap newMasterMap = newMaster.getStoragePoolIsoMapData();
            getCompensationContext().snapshotEntityUpdated(newMaster.getStorageStaticData());
            newMaster.setStorageDomainType(StorageDomainType.Master);
            if (lockNewMaster) {
                newMasterMap.setStatus(StorageDomainStatus.Unknown);
                getCompensationContext().snapshotEntityStatus(newMasterMap);
                newMaster.setStatus(StorageDomainStatus.Locked);
                storagePoolIsoMapDao.updateStatus(newMasterMap.getId(), newMasterMap.getStatus());
            }
            updateStorageDomainStaticData(newMaster.getStorageStaticData());
            getCompensationContext().snapshotEntityUpdated(getStorageDomain().getStorageStaticData());
            getStorageDomain().setStorageDomainType(StorageDomainType.Data);
            updateStorageDomainStaticData(getStorageDomain().getStorageStaticData());
            getCompensationContext().stateChanged();
            return null;
        });
    } else {
        updateStorageDomainStaticData(newMaster.getStorageStaticData());
    }
    updateStoragePoolMasterDomainVersionInDiffTransaction();
    return false;
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 32 with StoragePoolIsoMap

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

the class StorageDomainToPoolRelationValidatorTest method testAttachFailDomainAlreadyInPool.

@Test
public void testAttachFailDomainAlreadyInPool() {
    when(storagePoolIsoMapDao.getAllForStorage(storageDomain.getId())).thenReturn(Collections.singletonList(new StoragePoolIsoMap()));
    ValidationResult attachedDomainInsertionResult = validator.validateDomainCanBeAttachedToPool();
    assertThat(attachedDomainInsertionResult, failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL));
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 33 with StoragePoolIsoMap

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

the class IrsProxy method handleMonitoredDomainsForHost.

/**
 * Provides handling for the domains that are monitored by the given host.
 * @return map between the domain id and the reason for domains that
 * the host reporting is problematic for.
 */
private Map<Guid, DomainMonitoringResult> handleMonitoredDomainsForHost(final Guid vdsId, final String vdsName, final ArrayList<VDSDomainsData> data, Collection<Guid> monitoredDomains) {
    Map<Guid, DomainMonitoringResult> domainsProblematicReportInfo = new HashMap<>();
    // build a list of all domains in pool
    // which are in status Active or Unknown
    Set<Guid> activeDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Active));
    Set<Guid> unknownDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Unknown));
    Set<Guid> inActiveDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Inactive));
    // visible by the host.
    for (Guid tempDomainId : activeDomainsInPool) {
        if (!monitoredDomains.contains(tempDomainId)) {
            domainsProblematicReportInfo.put(tempDomainId, DomainMonitoringResult.NOT_REPORTED);
        }
    }
    for (Guid tempDomainId : unknownDomainsInPool) {
        if (!monitoredDomains.contains(tempDomainId)) {
            domainsProblematicReportInfo.put(tempDomainId, DomainMonitoringResult.NOT_REPORTED);
        }
    }
    Collection<Guid> storageDomainsToSync = new LinkedList<>();
    // Unknown domains in pool
    for (VDSDomainsData tempData : data) {
        StorageDomainStatic storageDomain = storageDomainStaticDao.get(tempData.getDomainId());
        if (activeDomainsInPool.contains(tempData.getDomainId()) || unknownDomainsInPool.contains(tempData.getDomainId())) {
            DomainMonitoringResult domainMonitoringResult = analyzeDomainReport(tempData, false);
            if (domainMonitoringResult.invalidAndActual()) {
                domainsProblematicReportInfo.put(tempData.getDomainId(), domainMonitoringResult);
            } else if (domainMonitoringResult.actual() && tempData.getDelay() > Config.<Double>getValue(ConfigValues.MaxStorageVdsDelayCheckSec)) {
                logDelayedDomain(vdsName, storageDomain.getName(), tempData.getDelay());
            }
        } else if (inActiveDomainsInPool.contains(tempData.getDomainId()) && analyzeDomainReport(tempData, false).validAndActual()) {
            log.warn("Storage Domain '{}' was reported by Host '{}' as Active in Pool '{}', moving to active status", getDomainIdTuple(tempData.getDomainId()), vdsName, storagePoolId);
            StoragePoolIsoMap map = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(tempData.getDomainId(), storagePoolId));
            map.setStatus(StorageDomainStatus.Active);
            storagePoolIsoMapDao.update(map);
            if (storageDomain.getStorageType().isBlockDomain()) {
                storageDomainsToSync.add(storageDomain.getId());
            }
        }
    }
    // For block domains, synchronize LUN details comprising the storage domain with the DB
    if (!storageDomainsToSync.isEmpty()) {
        getEventListener().syncStorageDomainsLuns(vdsId, storageDomainsToSync);
    }
    return domainsProblematicReportInfo;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) Guid(org.ovirt.engine.core.compat.Guid) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 34 with StoragePoolIsoMap

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

the class IrsProxy method connectStoragePool.

private void connectStoragePool(VDS vds, StoragePool storagePool) {
    Guid masterDomainId = storageDomainDao.getMasterStorageDomainIdForPool(storagePoolId);
    List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    VDSReturnValue connectResult = resourceManager.runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomainId, storagePoolIsoMap));
    if (!connectResult.getSucceeded() && connectResult.getExceptionObject() instanceof IRSNoMasterDomainException) {
        throw connectResult.getExceptionObject();
    } else if (!connectResult.getSucceeded()) {
        // failover
        throw new IRSNonOperationalException("Could not connect host to Data Center(Storage issue)");
    }
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 35 with StoragePoolIsoMap

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

the class StorageDomainCommandBase method setStorageDomainStatus.

protected void setStorageDomainStatus(StorageDomainStatus status, CompensationContext context) {
    if (getStorageDomain() != null && getStorageDomain().getStoragePoolId() != null) {
        StoragePoolIsoMap map = getStorageDomain().getStoragePoolIsoMapData();
        if (context != null) {
            context.snapshotEntityStatus(map);
        }
        getStorageDomain().setStatus(status);
        storagePoolIsoMapDao.updateStatus(map.getId(), status);
    }
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Aggregations

StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)40 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15 Guid (org.ovirt.engine.core.compat.Guid)14 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)9 Test (org.junit.Test)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 ArrayList (java.util.ArrayList)6 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Pair (org.ovirt.engine.core.common.utils.Pair)4 HashMap (java.util.HashMap)3 List (java.util.List)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Event (org.ovirt.engine.core.common.eventqueue.Event)3 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)3 ConnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)3