Search in sources :

Example 26 with StorageDomain

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

the class BackendStorageDomainDiskResource method get.

@Override
public Disk get() {
    Disk disk;
    boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
    if (unregistered) {
        QueryReturnValue result = runQuery(QueryType.GetDiskByDiskId, new IdQueryParameters(guid));
        if (!result.getSucceeded() || result.getReturnValue() == null) {
            Guid dataCenterId = BackendDataCenterHelper.lookupByStorageDomainId(this, storageDomainId);
            disk = performGet(QueryType.GetUnregisteredDisk, new GetUnregisteredDiskQueryParameters(guid, storageDomainId, dataCenterId));
        } else {
            // parameter was passed.
            return notFound();
        }
    } else {
        disk = getDelegate().get();
    }
    if (disk.isSetStorageDomains() && !disk.getStorageDomains().getStorageDomains().isEmpty()) {
        for (StorageDomain sd : disk.getStorageDomains().getStorageDomains()) {
            if (sd.isSetId() && sd.getId().equals(storageDomainId.toString())) {
                return disk;
            }
        }
    }
    return notFound();
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) GetUnregisteredDiskQueryParameters(org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters) Disk(org.ovirt.engine.api.model.Disk)

Example 27 with StorageDomain

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

the class BackendStorageDomainImageResource method addParents.

@Override
protected Image addParents(Image image) {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(getStorageDomainId().toString());
    image.setStorageDomain(storageDomain);
    return image;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 28 with StorageDomain

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

the class BackendStorageDomainImagesResource method addParents.

@Override
protected Image addParents(Image image) {
    StorageDomain sd = new StorageDomain();
    sd.setId(storageDomainId.toString());
    image.setStorageDomain(sd);
    return super.addParents(image);
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 29 with StorageDomain

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

the class BackendStorageDomainResource method update.

@Override
public StorageDomain update(StorageDomain incoming) {
    QueryIdResolver<Guid> storageDomainResolver = new QueryIdResolver<>(QueryType.GetStorageDomainById, IdQueryParameters.class);
    org.ovirt.engine.core.common.businessentities.StorageDomain entity = getEntity(storageDomainResolver, true);
    StorageDomain model = map(entity, new StorageDomain());
    StorageType storageType = entity.getStorageType();
    if (storageType != null) {
        switch(storageType) {
            case ISCSI:
            case FCP:
                extendStorageDomain(incoming, model);
                break;
            default:
                break;
        }
    }
    return addLinks(performUpdate(incoming, entity, model, storageDomainResolver, ActionType.UpdateStorageDomain, new UpdateParametersProvider()), new String[] { "templates", "vms" });
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) Guid(org.ovirt.engine.core.compat.Guid)

Example 30 with StorageDomain

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

the class BackendVmDiskResourceTest method testExport.

@Test
public void testExport() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[] { "ImageGroupID", "DestinationDomainId" }, new Object[] { DISK_ID, GUIDS[3] }, true, true, null, null, true));
    Action action = new Action();
    action.setStorageDomain(new StorageDomain());
    action.getStorageDomain().setId(GUIDS[3].toString());
    verifyActionResponse(resource.export(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) StorageDomain(org.ovirt.engine.api.model.StorageDomain) ExportRepoImageParameters(org.ovirt.engine.core.common.action.ExportRepoImageParameters) 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