Search in sources :

Example 51 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class AbstractDiskModel method flush.

public void flush() {
    switch(getDiskStorageType().getEntity()) {
        case LUN:
            LunDisk lunDisk = getLunDisk();
            DiskInterface diskInterface = getDiskInterface().getSelectedItem();
            if (DiskInterface.VirtIO_SCSI.equals(diskInterface)) {
                lunDisk.setSgio(!getIsScsiPassthrough().getEntity() ? null : getIsSgIoUnfiltered().getEntity() ? ScsiGenericIO.UNFILTERED : ScsiGenericIO.FILTERED);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(getIsUsingScsiReservation().getEntity());
                }
            } else {
                getIsScsiPassthrough().setEntity(false);
                lunDisk.setSgio(null);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(false);
                }
            }
            setDisk(lunDisk);
            break;
        case CINDER:
            CinderDisk cinderDisk = getCinderDisk();
            updateQuota(cinderDisk);
            updateDiskSize(cinderDisk);
            setDisk(cinderDisk);
            break;
        case IMAGE:
            DiskImage diskImage = getDiskImage();
            // For a long time it was possible to delete all disk profiles
            if (getDiskProfile().getSelectedItem() != null) {
                diskImage.setDiskProfileId(getDiskProfile().getSelectedItem().getId());
            }
            updateQuota(diskImage);
            updateDiskSize(diskImage);
            setDisk(diskImage);
            break;
    }
    getDisk().setDiskAlias(getAlias().getEntity());
    getDisk().setDiskDescription(getDescription().getEntity());
    getDisk().setWipeAfterDelete(getIsWipeAfterDelete().getEntity());
    getDisk().setShareable(getIsShareable().getEntity());
    getDisk().setPlugged(getIsPlugged().getEntity());
    getDisk().setPropagateErrors(PropagateErrors.Off);
    if (getVm() != null) {
        getDiskVmElement().setReadOnly(getIsReadOnly().getIsAvailable() ? getIsReadOnly().getEntity() : false);
        getDiskVmElement().setBoot(getIsBootable().getEntity());
        getDiskVmElement().setDiskInterface(getDiskInterface().getSelectedItem());
        getDiskVmElement().setPassDiscard(getPassDiscard().getEntity());
    }
}
Also used : DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 52 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class EditDiskModel method initialize.

@Override
public void initialize() {
    super.initialize();
    setDiskVmElement(getDisk().getDiskVmElementForVm(getVm().getId()));
    disableNonChangeableEntities();
    getAlias().setEntity(getDisk().getDiskAlias());
    getDescription().setEntity(getDisk().getDiskDescription());
    getIsShareable().setEntity(getDisk().isShareable());
    getIsWipeAfterDelete().setEntity(getDisk().isWipeAfterDelete());
    getIsScsiPassthrough().setEntity(getDisk().isScsiPassthrough());
    getIsSgIoUnfiltered().setEntity(getDisk().getSgio() == ScsiGenericIO.UNFILTERED);
    getIsReadOnly().setEntity(getDiskVmElement().isReadOnly());
    getIsBootable().setEntity(getDiskVmElement().isBoot());
    getPassDiscard().setEntity(getDiskVmElement().isPassDiscard());
    switch(getDisk().getDiskStorageType()) {
        case IMAGE:
            DiskImage diskImage = (DiskImage) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.IMAGE);
            getSize().setEntity((int) diskImage.getSizeInGigabytes());
            getVolumeType().setSelectedItem(diskImage.getVolumeType());
            boolean isExtendImageSizeEnabled = getVm() != null && !diskImage.isDiskSnapshot() && ActionUtils.canExecute(Arrays.asList(getVm()), VM.class, ActionType.ExtendImageSize);
            getSizeExtend().setIsChangeable(isExtendImageSizeEnabled);
            break;
        case LUN:
            LunDisk lunDisk = (LunDisk) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.LUN);
            getStorageType().setIsAvailable(false);
            getSize().setEntity(lunDisk.getLun().getDeviceSize());
            getSizeExtend().setIsAvailable(false);
            getIsUsingScsiReservation().setEntity(getDiskVmElement().isUsingScsiReservation());
            break;
        case CINDER:
            CinderDisk cinderDisk = (CinderDisk) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.CINDER);
            getSize().setEntity((int) cinderDisk.getSizeInGigabytes());
            getSizeExtend().setIsChangeable(true);
            break;
    }
    updateReadOnlyChangeability();
    updatePassDiscardChangeability();
    updateWipeAfterDeleteChangeability();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 53 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class RunVmCommandTest method connectAllTargets.

@Test
public void connectAllTargets() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    LunDisk lunDisk2 = new LunDisk();
    LUNs lun2 = new LUNs();
    lun2.setLUNId("id2");
    lunDisk2.setLun(lun2);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk2);
    List<StorageServerConnections> connections1 = new ArrayList<>();
    List<StorageServerConnections> connections2 = new ArrayList<>();
    // luns have the separate backing targets
    connections1.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
    connections2.add(new StorageServerConnections("/path/to/con2", "id2", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections1);
    when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(connections2);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for different targets, make sure all of them are connected
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(2));
    assertTrue(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 54 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class RunVmCommandTest method skipIdenticalTargets.

@Test
public void skipIdenticalTargets() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    LunDisk lunDisk2 = new LunDisk();
    LUNs lun2 = new LUNs();
    lun2.setLUNId("id2");
    lunDisk2.setLun(lun2);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk2);
    List<StorageServerConnections> connections = new ArrayList<>();
    // luns have the same backing targets
    connections.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections);
    when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(connections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for same targets, connect only once
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertTrue(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 55 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class VmHandlerTest method filterDisksForVmMixedDiskTypes.

@Test
public void filterDisksForVmMixedDiskTypes() {
    DiskImage snapshotDisk = createDiskImage(false);
    DiskImage regularDisk = createDiskImage(true);
    LunDisk lunDisk = createLunDisk();
    VM vm = new VM();
    vm.setId(Guid.newGuid());
    populateVmWithDisks(Arrays.asList(snapshotDisk, regularDisk, lunDisk), vm);
    vmHandler.filterImageDisksForVM(vm);
    assertFalse(vm.getDiskList().contains(snapshotDisk));
    assertTrue(vm.getDiskList().contains(regularDisk));
    assertTrue(vm.getManagedVmDeviceMap().containsKey(regularDisk.getId()));
    assertFalse(vm.getManagedVmDeviceMap().containsKey(lunDisk.getId()));
    assertFalse(vm.getManagedVmDeviceMap().containsKey(snapshotDisk.getId()));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

Aggregations

LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)62 Test (org.junit.Test)29 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)21 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)16 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)13 VM (org.ovirt.engine.core.common.businessentities.VM)10 ArrayList (java.util.ArrayList)9 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 Guid (org.ovirt.engine.core.compat.Guid)7 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)6 HashMap (java.util.HashMap)5 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)5 HashSet (java.util.HashSet)3 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)3 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)3 ImageResource (com.google.gwt.resources.client.ImageResource)2 List (java.util.List)2