Search in sources :

Example 86 with StorageServerConnections

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

the class RemoveStorageServerConnectionCommand method validate.

@Override
protected boolean validate() {
    String connectionId = getConnection().getId();
    List<StorageDomain> domains = null;
    if (StringUtils.isEmpty(connectionId)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY);
    }
    StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
    if (connection == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST);
    }
    // if user passed only the connection id for removal, vdsm still needs few more details in order to disconnect, so
    // bringing them from db and repopulating them in the connection object received in input parameters
    populateMissingFields(connection);
    StorageType storageType = connection.getStorageType();
    if (storageType.isFileDomain()) {
        // go to storage domain static, get all storage domains where storage field  = storage connection id
        domains = getStorageDomainsByConnId(connectionId);
        if (domains.size() > 0) {
            String domainNames = createDomainNamesListFromStorageDomains(domains);
            return prepareFailureMessageForDomains(domainNames);
        }
    } else if (storageType.equals(StorageType.ISCSI)) {
        List<String> domainNames = new ArrayList<>();
        List<String> diskNames = new ArrayList<>();
        // go to luns to storage connections map table, get it from there
        List<LUNs> luns = lunDao.getAllForStorageServerConnection(connectionId);
        if (!luns.isEmpty()) {
            String volumeGroupId = null;
            for (LUNs lun : luns) {
                volumeGroupId = lun.getVolumeGroupId();
                if (StringUtils.isNotEmpty(volumeGroupId)) {
                    // non empty vg id indicates there's a storage domain using the lun
                    String domainName = lun.getStorageDomainName();
                    domainNames.add(domainName);
                } else {
                    // empty vg id indicates there's a lun disk using the lun
                    String lunDiskName = lun.getDiskAlias();
                    diskNames.add(lunDiskName);
                }
            }
            String domainNamesForMessage = null;
            if (!domainNames.isEmpty()) {
                // Build domain names list to display in the error
                domainNamesForMessage = prepareEntityNamesForMessage(domainNames);
                if (diskNames.isEmpty()) {
                    return prepareFailureMessageForDomains(domainNamesForMessage);
                } else {
                    String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
                    return prepareFailureMessageForDomainsAndDisks(domainNamesForMessage, diskNamesForMessage);
                }
            } else if (!diskNames.isEmpty()) {
                String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
                return prepareFailureMessageForDisks(diskNamesForMessage);
            }
        }
    }
    return true;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) List(java.util.List) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 87 with StorageServerConnections

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

the class DetachStorageConnectionFromStorageDomainCommand method createStorageConnectionValidator.

protected StorageConnectionValidator createStorageConnectionValidator() {
    String connectionId = getParameters().getStorageConnectionId();
    StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
    return new StorageConnectionValidator(connection);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageConnectionValidator(org.ovirt.engine.core.bll.validator.storage.StorageConnectionValidator)

Example 88 with StorageServerConnections

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

the class StorageServerConnectionDaoTest method testGetForIqnWithInvalidIqn.

@Test
public void testGetForIqnWithInvalidIqn() {
    StorageServerConnections result = dao.getForIqn("farkle");
    assertNull(result);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Test(org.junit.Test)

Example 89 with StorageServerConnections

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

the class StorageServerConnectionDaoTest method generateNewEntity.

@Override
protected StorageServerConnections generateNewEntity() {
    StorageServerConnections newServerConnection = new StorageServerConnections();
    newServerConnection.setId("0cc146e8-e5ed-482c-8814-270bc48c2980");
    newServerConnection.setConnection(EXISTING_DOMAIN_STORAGE_NAME);
    newServerConnection.setNfsVersion(NfsVersion.V4);
    newServerConnection.setNfsRetrans((short) 5);
    return newServerConnection;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections)

Example 90 with StorageServerConnections

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

the class StorageServerConnectionDaoTest method testGetForIqn.

@Test
public void testGetForIqn() {
    StorageServerConnections result = dao.getForIqn(existingEntity.getIqn());
    assertNotNull(result);
    assertEquals(existingEntity, result);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Test(org.junit.Test)

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