Search in sources :

Example 66 with StorageDomainStatic

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

the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testUnattachedStorageDomainWithStorageDomainsParameterQuery.

@Test
public void testUnattachedStorageDomainWithStorageDomainsParameterQuery() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Up);
    mockStoragePoolDao(storagePool);
    // Create parameters
    List<StorageDomain> storageDomainList = new ArrayList<>();
    storageDomainList.add(storageDomain);
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
    // Run 'HSMGetStorageDomainInfo' command
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), null);
    returnValue.setReturnValue(storageDomainToPoolId);
    when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 67 with StorageDomainStatic

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

the class BackendStorageDomainsResource method addExistingSAN.

private Response addExistingSAN(StorageDomain model, StorageType storageType, Guid hostId) {
    getEntity(VDS.class, QueryType.GetVdsByVdsId, new IdQueryParameters(hostId), "Host: id=" + hostId);
    List<LUNs> existingLuns = getDeviceList(hostId, storageType);
    List<StorageServerConnections> existingStorageServerConnections = getLunsWithInitializedStorageType(existingLuns, storageType);
    List<org.ovirt.engine.core.common.businessentities.StorageDomain> existingStorageDomains = getExistingBlockStorageDomain(hostId, storageType, existingStorageServerConnections);
    StorageDomainStatic storageDomainToImport = getMatchingStorageDomain(asGuid(model.getId()), existingStorageDomains);
    if (storageDomainToImport == null) {
        throw new WebFaultException(new WebApplicationException(), "Storage Domain id " + model.getId() + " Does not exists", Status.NOT_FOUND);
    }
    StorageDomainMapper.map(model, storageDomainToImport);
    StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storageDomainToImport);
    parameters.setVdsId(hostId);
    return performCreate(ActionType.AddExistingBlockStorageDomain, parameters, ID_RESOLVER);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) WebApplicationException(javax.ws.rs.WebApplicationException) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters)

Example 68 with StorageDomainStatic

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

the class BackendStorageDomainsResource method add.

@Override
public Response add(StorageDomain storageDomain) {
    validateParameters(storageDomain, "host.id|name", "type", "storage");
    validateRange("nfs_timeio", storageDomain.getStorage().getNfsTimeo(), 0, 65535);
    validateRange("nfs_retrans", storageDomain.getStorage().getNfsRetrans(), 0, 65535);
    HostStorage storageConnectionFromUser = storageDomain.getStorage();
    Guid hostId = getHostId(storageDomain);
    StorageServerConnections cnx = null;
    if (!storageConnectionFromUser.isSetId()) {
        validateParameters(storageDomain, "storage.type");
        cnx = mapToCnx(storageDomain);
        if (cnx.getStorageType().isFileDomain()) {
            validateParameters(storageConnectionFromUser, "path");
        }
    } else {
        cnx = getStorageServerConnection(storageConnectionFromUser.getId());
        storageDomain.getStorage().setType(mapType(cnx.getStorageType()));
    }
    StorageDomainStatic entity = mapToStatic(storageDomain);
    Response resp = null;
    switch(entity.getStorageType()) {
        case ISCSI:
        case FCP:
            if (storageDomain.isSetImport() && storageDomain.isImport()) {
                validateParameters(storageDomain, "id");
                resp = addExistingSAN(storageDomain, entity.getStorageType(), hostId);
            } else {
                resp = addSAN(storageDomain, entity.getStorageType(), entity, hostId);
            }
            break;
        case NFS:
            if (!storageConnectionFromUser.isSetId()) {
                validateParameters(storageDomain.getStorage(), "address");
            }
            resp = addDomain(ActionType.AddNFSStorageDomain, storageDomain, entity, hostId, cnx);
            break;
        case LOCALFS:
            resp = addDomain(ActionType.AddLocalStorageDomain, storageDomain, entity, hostId, cnx);
            break;
        case POSIXFS:
            if (!storageConnectionFromUser.isSetId()) {
                validateParameters(storageDomain.getStorage(), "vfsType");
            }
            resp = addDomain(ActionType.AddPosixFsStorageDomain, storageDomain, entity, hostId, cnx);
            break;
        case GLUSTERFS:
            if (!storageConnectionFromUser.isSetId()) {
                validateParameters(storageDomain.getStorage(), "vfsType");
            }
            resp = addDomain(ActionType.AddGlusterFsStorageDomain, storageDomain, entity, hostId, cnx);
            break;
        default:
            break;
    }
    if (resp != null) {
        addLinks((StorageDomain) resp.getEntity(), getLinksToExclude(storageDomain));
    }
    return resp;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Response(javax.ws.rs.core.Response) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage) Guid(org.ovirt.engine.core.compat.Guid)

Example 69 with StorageDomainStatic

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

the class StorageHandlingCommandBase method updateStorageDomainFormatIfNeeded.

protected void updateStorageDomainFormatIfNeeded(StorageDomain domain) {
    final StorageDomainType sdType = domain.getStorageDomainType();
    if (!sdType.isDataDomain()) {
        log.debug("Skipping format update for domain '{}' (type '{}')", getStorageDomain().getId(), sdType);
        return;
    }
    final StorageDomainStatic storageStaticData = domain.getStorageStaticData();
    final StorageFormatType targetFormat = getStoragePool().getStoragePoolFormatType();
    if (storageStaticData.getStorageFormat() != targetFormat) {
        log.info("Updating storage domain '{}' (type '{}') to format '{}'", getStorageDomain().getId(), sdType, targetFormat);
        storageStaticData.setStorageFormat(targetFormat);
        storageDomainStaticDao.update(storageStaticData);
    } else {
        log.debug("Skipping format update for domain '{}' format is '{}'", getStorageDomain().getId(), storageStaticData.getStorageFormat());
    }
}
Also used : StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType)

Example 70 with StorageDomainStatic

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

the class BackendOpenStackVolumeProviderResourceTest method getStorageDomainStatic.

public StorageDomainStatic getStorageDomainStatic() {
    StorageDomainStatic storageDomainStatic = mock(StorageDomainStatic.class);
    when(storageDomainStatic.getId()).thenReturn(GUIDS[0]);
    when(storageDomainStatic.getName()).thenReturn(NAMES[0]);
    return storageDomainStatic;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic)

Aggregations

StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)92 Guid (org.ovirt.engine.core.compat.Guid)39 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)35 ArrayList (java.util.ArrayList)33 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)31 Test (org.junit.Test)23 Pair (org.ovirt.engine.core.common.utils.Pair)19 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)18 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)14 List (java.util.List)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)13 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)13 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 HashSet (java.util.HashSet)11 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)10