Search in sources :

Example 56 with LUNs

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;
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) List(java.util.List)

Example 57 with LUNs

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);
}
Also used : Collection(java.util.Collection) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 58 with LUNs

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);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 59 with LUNs

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));
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 60 with LUNs

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));
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Aggregations

LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)105 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)33 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)26 Guid (org.ovirt.engine.core.compat.Guid)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)17 List (java.util.List)16 HashMap (java.util.HashMap)14 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VM (org.ovirt.engine.core.common.businessentities.VM)7 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)7 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)7 Map (java.util.Map)6 LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)6 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 GetDeviceListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)5 HashSet (java.util.HashSet)4