Search in sources :

Example 6 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class AddStorageDomainCommand method connectStorage.

protected Pair<Boolean, Integer> connectStorage() {
    String connectionId = getStorageDomain().getStorage();
    StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
    Map<String, String> result = (Map<String, String>) runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(getParameters().getVdsId(), Guid.Empty, connection.getStorageType(), new ArrayList<>(Collections.singletonList(connection)))).getReturnValue();
    return new Pair<>(storageHelperDirector.getItem(connection.getStorageType()).isConnectSucceeded(result, Collections.singletonList(connection)), Integer.parseInt(result.values().iterator().next()));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) ArrayList(java.util.ArrayList) Map(java.util.Map) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 7 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class UpdateStorageServerConnectionCommand method disconnectFromStorage.

protected void disconnectFromStorage() {
    StorageServerConnectionManagementVDSParameters connectionParametersForVdsm = createParametersForVdsm(getParameters().getVdsId(), Guid.Empty, getConnection().getStorageType(), getConnection());
    boolean isDisconnectSucceeded = runVdsCommand(VDSCommandType.DisconnectStorageServer, connectionParametersForVdsm).getSucceeded();
    if (!isDisconnectSucceeded) {
        log.warn("Failed to disconnect storage connection {}", getConnection());
    }
}
Also used : StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)

Example 8 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class BaseIscsiBondCommand method connectAllHostsToStorage.

protected void connectAllHostsToStorage(List<String> connectionIds) {
    List<Callable<Void>> tasks = new ArrayList<>();
    final List<StorageServerConnections> connections = storageServerConnectionDao.getByIds(connectionIds);
    List<VDS> hosts = vdsDao.getAllForStoragePoolAndStatus(getIscsiBond().getStoragePoolId(), VDSStatus.Up);
    for (final VDS host : hosts) {
        tasks.add(() -> {
            try {
                final List<StorageServerConnections> conns = iscsiStorageHelper.updateIfaces(connections, host.getId());
                VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(host.getId(), Guid.Empty, StorageType.ISCSI, conns));
                final Map<String, String> iscsiMap = (Map<String, String>) returnValue.getReturnValue();
                List<String> failedConnectionsList = iscsiMap.entrySet().stream().filter(e -> !"0".equals(e.getValue())).map(Map.Entry::getKey).collect(Collectors.toList());
                if (!failedConnectionsList.isEmpty()) {
                    log.error("Host '{}' - '{}' encounter problems to connect to the iSCSI Storage" + " Server. The following connections were problematic" + "" + " (connectionid=vdsm result): {}", host.getName(), host.getId(), iscsiMap.toString());
                    encounterConnectionProblems = true;
                }
            } catch (EngineException e) {
                log.error("Could not connect Host '{}' - '{}' to Iscsi Storage Server: {}", host.getName(), host.getId(), e.getMessage());
                log.debug("Exception", e);
                encounterConnectionProblems = true;
            }
            return null;
        });
    }
    ThreadPoolUtil.invokeAll(tasks);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) Callable(java.util.concurrent.Callable) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) Map(java.util.Map)

Example 9 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class ISCSIStorageHelper method runConnectionStorageToDomain.

@SuppressWarnings("unchecked")
@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) {
    boolean isSuccess = true;
    VDSReturnValue returnValue = null;
    List<StorageServerConnections> list = (lun == null) ? storageServerConnectionDao.getAllForVolumeGroup(storageDomain.getStorage()) : lun.getLunConnections();
    if (list.size() != 0) {
        if (VDSCommandType.forValue(type) == VDSCommandType.DisconnectStorageServer) {
            list = filterConnectionsUsedByOthers(list, storageDomain.getStorage(), lun != null ? lun.getLUNId() : "");
        } else if (VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
            list = updateIfaces(list, vdsId);
        }
        Guid poolId = storagePoolId;
        if (storageDomain != null && storageDomain.getStoragePoolId() != null) {
            poolId = storageDomain.getStoragePoolId();
        }
        returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, poolId, StorageType.ISCSI, list));
        isSuccess = returnValue.getSucceeded();
        if (isSuccess && VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
            isSuccess = isConnectSucceeded((Map<String, String>) returnValue.getReturnValue(), list);
        }
    }
    EngineFault engineFault = null;
    if (!isSuccess && returnValue.getVdsError() != null) {
        engineFault = new EngineFault();
        engineFault.setError(returnValue.getVdsError().getCode());
    }
    return new Pair<>(isSuccess, engineFault);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) Guid(org.ovirt.engine.core.compat.Guid) Map(java.util.Map) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 10 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class ConnectStorageToVdsCommand method connectHostToStorage.

protected Pair<Boolean, Integer> connectHostToStorage() {
    List<StorageServerConnections> connections = Arrays.asList(getConnection());
    if (getConnection().getStorageType() == StorageType.ISCSI) {
        connections = iscsiStorageHelper.updateIfaces(connections, getVds().getId());
    }
    Map<String, String> result = (HashMap<String, String>) runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), Guid.Empty, getConnection().getStorageType(), connections)).getReturnValue();
    return new Pair<>(storageHelperDirector.getItem(getConnection().getStorageType()).isConnectSucceeded(result, connections), Integer.parseInt(result.values().iterator().next()));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) HashMap(java.util.HashMap) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)13 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)9 ArrayList (java.util.ArrayList)7 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)5 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)5 Map (java.util.Map)4 Test (org.junit.Test)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Guid (org.ovirt.engine.core.compat.Guid)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 Callable (java.util.concurrent.Callable)1