use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommand method isConnectionEditable.
protected boolean isConnectionEditable(StorageServerConnections connection) {
if (connection.getStorageType().isFileDomain()) {
boolean isConnectionEditable = isFileDomainInEditState(domains.get(0)) || getParameters().isForce();
if (!isConnectionEditable) {
addValidationMessageVariable("domainNames", domains.get(0).getStorageName());
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
}
return isConnectionEditable;
}
if (!getLuns().isEmpty()) {
List<String> problematicVMNames = new ArrayList<>();
List<String> problematicDomainNames = new ArrayList<>();
for (LUNs lun : getLuns()) {
Guid diskId = lun.getDiskId();
if (diskId != null) {
Map<Boolean, List<VM>> vmsMap = vmDao.getForDisk(diskId, true);
List<VM> pluggedVms = vmsMap.get(Boolean.TRUE);
if (pluggedVms != null && !pluggedVms.isEmpty()) {
for (VM vm : pluggedVms) {
if (!vm.getStatus().equals(VMStatus.Down)) {
problematicVMNames.add(vm.getName());
}
}
}
}
Guid storageDomainId = lun.getStorageDomainId();
if (storageDomainId != null) {
StorageDomain domain = storageDomainDao.get(storageDomainId);
if (!domain.getStorageDomainSharedStatus().equals(StorageDomainSharedStatus.Unattached) && !getParameters().isForce()) {
for (StoragePoolIsoMap map : getStoragePoolIsoMap(domain)) {
if (!map.getStatus().equals(StorageDomainStatus.Maintenance)) {
String domainName = domain.getStorageName();
problematicDomainNames.add(domainName);
} else {
domains.add(domain);
}
}
} else {
// unattached domain, edit allowed
domains.add(domain);
}
}
}
if (!problematicVMNames.isEmpty()) {
if (problematicDomainNames.isEmpty()) {
addValidationMessageVariable("vmNames", prepareEntityNamesForMessage(problematicVMNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS);
} else {
addValidationMessageVariable("vmNames", prepareEntityNamesForMessage(problematicVMNames));
addValidationMessageVariable("domainNames", prepareEntityNamesForMessage(problematicDomainNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_STATUS);
}
return false;
}
if (!problematicDomainNames.isEmpty()) {
addValidationMessageVariable("domainNames", prepareEntityNamesForMessage(problematicDomainNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class DetachStorageConnectionFromStorageDomainCommand method executeCommand.
@Override
protected void executeCommand() {
String connectionId = getParameters().getStorageConnectionId();
List<LUNs> lunsForConnection = lunDao.getAllForStorageServerConnection(connectionId);
List<LUNs> lunsForVG = lunDao.getAllForVolumeGroup(getStorageDomain().getStorage());
Collection<LUNs> lunsToRemove = (Collection<LUNs>) CollectionUtils.intersection(lunsForConnection, lunsForVG);
for (LUNs lun : lunsToRemove) {
if (lunDao.get(lun.getLUNId()) != null) {
lunDao.remove(lun.getLUNId());
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class AddDiskCommandTest method testLunDiskInvalid.
@Test
public void testLunDiskInvalid() {
VDS vds = mockVds();
LunDisk disk = createISCSILunDisk();
command.getParameters().setDiskInfo(disk);
command.getParameters().setVdsId(vds.getId());
command.setVds(vds);
mockMaxPciSlots();
mockInterfaceList();
mockVm();
List<LUNs> luns = Collections.emptyList();
doReturn(luns).when(command).executeGetDeviceList(any(), any(), any());
ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_INVALID);
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class AddDiskCommandTest method testGetLunDiskFails.
@Test
public void testGetLunDiskFails() {
VDS vds = mockVds();
LunDisk disk = createISCSILunDisk();
List<LUNs> luns = Collections.emptyList();
initializeCommand(Guid.newGuid());
doReturn(luns).when(command).executeGetDeviceList(any(), any(), any());
assertNull(command.getLunDisk(disk.getLun(), vds));
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class GetUnregisteredBlockStorageDomainsQueryTest method getLUNs.
private List<LUNs> getLUNs(Guid sdId, String vgId) {
LUNs lun1 = new LUNs();
lun1.setStorageDomainId(sdId);
lun1.setVolumeGroupId(vgId);
lun1.setLunConnections(new ArrayList<>(getConnections()));
LUNs lun2 = new LUNs();
lun2.setStorageDomainId(sdId);
lun2.setVolumeGroupId(vgId);
lun2.setLunConnections(new ArrayList<>(getConnections()));
return new ArrayList<>(Arrays.asList(lun1, lun2));
}
Aggregations