Search in sources :

Example 96 with StorageServerConnections

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

the class StorageDomainMapperTest method checkISCSIStorageConnectionsMappings.

@Test
public void checkISCSIStorageConnectionsMappings() {
    StorageServerConnections connection = new StorageServerConnections();
    Guid connId = Guid.newGuid();
    connection.setId(connId.toString());
    connection.setIqn("iqn.my.target1");
    connection.setPort("3260");
    connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI);
    connection.setConnection("1.2.135.255");
    connection.setUserName("myuser1");
    connection.setPassword("123");
    HostStorage RESTConnection = new HostStorage();
    RESTConnection.setId(connId.toString());
    RESTConnection.setType(StorageType.ISCSI);
    RESTConnection.setPort(3260);
    RESTConnection.setTarget("iqn.my.target1");
    RESTConnection.setAddress("1.2.135.255");
    RESTConnection.setUsername("myuser1");
    StorageConnection mappedResult = StorageDomainMapper.map(connection, null);
    assertEquals(RESTConnection.getId(), mappedResult.getId());
    // Although password was set on StorageServerConnections object, it should not be returned via REST
    // thus testing here that it remains empty.
    assertEquals(RESTConnection.getPassword(), mappedResult.getPassword());
    assertEquals(RESTConnection.getType(), mappedResult.getType());
    assertEquals(RESTConnection.getAddress(), mappedResult.getAddress());
    assertEquals(RESTConnection.getUsername(), mappedResult.getUsername());
    assertEquals(RESTConnection.getTarget(), mappedResult.getTarget());
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 97 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommand method validate.

@Override
protected boolean validate() {
    StorageServerConnections newConnectionDetails = getConnection();
    StorageType storageType = newConnectionDetails.getStorageType();
    if (!storageType.isFileDomain() && !storageType.equals(StorageType.ISCSI)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE);
    }
    if (!isValidConnection(newConnectionDetails)) {
        return false;
    }
    // Check if connection exists by id, otherwise there's nothing to update
    String connectionId = newConnectionDetails.getId();
    StorageServerConnections oldConnection = storageServerConnectionDao.get(connectionId);
    if (oldConnection == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST);
    }
    if (!newConnectionDetails.getStorageType().equals(oldConnection.getStorageType())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE);
    }
    Guid storagePoolId = getStoragePoolIdByFileConnectionId(oldConnection.getId());
    if (isConnWithSameDetailsExists(newConnectionDetails, storagePoolId)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS);
    }
    if (doDomainsUseConnection(newConnectionDetails) || doLunsUseConnection()) {
        if (storageType.isFileDomain() && domains.size() > 1) {
            String domainNames = createDomainNamesList(domains);
            addValidationMessageVariable("domainNames", domainNames);
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS);
        }
        // Check that the storage domain is in proper state to be edited
        if (!isConnectionEditable(newConnectionDetails)) {
            return false;
        }
    }
    return super.validate();
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Guid(org.ovirt.engine.core.compat.Guid)

Example 98 with StorageServerConnections

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

Example 99 with StorageServerConnections

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

the class FileStorageHelper method runConnectionStorageToDomain.

@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type) {
    Pair<Boolean, EngineFault> result;
    StorageServerConnections connection = storageServerConnectionDao.get(storageDomain.getStorage());
    if (connection != null) {
        ActionReturnValue returnValue = backend.runInternalAction(ActionType.forValue(type), new StorageServerConnectionParametersBase(connection, vdsId, false));
        result = new Pair<>(returnValue.getSucceeded(), returnValue.getFault());
    } else {
        result = new Pair<>(false, null);
        log.warn("Did not connect host '{}' to storage domain '{}' because connection for connectionId '{}' is null.", vdsId, storageDomain.getStorageName(), storageDomain.getStorage());
    }
    return result;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 100 with StorageServerConnections

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

the class ISCSIStorageHelper method storageDomainRemoved.

@Override
public boolean storageDomainRemoved(StorageDomainStatic storageDomain) {
    List<StorageServerConnections> list = storageServerConnectionDao.getAllForVolumeGroup(storageDomain.getStorage());
    for (StorageServerConnections connection : filterConnectionsUsedByOthers(list, storageDomain.getStorage(), "")) {
        storageServerConnectionDao.remove(connection.getId());
    }
    // There is no need to remove entries from lun_storage_server_connection_map,
    // as the foreign key from the luns table is defined as ON DELETE CASCADE.
    removeStorageDomainLuns(storageDomain);
    return true;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections)

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