Search in sources :

Example 51 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class GetBlockStorageDomainsWithAttachedStoragePoolGuidQueryTest method testNullStorageDomainListQuery.

@Test
public void testNullStorageDomainListQuery() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Up);
    mockStoragePoolDao(storagePool);
    // Run 'HSMGetStorageDomainInfo' command
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
    returnValue.setReturnValue(storageDomainToPoolId);
    when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair) Test(org.junit.Test)

Example 52 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class UpdateStorageServerConnectionCommandTest method failUpdateConnectToStorage.

@Test
public void failUpdateConnectToStorage() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    parameters.setStorageServerConnection(newNFSConnection);
    doReturn(false).when(command).connectToStorage();
    VDSReturnValue returnValueUpdate = new VDSReturnValue();
    returnValueUpdate.setSucceeded(true);
    StorageDomainDynamic domainDynamic = new StorageDomainDynamic();
    StorageDomain domain = createDomain();
    initDomainListForConnection(newNFSConnection.getId(), domain);
    StoragePoolIsoMap map = new StoragePoolIsoMap();
    doReturn(Collections.singletonList(map)).when(command).getStoragePoolIsoMap(domain);
    command.executeCommand();
    CommandAssertUtils.checkSucceeded(command, true);
    verify(storageDomainDynamicDao, never()).update(domainDynamic);
    verify(command, never()).disconnectFromStorage();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Example 53 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class CreateCloneOfTemplateCommand method performImageVdsmOperation.

@Override
protected boolean performImageVdsmOperation() {
    setDestinationImageId(Guid.newGuid());
    persistCommandIfNeeded();
    newDiskImage = cloneDiskImage(getDestinationImageId());
    newDiskImage.setId(Guid.newGuid());
    Guid storagePoolID = newDiskImage.getStoragePoolId() != null ? newDiskImage.getStoragePoolId() : Guid.Empty;
    if (isDataOperationsByHSM()) {
        CopyImageGroupWithDataCommandParameters p = new CopyImageGroupWithDataCommandParameters(storagePoolID, getParameters().getStorageDomainId(), getDestinationStorageDomainId(), getDiskImage().getId(), getImage().getImageId(), newDiskImage.getId(), getDestinationImageId(), newDiskImage.getVolumeFormat(), true);
        p.setParentParameters(getParameters());
        p.setParentCommand(getActionType());
        p.setEndProcedure(ActionParametersBase.EndProcedure.COMMAND_MANAGED);
        runInternalAction(ActionType.CopyImageGroupWithData, p);
        return true;
    } else {
        Guid taskId = persistAsyncTaskPlaceHolder(ActionType.AddVmFromTemplate);
        VDSReturnValue vdsReturnValue;
        try {
            vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(storagePoolID, getParameters().getStorageDomainId(), getVmTemplateId(), getDiskImage().getId(), getImage().getImageId(), newDiskImage.getId(), getDestinationImageId(), "", getDestinationStorageDomainId(), CopyVolumeType.LeafVol, newDiskImage.getVolumeFormat(), newDiskImage.getVolumeType(), getDiskImage().isWipeAfterDelete(), storageDomainDao.get(getDestinationStorageDomainId()).getDiscardAfterDelete(), false)));
        } catch (EngineException e) {
            log.error("Failed creating snapshot from image id '{}'", getImage().getImageId());
            throw e;
        }
        if (vdsReturnValue.getSucceeded()) {
            getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), ActionType.AddVmFromTemplate, VdcObjectType.Storage, getParameters().getStorageDomainId(), getDestinationStorageDomainId()));
        }
        return vdsReturnValue.getSucceeded();
    }
}
Also used : CopyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) CopyImageGroupWithDataCommandParameters(org.ovirt.engine.core.common.action.CopyImageGroupWithDataCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 54 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class GlusterSnapshotSyncJob method refreshSnapshotsInCluster.

private void refreshSnapshotsInCluster(Cluster cluster) {
    if (!supportsGlusterSnapshotFeature(cluster)) {
        return;
    }
    final VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
    if (upServer == null) {
        log.info("No UP server found in cluster '{}' for snapshot monitoring", cluster.getName());
        return;
    }
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeSnapshotInfo, new GlusterVolumeSnapshotVDSParameters(upServer.getId(), cluster.getId(), null));
    if (returnValue.getSucceeded()) {
        addOrUpdateSnapshots(cluster.getId(), (ArrayList<GlusterVolumeSnapshotEntity>) returnValue.getReturnValue());
        // check if the snapshot soft limit reached for a volume and alert
        List<GlusterVolumeEntity> volumes = volumeDao.getByClusterId(cluster.getId());
        for (final GlusterVolumeEntity volume : volumes) {
            // check if the snapshot soft limit reached for the volume and alert
            glusterUtil.alertVolumeSnapshotLimitsReached(volume);
            // Check and remove soft limit alert for the volume.
            // It might have fallen below the soft limit as part of deletions of snapshots
            glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(volume);
        }
    } else {
        log.error("VDS Error {}", returnValue.getVdsError().getMessage());
        log.debug("VDS Error {}", returnValue.getVdsError());
    }
}
Also used : GlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 55 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class ResetGlusterVolumeBrickCommand method executeCommand.

@Override
protected void executeCommand() {
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ResetGlusterVolumeBrick, new ResetGlusterVolumeBrickActionVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().getExistingBrick().getQualifiedName()));
    setSucceeded(returnValue.getSucceeded());
    if (getSucceeded()) {
        glusterBrickDao.updateBrickStatus(getParameters().getExistingBrick().getId(), GlusterStatus.UP);
    } else {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_RESET_BRICK_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : ResetGlusterVolumeBrickActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.ResetGlusterVolumeBrickActionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)250 Guid (org.ovirt.engine.core.compat.Guid)65 ArrayList (java.util.ArrayList)43 VDS (org.ovirt.engine.core.common.businessentities.VDS)29 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 Pair (org.ovirt.engine.core.common.utils.Pair)26 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)23 List (java.util.List)16 Test (org.junit.Test)15 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)15 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)15 HashMap (java.util.HashMap)13 VDSError (org.ovirt.engine.core.common.errors.VDSError)13 Map (java.util.Map)11 Callable (java.util.concurrent.Callable)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)11 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8