Search in sources :

Example 16 with EntityInfo

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

the class BackendVmDisksResourceTest method testAttachDiskSnapshot.

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

Example 17 with EntityInfo

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

the class VmPoolMonitor method runVmFromPool.

/**
 * Run the given VM as stateless.
 */
private boolean runVmFromPool(VmStatic vmToRun, boolean runAsStateless, String poolName) {
    log.info("Running VM '{}' as {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful");
    RunVmParams runVmParams = new RunVmParams(vmToRun.getId());
    runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToRun.getId()));
    runVmParams.setRunAsStateless(runAsStateless);
    ActionReturnValue actionReturnValueurnValue = Backend.getInstance().runInternalAction(ActionType.RunVm, runVmParams, ExecutionHandler.createInternalJobContext().withLock(vmPoolHandler.createLock(vmToRun.getId())));
    boolean prestartingVmSucceeded = actionReturnValueurnValue.getSucceeded();
    if (!prestartingVmSucceeded) {
        AuditLogable log = new AuditLogableImpl();
        log.addCustomValue("VmPoolName", poolName);
        Injector.get(AuditLogDirector.class).log(log, AuditLogType.VM_FAILED_TO_PRESTART_IN_POOL);
    }
    log.info("Running VM '{}' as {} {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful", prestartingVmSucceeded ? "succeeded" : "failed");
    return prestartingVmSucceeded;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Example 18 with EntityInfo

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

the class ExportRepoImageCommand method executeCommand.

@Override
protected void executeCommand() {
    DiskImage diskImage = getDiskImage();
    OpenStackImageProviderProxy proxy = getProviderProxy();
    acquireImageDbLock();
    String newImageId = proxy.createImageFromDiskImage(diskImage);
    getParameters().setParentCommand(ActionType.ExportRepoImage);
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UploadImage, new UploadImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), getStorageDomain().getId(), diskImage.getId(), diskImage.getImageId(), new HttpLocationInfo(getProviderProxy().getImageUrl(newImageId), getProviderProxy().getUploadHeaders())));
    if (vdsReturnValue.getSucceeded()) {
        getReturnValue().getVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Disk, getParameters().getImageGroupID(), getParameters().getDestinationDomainId()));
    }
    getReturnValue().setActionReturnValue(newImageId);
    setSucceeded(true);
}
Also used : UploadImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) HttpLocationInfo(org.ovirt.engine.core.common.businessentities.HttpLocationInfo) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OpenStackImageProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 19 with EntityInfo

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

the class HibernateVmCommand method init.

@Override
protected void init() {
    super.init();
    if (getVm() != null) {
        setStoragePoolId(getVm().getStoragePoolId());
        getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
    }
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 20 with EntityInfo

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

the class RemoveDiskCommand method buildRemoveImageParameters.

private RemoveImageParameters buildRemoveImageParameters(DiskImage diskImage) {
    RemoveImageParameters result = new RemoveImageParameters(diskImage.getImageId());
    result.setTransactionScopeOption(TransactionScopeOption.Suppress);
    result.setDiskImage(diskImage);
    result.setParentCommand(ActionType.RemoveDisk);
    result.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getDiskId()));
    result.setParentParameters(getParameters());
    result.setRemoveFromSnapshots(true);
    result.setStorageDomainId(getParameters().getStorageDomainId());
    result.setForceDelete(getParameters().getForceDelete());
    if (diskImage.getStorageIds().size() > 1) {
        result.setDbOperationScope(ImageDbOperationScope.MAPPING);
    }
    return result;
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) 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