Search in sources :

Example 1 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class BackendAssignedDiskProfilesResource method addParents.

@Override
public DiskProfile addParents(DiskProfile diskProfile) {
    diskProfile.setStorageDomain(new StorageDomain());
    diskProfile.getStorageDomain().setId(storageDomainId);
    return diskProfile;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 2 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class BackendAssignedDiskProfilesResource method add.

@Override
public Response add(DiskProfile diskProfile) {
    if (!diskProfile.isSetStorageDomain() || !diskProfile.getStorageDomain().isSetId()) {
        diskProfile.setStorageDomain(new StorageDomain());
        diskProfile.getStorageDomain().setId(storageDomainId);
    }
    return super.add(diskProfile);
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 3 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class AbstractBackendStorageDomainDiskResource method addParents.

@Override
protected Disk addParents(Disk disk) {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(storageDomainId.toString());
    StorageDomains storageDomains = new StorageDomains();
    storageDomains.getStorageDomains().add(storageDomain);
    disk.setStorageDomain(storageDomain);
    disk.setStorageDomains(storageDomains);
    return disk;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageDomains(org.ovirt.engine.api.model.StorageDomains)

Example 4 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class StorageDomainHelper method addAttachedDataCenterReferences.

/**
 * Adds to the given Storage Domain the references to the Data Centers it is attached to.
 *
 * @param resource the resource that will be used to run the required queries
 * @param model the model of the Storage Domain where the references will be added
 */
public static void addAttachedDataCenterReferences(BackendResource resource, StorageDomain model) {
    // Note that this implementation is far from efficient, as we are retrieving all the content of the Storage
    // Domains and immediately discarding everything but the identifiers of the Data Centers. It would be better to
    // have a query that returns only the identifiers.
    Guid id = Guid.createGuidFromString(model.getId());
    QueryReturnValue result = resource.runQuery(QueryType.GetStorageDomainListById, new IdQueryParameters(id));
    if (result != null && result.getSucceeded()) {
        List<org.ovirt.engine.core.common.businessentities.StorageDomain> storageDomains = result.getReturnValue();
        if (CollectionUtils.isNotEmpty(storageDomains)) {
            DataCenters dataCenters = new DataCenters();
            for (org.ovirt.engine.core.common.businessentities.StorageDomain storageDomain : storageDomains) {
                DataCenter dataCenter = new DataCenter();
                dataCenter.setId(storageDomain.getStoragePoolId().toString());
                dataCenters.getDataCenters().add(dataCenter);
            }
            model.setDataCenters(dataCenters);
        }
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.api.model.StorageDomain) DataCenters(org.ovirt.engine.api.model.DataCenters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DataCenter(org.ovirt.engine.api.model.DataCenter)

Example 5 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class BackendStorageDomainTemplateResourceTest method testImportNotFound.

@Test
public void testImportNotFound() throws Exception {
    Action action = new Action();
    action.setStorageDomain(new StorageDomain());
    action.getStorageDomain().setId(GUIDS[2].toString());
    action.setCluster(new org.ovirt.engine.api.model.Cluster());
    action.getCluster().setId(GUIDS[1].toString());
    setUpGetEntityExpectations(StorageDomainType.ImportExport, GUIDS[2], true);
    setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID);
    try {
        resource.doImport(action);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyNotFoundException(wae);
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) BackendStorageDomainTemplatesResourceTest.setUpStorageDomain(org.ovirt.engine.api.restapi.resource.BackendStorageDomainTemplatesResourceTest.setUpStorageDomain) StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

StorageDomain (org.ovirt.engine.api.model.StorageDomain)88 Test (org.junit.Test)41 WebApplicationException (javax.ws.rs.WebApplicationException)14 Action (org.ovirt.engine.api.model.Action)14 Response (javax.ws.rs.core.Response)13 Host (org.ovirt.engine.api.model.Host)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 Disk (org.ovirt.engine.api.model.Disk)9 StorageDomains (org.ovirt.engine.api.model.StorageDomains)9 BackendStorageDomainVmsResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain)8 HostStorage (org.ovirt.engine.api.model.HostStorage)6 BackendStorageDomainTemplatesResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainTemplatesResourceTest.setUpStorageDomain)6 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)6 DataCenter (org.ovirt.engine.api.model.DataCenter)5 Vm (org.ovirt.engine.api.model.Vm)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)5 Guid (org.ovirt.engine.core.compat.Guid)5 DiskProfile (org.ovirt.engine.api.model.DiskProfile)4 ExportRepoImageParameters (org.ovirt.engine.core.common.action.ExportRepoImageParameters)4 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)4