Search in sources :

Example 26 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class CreateImagePlaceholderCommand method executeCommand.

@Override
protected void executeCommand() {
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroup()));
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CloneImageGroupStructure, new TargetDomainImageGroupVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroup(), getParameters().getDstStorageDomain()));
    if (vdsReturnValue.getSucceeded()) {
        getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
    }
    setSucceeded(true);
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid) TargetDomainImageGroupVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.TargetDomainImageGroupVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 27 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class SyncImageGroupDataCommand method executeCommand.

@Override
protected void executeCommand() {
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroup()));
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.SyncImageGroupData, new SyncImageGroupDataVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroup(), getParameters().getDstStorageDomain(), SyncImageGroupDataVDSCommandParameters.SYNC_TYPE_INTERNAL));
    if (vdsReturnValue.getSucceeded()) {
        getParameters().setVdsmTaskIds(new ArrayList<>());
        getParameters().getVdsmTaskIds().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
        getReturnValue().getVdsmTaskIdList().add(getParameters().getVdsmTaskIds().get(0));
    }
    setSucceeded(true);
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) SyncImageGroupDataVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SyncImageGroupDataVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 28 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class BackendVmDisksResourceTest method testAttachDisk.

@Test
public void testAttachDisk() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AttachDiskToVm, AttachDetachVmDiskParameters.class, new String[] { "VmId", "EntityInfo" }, new Object[] { VM_ID, new EntityInfo(VdcObjectType.Disk, DISK_ID) }, true, true, null, null, null, QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
    Disk model = getModel();
    // means this is an existing disk --> attach
    model.setId(DISK_ID.toString());
    model.setProvisionedSize(1024 * 1024L);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 29 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class RemoveVmTemplateFromImportExportCommand method executeCommand.

@Override
protected void executeCommand() {
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, getVmTemplateId()));
    RemoveVMVDSCommandParameters tempVar = new RemoveVMVDSCommandParameters(getParameters().getStoragePoolId(), getVmTemplateId());
    tempVar.setStorageDomainId(getParameters().getStorageDomainId());
    runVdsCommand(VDSCommandType.RemoveVM, tempVar);
    List<DiskImage> images = getParameters().getImages();
    setSucceeded(true);
    if (!images.isEmpty()) {
        for (DiskImage image : images) {
            ArrayList<Guid> storageIds = new ArrayList<>();
            storageIds.add(getParameters().getStorageDomainId());
            image.setStorageIds(storageIds);
            image.setStoragePoolId(getParameters().getStoragePoolId());
        }
        RemoveAllVmImagesParameters tempVar2 = new RemoveAllVmImagesParameters(getVmId(), images);
        tempVar2.setParentCommand(getActionType());
        tempVar2.setEntityInfo(getParameters().getEntityInfo());
        tempVar2.setForceDelete(true);
        tempVar2.setParentParameters(getParameters());
        ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.RemoveAllVmImages, tempVar2);
        if (vdcRetValue.getSucceeded()) {
            getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList());
        } else {
            getReturnValue().setFault(vdcRetValue.getFault());
            setSucceeded(false);
        }
    }
}
Also used : RemoveAllVmImagesParameters(org.ovirt.engine.core.common.action.RemoveAllVmImagesParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) RemoveVMVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.RemoveVMVDSCommandParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 30 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForMemoryConfImage.

private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForMemoryConfImage(Guid containerID, Guid storageId, Guid imageId, Guid volumeId) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, imageId, volumeId, imageId, volumeId, storageId, ImageOperation.Copy);
    params.setParentCommand(getActionType());
    // This volume is always of type 'sparse' and format 'cow' so no need to convert,
    // and there're no snapshots for it so no reason to use copy collapse
    params.setUseCopyCollapse(false);
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setForceOverride(getParameters().getForceOverride());
    params.setParentParameters(getParameters());
    params.setSourceDomainId(getParameters().getSourceDomainId());
    params.setStoragePoolId(getParameters().getStoragePoolId());
    params.setImportEntity(true);
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Aggregations

EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)33 Guid (org.ovirt.engine.core.compat.Guid)14 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)6 MoveOrCopyImageGroupParameters (org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)5 RemoveImageParameters (org.ovirt.engine.core.common.action.RemoveImageParameters)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Test (org.junit.Test)3 RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Disk (org.ovirt.engine.api.model.Disk)2 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)2 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1