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