Search in sources :

Example 76 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainsByVolumeGroupIds.

/**
 * Create StorageDomain objects according to the specified VG-IDs list.
 *
 * @param vgIDs the VG-IDs list
 *
 * @return storage domains list
 */
@SuppressWarnings("unchecked")
protected List<StorageDomain> getStorageDomainsByVolumeGroupIds(List<String> vgIDs) {
    List<StorageDomain> storageDomains = new ArrayList<>();
    // Get existing PhysicalVolumes.
    Set<String> existingLunIds = lunDao.getAll().stream().map(LUNs::getId).collect(Collectors.toSet());
    for (String vgID : vgIDs) {
        VDSReturnValue returnValue;
        try {
            returnValue = executeGetVGInfo(new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgID));
        } catch (RuntimeException e) {
            log.error("Could not get info for VG ID: '{}': {}", vgID, e.getMessage());
            log.debug("Exception", e);
            continue;
        }
        ArrayList<LUNs> luns = (ArrayList<LUNs>) returnValue.getReturnValue();
        if (luns.stream().anyMatch(l -> existingLunIds.contains(l.getId()))) {
            log.info("There are existing luns in the system which are part of VG id '{}'", vgID);
            continue;
        }
        // Get storage domain ID by a representative LUN
        LUNs lun = luns.get(0);
        Guid storageDomainId = lun.getStorageDomainId();
        // Get storage domain using GetStorageDomainInfo
        StorageDomain storageDomain = getStorageDomainById(storageDomainId);
        if (storageDomain != null) {
            storageDomains.add(storageDomain);
        }
    }
    return storageDomains;
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 77 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class ImportHostedEngineStorageDomainCommand method discoverBlockConnectionDetails.

private void discoverBlockConnectionDetails() {
    // get device list
    VDSReturnValue getDeviceList = runVdsCommand(VDSCommandType.GetDeviceList, new GetDeviceListVDSCommandParameters(getParameters().getVdsId(), heStorageDomain.getStorageType()));
    if (getDeviceList.getSucceeded() && getDeviceList.getReturnValue() != null && heStorageDomain.getStorageStaticData().getStorage() != null) {
        for (LUNs lun : (ArrayList<LUNs>) getDeviceList.getReturnValue()) {
            // match a lun vgid to the domain vgid.
            if (heStorageDomain.getStorage().equals(lun.getVolumeGroupId())) {
                // found a lun. Use its connection details
                heStorageDomain.getStorageStaticData().setConnection(lun.getLunConnections().get(0));
                setSucceeded(true);
                break;
            }
        }
        if (!getSucceeded()) {
            log.error("There are no luns with VG that match the SD VG '{}'." + " Connections details are missing.  completing this automatic import");
        }
    }
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 78 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class GetDeviceListQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    if (getParameters().isValidateHostStatus() && !isActiveVds()) {
        return;
    }
    List<LUNs> returnValue = new ArrayList<>();
    // Get Device List
    GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(getParameters().getId(), getParameters().getStorageType(), getParameters().isCheckStatus(), getParameters().getLunIds());
    List<LUNs> luns = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
    // Get LUNs from DB
    List<LUNs> lunsFromDb = lunDao.getAll();
    Map<String, LUNs> lunsFromDbById = lunsFromDb.stream().collect(Collectors.toMap(LUNs::getLUNId, Function.identity()));
    for (LUNs lun : luns) {
        if (lunsFromDbById.containsKey(lun.getLUNId())) {
            LUNs lunFromDb = lunsFromDbById.get(lun.getLUNId());
            lun.setDiskId(lunFromDb.getDiskId());
            lun.setDiskAlias(lunFromDb.getDiskAlias());
            lun.setStorageDomainId(lunFromDb.getStorageDomainId());
            lun.setStorageDomainName(lunFromDb.getStorageDomainName());
        }
        returnValue.add(lun);
    }
    getQueryReturnValue().setReturnValue(returnValue);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)

Example 79 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class GetLunsByVgIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<LUNs> luns = lunDao.getAllForVolumeGroup(getVgId());
    List<LUNs> nonDummyLuns = new ArrayList<>(luns.size());
    StorageType storageType = getStorageType(luns);
    Map<String, LUNs> lunsFromDeviceMap = getLunsFromDeviceMap(storageType);
    for (LUNs lun : luns) {
        // Filter dummy luns
        if (lun.getLUNId().startsWith(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX)) {
            continue;
        }
        nonDummyLuns.add(lun);
        // Update LUN's connections
        for (LUNStorageServerConnectionMap map : storageServerConnectionLunMapDao.getAll(lun.getLUNId())) {
            addConnection(lun, storageServerConnectionDao.get(map.getStorageServerConnection()));
        }
        // Update LUN's 'PathsDictionary' by 'lunsFromDeviceList'
        LUNs lunFromDeviceList = lunsFromDeviceMap.get(lun.getLUNId());
        if (lunFromDeviceList != null) {
            lun.setPathsDictionary(lunFromDeviceList.getPathsDictionary());
            lun.setPathsCapacity(lunFromDeviceList.getPathsCapacity());
            lun.setPvSize(lunFromDeviceList.getPvSize());
        }
    }
    setReturnValue(nonDummyLuns);
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 80 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class GetLunsByVgIdQuery method getLunsFromDeviceMap.

protected Map<String, LUNs> getLunsFromDeviceMap(StorageType storageType) {
    Map<String, LUNs> lunsMap = new HashMap<>();
    if (getParameters().getId() == null) {
        return lunsMap;
    }
    GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(getParameters().getId(), storageType);
    List<LUNs> lunsList = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
    for (LUNs lun : lunsList) {
        lunsMap.put(lun.getLUNId(), lun);
    }
    return lunsMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)

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