Search in sources :

Example 1 with CompensationContext

use of org.ovirt.engine.core.bll.context.CompensationContext 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)

Example 2 with CompensationContext

use of org.ovirt.engine.core.bll.context.CompensationContext in project ovirt-engine by oVirt.

the class UpdateStorageServerConnectionCommand method updateStorageDomain.

protected void updateStorageDomain(final List<StorageDomain> storageDomainsToUpdate) {
    executeInNewTransaction(() -> {
        for (StorageDomain domainToUpdate : storageDomainsToUpdate) {
            CompensationContext context = getCompensationContext();
            context.snapshotEntity(domainToUpdate.getStorageDynamicData());
            storageDomainDynamicDao.update(domainToUpdate.getStorageDynamicData());
            getCompensationContext().stateChanged();
        }
        return null;
    });
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext)

Example 3 with CompensationContext

use of org.ovirt.engine.core.bll.context.CompensationContext in project ovirt-engine by oVirt.

the class ImportHostedEngineStorageDomainCommandTest method prepareCommand.

protected void prepareCommand() {
    parameters.setStoragePoolId(HE_SP_ID);
    parameters.setVdsId(HE_VDS_ID);
    parameters.setStorageDomainId(HE_SD_ID);
    // vds
    VDS vds = new VDS();
    vds.setId(Guid.Empty);
    vds.setStoragePoolId(HE_SP_ID);
    when(vdsDao.get(any())).thenReturn(vds);
    List<BaseDisk> baseDisks = Collections.singletonList(new BaseDisk());
    when(baseDiskDao.getDisksByAlias(any())).thenReturn(baseDisks);
    // Data center
    StoragePool pool = new StoragePool();
    pool.setStatus(StoragePoolStatus.Up);
    pool.setId(HE_SP_ID);
    when(storagePoolDao.get(HE_SP_ID)).thenReturn(pool);
    // compensation
    CompensationContext compensationContext = mock(CompensationContext.class);
    when(cmd.getCompensationContext()).thenReturn(compensationContext);
    when(cmd.getContext()).thenReturn(new CommandContext(new EngineContext()));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) EngineContext(org.ovirt.engine.core.bll.context.EngineContext)

Example 4 with CompensationContext

use of org.ovirt.engine.core.bll.context.CompensationContext in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommand method updateLunsInDb.

private void updateLunsInDb(List<LUNs> lunsToUpdateInDb) {
    TransactionSupport.executeInNewTransaction(() -> {
        CompensationContext context = getCompensationContext();
        context.snapshotEntities(getParameters().getLunsList());
        lunDao.updateAllInBatch(lunsToUpdateInDb);
        context.stateChanged();
        return null;
    });
    log.debug("LUNs with IDs: [" + lunsToUpdateInDb.stream().map(LUNs::getLUNId).collect(Collectors.joining(", ")) + "] were updated in the DB.");
}
Also used : CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 5 with CompensationContext

use of org.ovirt.engine.core.bll.context.CompensationContext in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommand method updateStorageDomain.

protected void updateStorageDomain(final StorageDomain storageDomainToUpdate) {
    executeInNewTransaction(() -> {
        CompensationContext context = getCompensationContext();
        context.snapshotEntity(getStorageDomain().getStorageDynamicData());
        storageDomainDynamicDao.update(storageDomainToUpdate.getStorageDynamicData());
        getCompensationContext().stateChanged();
        return null;
    });
}
Also used : CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext)

Aggregations

CompensationContext (org.ovirt.engine.core.bll.context.CompensationContext)5 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 EngineContext (org.ovirt.engine.core.bll.context.EngineContext)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)1 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)1