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());
}
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;
}
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);
}
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()));
}
}
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;
}
Aggregations