use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class MoveDiskCommandTest method testVmDownAndDiskUnplugged.
@Test
public void testVmDownAndDiskUnplugged() {
VM vm = createMockVm(VMStatus.Down);
DiskVmElement diskVmElement = createMockDiskVmElement(vm.getId(), false);
doReturn(vm).when(vmDao).get(any());
assertEquals(ActionType.MoveOrCopyDisk, command.getMoveActionType(Collections.singletonList(diskVmElement)));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class MoveDiskCommandTest method createMockDiskVmElement.
private DiskVmElement createMockDiskVmElement(Guid vmId, boolean plugged) {
DiskVmElement diskVmElement = new DiskVmElement();
diskVmElement.setId(new VmDeviceId(Guid.newGuid(), vmId));
diskVmElement.setPlugged(plugged);
return diskVmElement;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class AddDiskCommandTest method testAddingPCILunExceedsSlotLimit.
@Test
public void testAddingPCILunExceedsSlotLimit() {
mockInterfaceList();
LunDisk disk = createISCSILunDisk();
command.getParameters().setDiskInfo(disk);
command.getParameters().getDiskVmElement().setDiskInterface(DiskInterface.VirtIO);
VM vm = mockVm();
mockMaxPciSlots();
// use maximum slots for PCI. validate expected to succeed.
mockOtherVmDisks(vm, MAX_PCI_SLOTS - 2, DiskInterface.VirtIO);
ValidateTestUtils.runAndAssertValidateSuccess(command);
LunDisk newDisk = createISCSILunDisk();
DiskVmElement dve = new DiskVmElement(disk.getId(), vmId);
dve.setDiskInterface(DiskInterface.VirtIO);
newDisk.setDiskVmElements(Collections.singletonList(dve));
vm.getDiskMap().put(newDisk.getId(), newDisk);
ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_PCI_SLOTS);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class AddDiskCommandTest method createParameters.
/**
* @return Valid parameters for the command.
*/
private static AddDiskParameters createParameters() {
DiskImage image = new DiskImage();
DiskVmElement dve = new DiskVmElement(null, vmId);
dve.setDiskInterface(DiskInterface.IDE);
return new AddDiskParameters(dve, image);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class BackendDiskAttachmentResource method update.
@Override
public DiskAttachment update(DiskAttachment attachment) {
if (attachment.isSetActive()) {
DiskAttachment attachmentFromDb = get();
if (!attachmentFromDb.isActive().equals(attachment.isActive())) {
ActionType actionType = attachment.isActive() ? ActionType.HotPlugDiskToVm : ActionType.HotUnPlugDiskFromVm;
VmDiskOperationParameterBase params = new VmDiskOperationParameterBase(new DiskVmElement(guid, vmId));
try {
doAction(actionType, params);
} catch (BackendFailureException e) {
return handleError(e, false);
}
}
}
return performUpdate(attachment, new AddDiskResolver(), ActionType.UpdateVmDisk, new UpdateParametersProvider());
}
Aggregations