Search in sources :

Example 31 with StoragePool

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

the class BackendOpenStackVolumeProvidersResource method getStoragePoolIdByStorageDomainName.

private StoragePool getStoragePoolIdByStorageDomainName(String storageDomainName) {
    StorageDomainStatic storageDomain = getEntity(StorageDomainStatic.class, QueryType.GetStorageDomainByName, new NameQueryParameters(storageDomainName), "StorageDomain: name=" + storageDomainName);
    List<StoragePool> storagePools = getEntity(List.class, QueryType.GetStoragePoolsByStorageDomainId, new IdQueryParameters(storageDomain.getId()), "Datacenters");
    if (!storagePools.isEmpty()) {
        return storagePools.get(0);
    }
    // The storage domain is unattached
    return null;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) NameQueryParameters(org.ovirt.engine.core.common.queries.NameQueryParameters)

Example 32 with StoragePool

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

the class BackendOpenStackVolumeProvidersResource method getStoragePool.

public StoragePool getStoragePool(DataCenter dataCenter) {
    StoragePool pool = null;
    if (dataCenter.isSetId()) {
        Guid id = asGuid(dataCenter.getId());
        pool = getEntity(StoragePool.class, QueryType.GetStoragePoolById, new IdQueryParameters(id), "Datacenter: id=" + dataCenter.getId());
    } else if (dataCenter.isSetName()) {
        pool = getEntity(StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(dataCenter.getName()), "Datacenter: name=" + dataCenter.getName());
    }
    if (pool == null) {
        notFound(DataCenter.class);
    }
    return pool;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) NameQueryParameters(org.ovirt.engine.core.common.queries.NameQueryParameters)

Example 33 with StoragePool

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

the class BackendOpenStackVolumeProvidersResource method add.

@Override
public Response add(OpenStackVolumeProvider provider) {
    validateParameters(provider, "name");
    if (provider.isSetDataCenter()) {
        StoragePool storagePool = getStoragePool(provider.getDataCenter());
        provider.setDataCenter(DataCenterMapper.map(storagePool, null));
    }
    return performCreate(ActionType.AddProvider, new ProviderParameters(map(provider)), new QueryIdResolver<Guid>(QueryType.GetProviderById, IdQueryParameters.class));
}
Also used : ProviderParameters(org.ovirt.engine.core.common.action.ProviderParameters) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 34 with StoragePool

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

the class BackendStorageDomainDisksResourceTest method testListUnregistered.

@Test
public void testListUnregistered() throws Exception {
    setUriInfo(addMatrixParameterExpectations(setUpBasicUriExpectations(), BackendStorageDomainDisksResource.UNREGISTERED));
    StoragePool storagePool = new StoragePool();
    storagePool.setId(storagePoolId);
    setUpEntityQueryExpectations(QueryType.GetStoragePoolsByStorageDomainId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[3] }, Collections.singletonList(storagePool));
    List<org.ovirt.engine.core.common.businessentities.storage.Disk> entities = new ArrayList<>();
    for (int i = 0; i < NAMES.length; i++) {
        entities.add(getEntity(i));
    }
    setUpEntityQueryExpectations(QueryType.GetUnregisteredDisks, GetUnregisteredDisksQueryParameters.class, new String[] { "StorageDomainId", "StoragePoolId" }, new Object[] { GUIDS[3], storagePoolId }, entities);
    verifyCollection(getCollection());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 35 with StoragePool

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

the class BackendStorageDomainImageResourceTest method getStoragePoolList.

public static List<StoragePool> getStoragePoolList() {
    return new ArrayList<StoragePool>() {

        private static final long serialVersionUID = 4817230014440543623L;

        {
            StoragePool storagePool = new StoragePool();
            storagePool.setId(STORAGE_POOL_ID);
            add(storagePool);
        }
    };
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList)

Aggregations

StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)239 Guid (org.ovirt.engine.core.compat.Guid)83 ArrayList (java.util.ArrayList)78 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)60 Test (org.junit.Test)59 List (java.util.List)46 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)34 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)31 QueryType (org.ovirt.engine.core.common.queries.QueryType)31 Frontend (org.ovirt.engine.ui.frontend.Frontend)31 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)28 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)28 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)27 Linq (org.ovirt.engine.ui.uicommonweb.Linq)26 Arrays (java.util.Arrays)25 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)25