use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class ImportVmCommand method validateLunDisk.
private List<EngineMessage> validateLunDisk(LunDisk lunDisk) {
DiskValidator diskValidator = getDiskValidator(lunDisk);
LUNs lun = lunDisk.getLun();
StorageType storageType;
if (lun.getLunConnections() != null && !lun.getLunConnections().isEmpty()) {
// We set the storage type based on the first connection since connections should be with the same
// storage type
storageType = lun.getLunConnections().get(0).getStorageType();
} else {
storageType = StorageType.FCP;
}
if (storageType == StorageType.ISCSI) {
ValidationResult connectionsInLunResult = diskValidator.validateConnectionsInLun(storageType);
if (!connectionsInLunResult.isValid()) {
return connectionsInLunResult.getMessages();
}
}
ValidationResult lunAlreadyInUseResult = diskValidator.validateLunAlreadyInUse();
if (!lunAlreadyInUseResult.isValid()) {
return lunAlreadyInUseResult.getMessages();
}
DiskVmElementValidator diskVmElementValidator = new DiskVmElementValidator(lunDisk, lunDisk.getDiskVmElementForVm(getVmId()));
ValidationResult virtIoScsiResult = isVirtIoScsiValid(getVm(), diskVmElementValidator);
if (!virtIoScsiResult.isValid()) {
return virtIoScsiResult.getMessages();
}
ValidationResult diskInterfaceResult = diskVmElementValidator.isDiskInterfaceSupported(getVm());
if (!diskInterfaceResult.isValid()) {
return diskInterfaceResult.getMessages();
}
Guid vdsId = vdsCommandsHelper.getHostForExecution(getStoragePoolId());
if (vdsId == null || !validateLunExistsAndInitDeviceData(lun, storageType, vdsId)) {
return Arrays.asList(EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_INVALID);
}
ValidationResult usingScsiReservationResult = diskValidator.isUsingScsiReservationValid(getVm(), lunDisk.getDiskVmElementForVm(getVmId()), lunDisk);
if (!usingScsiReservationResult.isValid()) {
return usingScsiReservationResult.getMessages();
}
return Collections.emptyList();
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommandTest method updateConnectionOfLunDisks.
@Test
public void updateConnectionOfLunDisks() {
StorageServerConnections iscsiConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3260", "user1", "mypassword123");
LUNs lun1 = new LUNs();
lun1.setLUNId("3600144f09dbd05000000517e730b1212");
lun1.setVolumeGroupId("");
lun1.setDiskAlias("disk1");
Guid diskId1 = Guid.newGuid();
lun1.setDiskId(diskId1);
LUNs lun2 = new LUNs();
lun2.setLUNId("3600144f09dbd05000000517e730b1212");
lun2.setVolumeGroupId("");
lun2.setDiskAlias("disk2");
Guid diskId2 = Guid.newGuid();
lun2.setDiskId(diskId2);
List<LUNs> luns = Arrays.asList(lun1, lun2);
Map<Boolean, List<VM>> vmsMap = new HashMap<>();
VM vm1 = new VM();
vm1.setName("vm1");
vm1.setStatus(VMStatus.Up);
VM vm2 = new VM();
vm2.setName("vm2");
vm2.setStatus(VMStatus.Paused);
VM vm3 = new VM();
vm3.setName("vm3");
vm3.setStatus(VMStatus.Up);
List<VM> pluggedVms = Arrays.asList(vm1, vm2);
List<VM> unPluggedVms = Collections.singletonList(vm3);
vmsMap.put(Boolean.FALSE, unPluggedVms);
vmsMap.put(Boolean.TRUE, pluggedVms);
when(vmDao.getForDisk(diskId1, true)).thenReturn(vmsMap);
parameters.setStorageServerConnection(iscsiConnection);
when(storageConnDao.get(iscsiConnection.getId())).thenReturn(iscsiConnection);
doReturn(luns).when(command).getLuns();
List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS);
assertTrue(messages.contains("$vmNames vm1,vm2"));
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommandTest method updateConnectionOfDomains.
@Test
public void updateConnectionOfDomains() {
StorageServerConnections iscsiConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3260", "user1", "mypassword123");
LUNs lun1 = new LUNs();
lun1.setLUNId("3600144f09dbd05000000517e730b1212");
lun1.setStorageDomainName("storagedomain4");
Guid storageDomainId = Guid.newGuid();
lun1.setStorageDomainId(storageDomainId);
lun1.setVolumeGroupId(Guid.newGuid().toString());
List<LUNs> luns = Collections.singletonList(lun1);
parameters.setStorageServerConnection(iscsiConnection);
when(storageConnDao.get(iscsiConnection.getId())).thenReturn(iscsiConnection);
doReturn(luns).when(command).getLuns();
StorageDomain domain1 = new StorageDomain();
domain1.setStorage(iscsiConnection.getConnection());
domain1.setStatus(StorageDomainStatus.Active);
domain1.setStorageDomainSharedStatus(StorageDomainSharedStatus.Active);
domain1.setId(storageDomainId);
domain1.setStorageName("storagedomain4");
when(storageDomainDao.get(storageDomainId)).thenReturn(domain1);
when(storagePoolIsoMapDao.getAllForStorage(storageDomainId)).thenReturn(Collections.singletonList(new StoragePoolIsoMap(storageDomainId, Guid.newGuid(), StorageDomainStatus.Active)));
List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
assertTrue(messages.contains("$domainNames storagedomain4"));
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class AttachStorageServerConnectionToStorageDomainCommandTest method executeCommandNotFirstDummyLun.
@Test
public void executeCommandNotFirstDummyLun() {
LUNs dummyLun = new LUNs();
dummyLun.setLUNId(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX + domain.getId());
when(lunDao.get(dummyLun.getLUNId())).thenReturn(dummyLun);
List<StorageServerConnections> connectionsForDomain = new ArrayList<>();
StorageServerConnections connection = new StorageServerConnections();
connection.setId(Guid.newGuid().toString());
connection.setStorageType(StorageType.ISCSI);
connection.setIqn("iqn.1.2.3.4.com");
connection.setConnection("123.345.266.255");
connectionsForDomain.add(connection);
when(connectionDao.getAllForDomain(domain.getId())).thenReturn(connectionsForDomain);
// dummy lun already exists, thus no need to save
verify(lunDao, never()).save(dummyLun);
verify(lunMapDao, never()).save(new LUNStorageServerConnectionMap());
command.executeCommand();
CommandAssertUtils.checkSucceeded(command, true);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class DetachStorageConnectionFromStorageDomainCommandTest method executeCommand.
@Test
public void executeCommand() {
LUNs lun1 = new LUNs();
lun1.setLUNId(Guid.newGuid().toString());
lun1.setStorageDomainId(domain.getId());
LUNs lun2 = new LUNs();
lun2.setLUNId(Guid.newGuid().toString());
lun2.setStorageDomainId(domain.getId());
LUNs lun3 = new LUNs();
lun3.setLUNId(Guid.newGuid().toString());
lun3.setStorageDomainId(domain.getId());
List<LUNs> lunsForConnection = new ArrayList<>();
lunsForConnection.add(lun1);
lunsForConnection.add(lun2);
lunsForConnection.add(lun3);
List<LUNs> lunsForVG = new ArrayList<>();
lunsForVG.add(lun1);
lunsForVG.add(lun2);
when(lunDao.getAllForStorageServerConnection(connectionId.toString())).thenReturn(lunsForConnection);
when(lunDao.getAllForVolumeGroup(domain.getStorage())).thenReturn(lunsForVG);
when(lunDao.get(lun1.getLUNId())).thenReturn(lun1);
when(lunDao.get(lun2.getLUNId())).thenReturn(lun2);
command.executeCommand();
verify(lunDao, times(1)).remove(lun1.getLUNId());
verify(lunDao, times(1)).remove(lun2.getLUNId());
CommandAssertUtils.checkSucceeded(command, true);
}
Aggregations