Search in sources :

Example 21 with StoragePoolIsoMap

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

the class InitVdsOnUpCommand method runConnectHostToPoolEvent.

private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) {
    EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
    StoragePool storagePool = storagePoolDao.get(storagePoolId);
    StorageDomain masterDomain = storageDomainDao.getStorageDomains(storagePoolId, StorageDomainType.Master).get(0);
    List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == StorageDomainStatus.Inactive || masterDomain.getStatus() == StorageDomainStatus.Unknown;
    VDSError error = null;
    try {
        VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomain.getId(), storagePoolIsoMap));
        if (!vdsReturnValue.getSucceeded()) {
            error = vdsReturnValue.getVdsError();
        }
    } catch (EngineException e) {
        error = e.getVdsError();
    }
    if (error != null) {
        if (error.getCode() != EngineError.CannotConnectMultiplePools && masterDomainInactiveOrUnknown) {
            log.info("Could not connect host '{}' to pool '{}', as the master domain is in inactive/unknown" + " status - not failing the operation", vds.getName(), storagePool.getName());
        } else {
            log.error("Could not connect host '{}' to pool '{}': {}", vds.getName(), storagePool.getName(), error.getMessage());
            result.setSuccess(false);
        }
    }
    if (result.isSuccess()) {
        Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown, storagePool);
        result.setSuccess(vdsStatsResults.getFirst());
        if (!result.isSuccess()) {
            result.setResultData(vdsStatsResults.getSecond());
            auditLogDirector.log(this, AuditLogType.VDS_STORAGE_VDS_STATS_FAILED);
        }
    }
    return result;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDSError(org.ovirt.engine.core.common.errors.VDSError) List(java.util.List) ArrayList(java.util.ArrayList) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Example 22 with StoragePoolIsoMap

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

the class CINDERStorageHelper method attachCinderDomainToPool.

public void attachCinderDomainToPool(final Guid storageDomainId, final Guid storagePoolId) {
    StoragePoolIsoMap storagePoolIsoMap = new StoragePoolIsoMap(storageDomainId, storagePoolId, StorageDomainStatus.Maintenance);
    storagePoolIsoMapDao.save(storagePoolIsoMap);
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 23 with StoragePoolIsoMap

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

the class StoragePoolIsoMapDaoTest method testGetAllStoragePoolIsoMapsForIso.

@Test
public void testGetAllStoragePoolIsoMapsForIso() {
    List<StoragePoolIsoMap> result = dao.getAllForStorage(FixturesTool.STORAGE_DOMAIN_SCALE_SD5);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (StoragePoolIsoMap mapping : result) {
        assertEquals(FixturesTool.STORAGE_DOMAIN_SCALE_SD5, mapping.getStorageId());
    }
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Test(org.junit.Test)

Example 24 with StoragePoolIsoMap

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

the class StorageServerConnectionDaoTest method getStorageConnectionsByStorageTypeWithRecords.

public void getStorageConnectionsByStorageTypeWithRecords(EnumSet<StorageDomainStatus> statuses, Collection<Guid> expectedDomains) {
    List<StoragePoolIsoMap> poolIsoMap = dbFacade.getStoragePoolIsoMapDao().getAllForStoragePool(FixturesTool.STORAGE_POOL_MIXED_TYPES);
    List<Guid> storageDomainIds = poolIsoMap.stream().filter(isoMap -> statuses.contains(isoMap.getStatus())).map(StoragePoolIsoMap::getStorageId).collect(Collectors.toList());
    assertTrue("the list of the pool domains expected to be in the given statuses doesn't match the queried data", CollectionUtils.isEqualCollection(expectedDomains, storageDomainIds));
    List<StorageServerConnections> result = dao.getStorageConnectionsByStorageTypeAndStatus(FixturesTool.STORAGE_POOL_MIXED_TYPES, StorageType.NFS, statuses);
    assertFalse("there should be connections for the tested domains to verify the correctness", result.isEmpty());
    for (StorageServerConnections storageServerConnection : result) {
        assertEquals("connections were loaded with incorrect storage type", StorageType.NFS, storageServerConnection.getStorageType());
    }
    List<StorageServerConnections> domainConnections = new LinkedList<>();
    for (Guid domainId : storageDomainIds) {
        domainConnections.addAll(dao.getAllForDomain(domainId));
    }
    assertTrue("the connections loaded by the given dao function should match the connections loaded separately", CollectionUtils.isEqualCollection(domainConnections, result));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) LinkedList(java.util.LinkedList)

Example 25 with StoragePoolIsoMap

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

the class UpdateStorageServerConnectionCommand method changeStorageDomainStatusInTransaction.

protected void changeStorageDomainStatusInTransaction(final StorageDomainStatus status) {
    executeInNewTransaction(() -> {
        CompensationContext context = getCompensationContext();
        for (StorageDomain domain : domains) {
            for (StoragePoolIsoMap map : getStoragePoolIsoMap(domain)) {
                context.snapshotEntityStatus(map);
                updateStatus(map, status);
            }
        }
        getCompensationContext().stateChanged();
        return null;
    });
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) 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