Search in sources :

Example 76 with StorageServerConnections

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

the class BackendAttachedStorageDomainsResourceTest method setUpStorageServerConnection.

static StorageServerConnections setUpStorageServerConnection() {
    StorageServerConnections cnx = new StorageServerConnections();
    cnx.setId(GUIDS[0].toString());
    cnx.setConnection("10.11.12.13" + ":" + "/1");
    return cnx;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections)

Example 77 with StorageServerConnections

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

the class StorageDomainMapper method map.

@Mapping(from = StorageConnection.class, to = StorageServerConnections.class)
public static StorageServerConnections map(StorageConnection model, StorageServerConnections template) {
    StorageServerConnections entity = template != null ? template : new StorageServerConnections();
    if (model.isSetId()) {
        entity.setId(model.getId());
    }
    org.ovirt.engine.core.common.businessentities.storage.StorageType storageType = null;
    if (model.getType() != null) {
        storageType = map(model.getType(), null);
    } else if (template != null) {
        storageType = template.getStorageType();
    }
    if (storageType != null) {
        entity.setStorageType(storageType);
        switch(storageType) {
            case ISCSI:
                if (model.isSetAddress()) {
                    entity.setConnection(model.getAddress());
                }
                if (model.isSetPort()) {
                    entity.setPort(model.getPort().toString());
                }
                if (model.isSetUsername()) {
                    entity.setUserName(model.getUsername());
                }
                if (model.isSetTarget()) {
                    entity.setIqn(model.getTarget());
                }
                if (model.isSetPassword()) {
                    entity.setPassword(model.getPassword());
                }
                break;
            case FCP:
                break;
            case NFS:
                // in case of update, one or both of the address/path fields might be updated.
                // thus, need to take care of their assignment separately since they are merged
                // in the backend into a single field.
                String[] parts = null;
                if (!StringUtils.isEmpty(entity.getConnection())) {
                    parts = entity.getConnection().split(":");
                }
                String address = null;
                String path = null;
                if (model.isSetAddress()) {
                    address = model.getAddress();
                } else {
                    address = parts != null ? parts[0] : "";
                }
                if (model.isSetPath()) {
                    path = model.getPath();
                } else {
                    path = parts != null ? parts[1] : "";
                }
                entity.setConnection(address + ":" + path);
                if (model.getNfsRetrans() != null) {
                    entity.setNfsRetrans(model.getNfsRetrans().shortValue());
                }
                if (model.getNfsTimeo() != null) {
                    entity.setNfsTimeo(model.getNfsTimeo().shortValue());
                }
                if (model.getNfsVersion() != null) {
                    entity.setNfsVersion(map(model.getNfsVersion(), null));
                }
                if (model.isSetMountOptions()) {
                    entity.setMountOptions(model.getMountOptions());
                }
                break;
            case LOCALFS:
                if (model.isSetPath()) {
                    entity.setConnection(model.getPath());
                }
                break;
            case POSIXFS:
            case GLUSTERFS:
                if (model.isSetAddress() && model.isSetPath()) {
                    entity.setConnection(model.getAddress() + ":" + model.getPath());
                } else if (model.isSetPath()) {
                    entity.setConnection(model.getPath());
                }
                if (model.isSetMountOptions()) {
                    entity.setMountOptions(model.getMountOptions());
                }
                if (model.isSetVfsType()) {
                    entity.setVfsType(model.getVfsType());
                }
                break;
            default:
                break;
        }
    }
    return entity;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections)

Example 78 with StorageServerConnections

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

the class AddStorageServerConnectionCommand method validate.

@Override
protected boolean validate() {
    StorageServerConnections paramConnection = getConnection();
    // if an id was sent - it's not ok since only the backend should allocate ids
    if (StringUtils.isNotEmpty(paramConnection.getId())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY);
    }
    if (!isValidConnection(paramConnection)) {
        return false;
    }
    Guid storagePoolId = Guid.isNullOrEmpty(getParameters().getVdsId()) ? null : getVds().getStoragePoolId();
    if (isConnWithSameDetailsExists(paramConnection, storagePoolId)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS);
    }
    // validate that it's a valid VDS ID and that the VDS is up.
    if (!Guid.isNullOrEmpty(getParameters().getVdsId())) {
        if (getVds() == null) {
            return failValidation(EngineMessage.VDS_INVALID_SERVER_ID);
        }
        if (getVds().getStatus() != VDSStatus.Up) {
            return failValidation(EngineMessage.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP);
        }
    }
    return true;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Guid(org.ovirt.engine.core.compat.Guid)

Example 79 with StorageServerConnections

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

the class AddStorageServerConnectionCommand method executeCommand.

@Override
protected void executeCommand() {
    // If not, just save the connection to the database
    if (!Guid.isNullOrEmpty(getParameters().getVdsId())) {
        Pair<Boolean, Integer> result = connectHostToStorage();
        boolean isValidConnection = result.getFirst();
        // Process failure
        if (!isValidConnection) {
            throw new EngineException(EngineError.forValue(result.getSecond()));
        }
    }
    StorageServerConnections connection = getConnection();
    connection.setId(Guid.newGuid().toString());
    saveConnection(connection);
    getReturnValue().setActionReturnValue(connection.getId());
    setSucceeded(true);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 80 with StorageServerConnections

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

Aggregations

StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)181 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)43 Guid (org.ovirt.engine.core.compat.Guid)39 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)33 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)32 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)19 List (java.util.List)18 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)14 HashSet (java.util.HashSet)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 Set (java.util.Set)10 StorageConnection (org.ovirt.engine.api.model.StorageConnection)10 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)10 QueryType (org.ovirt.engine.core.common.queries.QueryType)10