Search in sources :

Example 1 with GetDeviceListVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters 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 2 with GetDeviceListVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters 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 3 with GetDeviceListVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters 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 4 with GetDeviceListVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters 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 5 with GetDeviceListVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters 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)5 GetDeviceListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 HashMap (java.util.HashMap)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 NonTransactiveCommandAttribute (org.ovirt.engine.core.bll.NonTransactiveCommandAttribute)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 CompensationContext (org.ovirt.engine.core.bll.context.CompensationContext)1 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 ExtendSANStorageDomainParameters (org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1