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