Search in sources :

Example 56 with LunDisk

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

the class DiskGeneralModel method updateProperties.

private void updateProperties() {
    Disk disk = getEntity();
    setImage(disk.getDiskStorageType().isInternal());
    setLun(disk.getDiskStorageType() == DiskStorageType.LUN);
    setAlias(disk.getDiskAlias());
    setDescription(disk.getDiskDescription());
    setDiskId(disk.getId().toString());
    setWipeAfterDelete(disk.isWipeAfterDelete());
    if (isImage()) {
        DiskImage diskImage = (DiskImage) disk;
        // $NON-NLS-1$
        setDiskProfileName(StringHelper.nullSafeJoin(",", diskImage.getDiskProfileNames()));
        // $NON-NLS-1$
        setQuotaName(StringHelper.nullSafeJoin(",", diskImage.getQuotaNames()));
        setQuotaAvailable(!diskImage.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
    } else if (isLun()) {
        LunDisk lunDisk = (LunDisk) disk;
        setLunId(lunDisk.getLun().getLUNId());
    }
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 57 with LunDisk

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

the class RemoveVmCommand method removeVm.

private boolean removeVm() {
    final List<DiskImage> diskImages = DisksFilter.filterImageDisks(getVm().getDiskList(), ONLY_NOT_SHAREABLE, ONLY_ACTIVE);
    final List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getVm().getDiskMap().values(), ONLY_NOT_SHAREABLE);
    for (VmNic nic : getInterfaces()) {
        externalNetworkManagerFactory.create(nic).deallocateIfExternal();
    }
    removeMemoryVolumes();
    TransactionSupport.executeInNewTransaction(() -> {
        removeVmFromDb();
        if (getParameters().isRemoveDisks()) {
            for (DiskImage image : diskImages) {
                getCompensationContext().snapshotEntityStatus(image.getImage(), ImageStatus.ILLEGAL);
                imagesHandler.updateImageStatus(image.getImage().getId(), ImageStatus.LOCKED);
            }
            for (LunDisk lunDisk : lunDisks) {
                imagesHandler.removeLunDisk(lunDisk);
            }
            getCompensationContext().stateChanged();
        } else {
            for (DiskImage image : diskImages) {
                imageDao.updateImageVmSnapshotId(image.getImageId(), null);
            }
        }
        return null;
    });
    Collection<DiskImage> unremovedDisks = Collections.emptyList();
    if (getParameters().isRemoveDisks()) {
        if (!diskImages.isEmpty()) {
            unremovedDisks = removeVmImages(diskImages).getActionReturnValue();
        }
        unremovedDisks.addAll(removeCinderDisks());
        if (!unremovedDisks.isEmpty()) {
            processUnremovedDisks(unremovedDisks);
            return false;
        }
    }
    vmDeleted.fire(getVmId());
    return true;
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 58 with LunDisk

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

the class AbstractGetDisksAndSnapshotsQueryTest method createLunDisk.

private LunDisk createLunDisk() {
    LunDisk lun = new LunDisk();
    lun.setId(Guid.newGuid());
    return lun;
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 59 with LunDisk

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

the class AddDiskCommandTest method testLunDiskWithSgioCanBeAdded.

@Test
public void testLunDiskWithSgioCanBeAdded() {
    LunDisk disk = createISCSILunDisk();
    disk.setSgio(ScsiGenericIO.UNFILTERED);
    command.getParameters().setDiskInfo(disk);
    command.getParameters().getDiskVmElement().setDiskInterface(DiskInterface.VirtIO_SCSI);
    mockVm();
    mockMaxPciSlots();
    when(osRepository.getDiskInterfaces(anyInt(), any())).thenReturn(Collections.singletonList("VirtIO_SCSI"));
    mockInterfaceList();
    ValidateTestUtils.runAndAssertValidateSuccess(command);
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 60 with LunDisk

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

the class AddDiskCommandTest method testIscsiLunDiskWithNoPortCantBeAdded.

@Test
public void testIscsiLunDiskWithNoPortCantBeAdded() {
    LunDisk disk = createISCSILunDisk();
    command.getParameters().setDiskInfo(disk);
    disk.getLun().getLunConnections().get(0).setPort(null);
    assertFalse("checkIfLunDiskCanBeAdded() succeded for ISCSI lun which LUNs has storage_server_connection with a null port", command.checkIfLunDiskCanBeAdded(spyDiskValidator(disk)));
    ValidateTestUtils.assertValidationMessages("checkIfLunDiskCanBeAdded() failed but correct can do action hasn't been added to the return response", command, EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS);
    clearValidationMessages();
    disk.getLun().getLunConnections().get(0).setPort("");
    assertFalse("checkIfLunDiskCanBeAdded() succeded for ISCSI lun which LUNs has storage_server_connection with a empty port", command.checkIfLunDiskCanBeAdded(spyDiskValidator(disk)));
    ValidateTestUtils.assertValidationMessages("checkIfLunDiskCanBeAdded() failed but correct can do action hasn't been added to the return response", command, EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS);
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

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