Search in sources :

Example 1 with LUNs

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

the class LunDisksMonitoring method getVmLunDisksToSave.

List<LUNs> getVmLunDisksToSave(Guid vmId, Map<String, LUNs> lunsMap) {
    if (lunsMap.isEmpty()) {
        // LUNs list from getVmStats hasn't been updated yet or VDSM doesn't support LUNs list retrieval.
        return Collections.emptyList();
    }
    List<LUNs> vmLunDisksToSave = new ArrayList<>();
    getVmPluggedLunsFromDb(vmId).forEach(lunFromDB -> {
        LUNs lunFromMap = lunsMap.get(lunFromDB.getId());
        // Hence, verify before updating.
        if (lunFromMap.getDeviceSize() != 0 && lunFromMap.getDeviceSize() != lunFromDB.getDeviceSize()) {
            // Found a mismatch - set LUN for update
            log.info("Updated LUN device size - ID: '{}', previous size: '{}', new size: '{}'.", lunFromDB.getLUNId(), lunFromDB.getDeviceSize(), lunFromMap.getDeviceSize());
            lunFromDB.setDeviceSize(lunFromMap.getDeviceSize());
            vmLunDisksToSave.add(lunFromDB);
        }
    });
    return vmLunDisksToSave;
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 2 with LUNs

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

the class ImportVmCommand method validateLunExistsAndInitDeviceData.

private boolean validateLunExistsAndInitDeviceData(LUNs lun, StorageType storageType, Guid vdsId) {
    List<LUNs> lunFromStorage = null;
    try {
        StorageServerConnectionManagementVDSParameters connectParams = new StorageServerConnectionManagementVDSParameters(vdsId, Guid.Empty, storageType, lun.getLunConnections());
        runVdsCommand(VDSCommandType.ConnectStorageServer, connectParams);
        GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vdsId, storageType, false, Collections.singleton(lun.getLUNId()));
        lunFromStorage = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
    } catch (Exception e) {
        log.debug("Exception while validating LUN disk: '{}'", e);
        return false;
    }
    if (lunFromStorage == null || lunFromStorage.isEmpty()) {
        return false;
    } else {
        LUNs luns = lunFromStorage.get(0);
        lun.setSerial(luns.getSerial());
        lun.setLunMapping(luns.getLunMapping());
        lun.setVendorId(luns.getVendorId());
        lun.setProductId(luns.getProductId());
        lun.setProductId(luns.getProductId());
        lun.setDiscardMaxSize(luns.getDiscardMaxSize());
        lun.setPvSize(luns.getPvSize());
    }
    return true;
}
Also used : StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 3 with LUNs

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

the class RefreshLunsSizeCommand method checkLunsInStorageDomain.

private boolean checkLunsInStorageDomain(Set<String> lunIds) {
    // Get LUNs from DB
    getParameters().setLunsList(new ArrayList<>(lunDao.getAllForVolumeGroup(getStorageDomain().getStorage())));
    Set<String> lunsSet = new HashSet<>(lunIds);
    for (LUNs lun : getParameters().getLunsList()) {
        if (lunsSet.contains(lun.getLUNId())) {
            // LUN is part of the storage domain
            lunsSet.remove(lun.getLUNId());
        }
    }
    return lunsSet.isEmpty();
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HashSet(java.util.HashSet)

Example 4 with LUNs

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

the class RefreshLunsSizeCommand method getDeviceListAllVds.

/**
 *        This  method calls GetDeviceList with the specified luns on all hosts.
 *        In VDSM , this call will resize the devices if needed.
 *        It returns a map of LUN ID to a list of Pair(VDS,LUNs)
 *        This map will help to check if all hosts are seeing the same size of the LUNs.
 */
private Map<String, List<Pair<VDS, LUNs>>> getDeviceListAllVds(Set<String> lunsToResize) {
    Map<String, List<Pair<VDS, LUNs>>> lunToVds = new HashMap<>();
    for (VDS vds : getAllRunningVdssInPool()) {
        GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vds.getId(), getStorageDomain().getStorageType(), false, lunsToResize);
        List<LUNs> luns = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
        for (LUNs lun : luns) {
            lunToVds.computeIfAbsent(lun.getLUNId(), k -> new ArrayList<>()).add(new Pair<>(vds, lun));
        }
    }
    return lunToVds;
}
Also used : NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) StorageDomainDynamicDao(org.ovirt.engine.core.dao.StorageDomainDynamicDao) Guid(org.ovirt.engine.core.compat.Guid) EngineException(org.ovirt.engine.core.common.errors.EngineException) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters) Map(java.util.Map) Pair(org.ovirt.engine.core.common.utils.Pair) GetStorageDomainStatsVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetStorageDomainStatsVDSCommandParameters) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) Collectors(java.util.stream.Collectors) EngineError(org.ovirt.engine.core.common.errors.EngineError) LunDao(org.ovirt.engine.core.dao.LunDao) List(java.util.List) ResizeStorageDomainPVVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ResizeStorageDomainPVVDSCommandParameters) Optional(java.util.Optional) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) VDS(org.ovirt.engine.core.common.businessentities.VDS) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) 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 5 with LUNs

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

the class GetUnregisteredBlockStorageDomainsQuery method getDeviceList.

/**
 * Get devices (LUNs) that are visible by the host.
 *
 * @return the list of LUNs.
 */
protected List<LUNs> getDeviceList() {
    List<LUNs> luns = new ArrayList<>();
    QueryReturnValue returnValue = executeGetDeviceList(new GetDeviceListQueryParameters(getParameters().getVdsId(), getParameters().getStorageType(), false, null, false));
    if (returnValue.getSucceeded()) {
        luns.addAll(returnValue.<List<LUNs>>getReturnValue());
    } else {
        throw new RuntimeException(String.format("GetDeviceList execution failed. Exception message: %1$s", returnValue.getExceptionString()));
    }
    return luns;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) 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