Search in sources :

Example 81 with StorageDomain

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

the class BackendStorageDomainDisksResourceTest method getModel.

static Disk getModel() {
    Disk model = new Disk();
    model.setProvisionedSize(1024 * 1024L);
    model.setFormat(DiskFormat.COW);
    model.setSparse(true);
    model.setShareable(false);
    model.setPropagateErrors(true);
    model.setStorageDomains(new StorageDomains());
    model.getStorageDomains().getStorageDomains().add(new StorageDomain());
    model.getStorageDomains().getStorageDomains().get(0).setId(GUIDS[2].toString());
    return model;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageDomains(org.ovirt.engine.api.model.StorageDomains) Disk(org.ovirt.engine.api.model.Disk)

Example 82 with StorageDomain

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

the class BackendTemplateDiskResourceTest method testExport.

@Test
public void testExport() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[] { "ImageGroupID", "DestinationDomainId" }, new Object[] { GUIDS[1], 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)

Example 83 with StorageDomain

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

the class BackendTemplateDisksResourceTest method testList.

@Test
@Override
public void testList() throws Exception {
    UriInfo uriInfo = setUpUriExpectations(null);
    setUpEntityQueryExpectations(1, null);
    collection.setUriInfo(uriInfo);
    List<Disk> disks = getCollection();
    for (Disk disk : disks) {
        assertNotNull(disk.getStorageDomains());
        List<StorageDomain> storageDomains = disk.getStorageDomains().getStorageDomains();
        assertEquals(1, storageDomains.size());
        assertEquals(storageDomains.get(0).getId(), GUIDS[0].toString());
    }
    verifyCollection(disks);
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) Disk(org.ovirt.engine.api.model.Disk) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 84 with StorageDomain

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

the class BackendVmResourceTest method testExportWithStorageDomainId.

protected void testExportWithStorageDomainId(boolean exclusive, boolean discardSnapshots) throws Exception {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(GUIDS[2].toString());
    doTestExport(storageDomain, exclusive, discardSnapshots);
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 85 with StorageDomain

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

the class DiskMapper method mapDiskImageToDiskFields.

private static void mapDiskImageToDiskFields(DiskImage entity, Disk model) {
    if (entity.getImageId() != null) {
        model.setImageId(entity.getImageId().toString());
    }
    model.setProvisionedSize(entity.getSize());
    if (entity.hasActualSize()) {
        model.setActualSize(entity.getActualSizeInBytes());
        if (entity.isAllowSnapshot()) {
            model.setTotalSize((long) entity.getActualDiskWithSnapshotsSizeInBytes());
        }
    }
    if (entity.getSnapshotId() != null) {
        model.setSnapshot(new Snapshot());
        model.getSnapshot().setId(entity.getSnapshotId().toString());
    }
    if (entity.getVolumeFormat() != null) {
        model.setFormat(map(entity.getVolumeFormat(), null));
    }
    if (entity.getQcowCompat() != null) {
        model.setQcowVersion(mapQcowCompat(entity.getQcowCompat()));
    }
    if (entity.getImageStatus() != null) {
        model.setStatus(mapDiskStatus(entity.getImageStatus()));
    }
    model.setSparse(VolumeType.Sparse == entity.getVolumeType());
    if (entity.getStorageIds() != null && entity.getStorageIds().size() > 0) {
        if (!model.isSetStorageDomains()) {
            model.setStorageDomains(new StorageDomains());
        }
        for (Guid id : entity.getStorageIds()) {
            StorageDomain storageDomain = new StorageDomain();
            storageDomain.setId(id.toString());
            model.getStorageDomains().getStorageDomains().add(storageDomain);
        }
    }
    if (entity.getQuotaId() != null) {
        Quota quota = new Quota();
        quota.setId(entity.getQuotaId().toString());
        // Add DataCenter to the quota, so links are properly created
        if (entity.getStoragePoolId() != null) {
            quota.setDataCenter(new DataCenter());
            quota.getDataCenter().setId(entity.getStoragePoolId().toString());
        }
        model.setQuota(quota);
    }
    if (entity.getDiskProfileId() != null) {
        DiskProfile diskProfile = new DiskProfile();
        diskProfile.setId(entity.getDiskProfileId().toString());
        model.setDiskProfile(diskProfile);
    }
    if (entity.getCinderVolumeType() != null) {
        OpenStackVolumeType volumeType = model.getOpenstackVolumeType();
        if (volumeType == null) {
            volumeType = new OpenStackVolumeType();
            model.setOpenstackVolumeType(volumeType);
        }
        volumeType.setName(entity.getCinderVolumeType());
    }
}
Also used : OpenStackVolumeType(org.ovirt.engine.api.model.OpenStackVolumeType) Snapshot(org.ovirt.engine.api.model.Snapshot) StorageDomain(org.ovirt.engine.api.model.StorageDomain) DataCenter(org.ovirt.engine.api.model.DataCenter) Quota(org.ovirt.engine.api.model.Quota) Guid(org.ovirt.engine.core.compat.Guid) StorageDomains(org.ovirt.engine.api.model.StorageDomains) DiskProfile(org.ovirt.engine.api.model.DiskProfile)

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