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()));
}
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());
}
}
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);
}
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);
}
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()));
}
Aggregations