Search in sources :

Example 1 with LUNStorageServerConnectionMap

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

the class GetLunsByVgIdQuery method getStorageType.

private StorageType getStorageType(List<LUNs> luns) {
    StorageType storageType = null;
    if (!luns.isEmpty()) {
        LUNs lun = luns.get(0);
        List<LUNStorageServerConnectionMap> lunConnections = storageServerConnectionLunMapDao.getAll(lun.getLUNId());
        if (!lunConnections.isEmpty()) {
            StorageServerConnections connection = storageServerConnectionDao.get(lunConnections.get(0).getStorageServerConnection());
            storageType = connection.getStorageType();
        } else {
            storageType = StorageType.FCP;
        }
    }
    return storageType;
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 2 with LUNStorageServerConnectionMap

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

the class ISCSIStorageHelper method isConnectSucceeded.

@Override
public boolean isConnectSucceeded(final Map<String, String> returnValue, List<StorageServerConnections> connections) {
    boolean result = true;
    List<String> failedConnectionsList = returnValue.keySet().stream().filter(a -> !"0".equals(returnValue.get(a))).collect(Collectors.toList());
    for (String failedConnection : failedConnectionsList) {
        List<LUNs> failedLuns = lunDao.getAllForStorageServerConnection(failedConnection);
        if (!failedLuns.isEmpty()) {
            for (LUNs lun : failedLuns) {
                // TODO: check if LUNs in the same pool.
                List<String> strings = storageServerConnectionLunMapDao.getAll(lun.getLUNId()).stream().map(LUNStorageServerConnectionMap::getStorageServerConnection).collect(Collectors.toList());
                if (CollectionUtils.subtract(strings, failedConnectionsList).size() == 0) {
                    // At case of failure the appropriate log message will be
                    // added
                    log.info("The lun with id '{}' was reported as problematic", lun.getPhysicalVolumeId());
                    for (String connectionFailed : failedConnectionsList) {
                        String connectionField = addToAuditLogErrorMessage(connectionFailed, returnValue.get(connectionFailed), connections, lun);
                        printLog(log, connectionField, returnValue.get(connectionFailed));
                    }
                    return false;
                }
            }
        } else {
            result = false;
            printLog(log, failedConnection, returnValue.get(failedConnection));
        }
    }
    return result;
}
Also used : ConnectHostToStoragePoolServersParameters(org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) CollectionUtils(org.apache.commons.collections.CollectionUtils) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Map(java.util.Map) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) Pair(org.ovirt.engine.core.common.utils.Pair) StorageServerConnectionLunMapDao(org.ovirt.engine.core.dao.StorageServerConnectionLunMapDao) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SyncLunsInfoForBlockStorageDomainParameters(org.ovirt.engine.core.common.action.SyncLunsInfoForBlockStorageDomainParameters) Logger(org.slf4j.Logger) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) HostStoragePoolParametersBase(org.ovirt.engine.core.common.action.HostStoragePoolParametersBase) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) InterfaceDao(org.ovirt.engine.core.dao.network.InterfaceDao) Collections(java.util.Collections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 3 with LUNStorageServerConnectionMap

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

the class GetLunsByVgIdQueryTest method expectGetLunsMap.

private void expectGetLunsMap(String lunId, String cnxId) {
    List<LUNStorageServerConnectionMap> ret = new ArrayList<>();
    LUNStorageServerConnectionMap map = new LUNStorageServerConnectionMap();
    map.setLunId(lunId);
    map.setStorageServerConnection(cnxId);
    ret.add(map);
    when(storageServerConnectionLunMapDao.getAll(lunId)).thenReturn(ret);
}
Also used : ArrayList(java.util.ArrayList) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 4 with LUNStorageServerConnectionMap

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

the class AttachStorageConnectionToStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    // Create a dummy lun
    LUNs dummyLun = createDummyLun();
    // Create storage server connection mapping
    LUNStorageServerConnectionMap connectionMapRecord = new LUNStorageServerConnectionMap(dummyLun.getLUNId(), getParameters().getStorageConnectionId());
    List<StorageServerConnections> connectionsForDomain;
    if (lunDao.get(dummyLun.getLUNId()) == null) {
        lunDao.save(dummyLun);
        // Save connection maps when creating the dummy lun for the first time
        connectionsForDomain = storageServerConnectionDao.getAllForDomain(getStorageDomainId());
        for (StorageServerConnections connection : connectionsForDomain) {
            saveConnection(new LUNStorageServerConnectionMap(dummyLun.getLUNId(), connection.getId()));
        }
    }
    // Save new connection map
    saveConnection(connectionMapRecord);
    setSucceeded(true);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

Example 5 with LUNStorageServerConnectionMap

use of org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap 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)

Aggregations

LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)9 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)6 ArrayList (java.util.ArrayList)4 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)3 Test (org.junit.Test)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 ConnectHostToStoragePoolServersParameters (org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters)1 HostStoragePoolParametersBase (org.ovirt.engine.core.common.action.HostStoragePoolParametersBase)1