Search in sources :

Example 21 with DiskVmElement

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)));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 22 with 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;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 23 with 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);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 24 with DiskVmElement

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);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 25 with DiskVmElement

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());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Aggregations

DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)91 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Test (org.junit.Test)26 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)23 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)22 Guid (org.ovirt.engine.core.compat.Guid)17 ArrayList (java.util.ArrayList)16 VM (org.ovirt.engine.core.common.businessentities.VM)12 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)11 HashMap (java.util.HashMap)8 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)8 Map (java.util.Map)7 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)7 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)7 ActionType (org.ovirt.engine.core.common.action.ActionType)6 AttachDetachVmDiskParameters (org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 VmDiskOperationParameterBase (org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)5 Collection (java.util.Collection)4