Search in sources :

Example 86 with StorageDomain

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

the class DiskMapper method mapDiskToDiskImageProperties.

private static void mapDiskToDiskImageProperties(Disk disk, DiskImage diskImage) {
    if (disk.isSetImageId()) {
        diskImage.setImageId(GuidUtils.asGuid(disk.getImageId()));
    }
    if (disk.isSetProvisionedSize()) {
        diskImage.setSize(disk.getProvisionedSize());
    }
    if (disk.isSetFormat()) {
        diskImage.setVolumeFormat(map(disk.getFormat(), null));
    }
    if (disk.isSetQcowVersion()) {
        diskImage.setQcowCompat(mapQcowVersion(disk.getQcowVersion()));
    }
    if (disk.isSetStatus()) {
        diskImage.setImageStatus(mapDiskStatus(disk.getStatus()));
    }
    if (disk.isSetSnapshot() && disk.getSnapshot().isSetId()) {
        diskImage.setVmSnapshotId(GuidUtils.asGuid(disk.getSnapshot().getId()));
    }
    if (disk.isSetSparse()) {
        diskImage.setVolumeType(disk.isSparse() ? VolumeType.Sparse : VolumeType.Preallocated);
    }
    // TODO: relevant when adding disk, needs to be removed when the initial size will be passed in the parameters.
    if (disk.isSetInitialSize()) {
        diskImage.setActualSizeInBytes(disk.getInitialSize());
    }
    if (disk.isSetStorageDomains() && disk.getStorageDomains().isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetId()) {
        StorageDomain storageDomain = disk.getStorageDomains().getStorageDomains().get(0);
        diskImage.setStorageIds(new ArrayList<>());
        diskImage.getStorageIds().add(Guid.createGuidFromStringDefaultEmpty(storageDomain.getId()));
    }
    if (disk.isSetQuota() && disk.getQuota().isSetId()) {
        diskImage.setQuotaId(GuidUtils.asGuid(disk.getQuota().getId()));
    }
    if (disk.isSetDiskProfile() && disk.getDiskProfile().isSetId()) {
        diskImage.setDiskProfileId(GuidUtils.asGuid(disk.getDiskProfile().getId()));
    }
    if (disk.isSetOpenstackVolumeType() && disk.getOpenstackVolumeType().isSetName()) {
        diskImage.setCinderVolumeType(disk.getOpenstackVolumeType().getName());
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 87 with StorageDomain

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

the class BackendExternalVmImportsResource method add.

@Override
public Response add(ExternalVmImport externalVmImport) {
    validateParameters(externalVmImport, "provider", "url", "name", "sparse", "cluster.id|name", "storageDomain.id|name");
    ImportVmFromExternalUrlParameters parameters = buildImportParameters(externalVmImport);
    VM createdVm = performAction(ActionType.ImportVmFromExternalUrl, parameters, VM.class);
    // Postprocess output entity to clear sensitive data and resolve links.
    externalVmImport.setPassword(null);
    externalVmImport.setVm(withIdLink(new Vm(), createdVm.getId()));
    externalVmImport.setCluster(withIdLink(new org.ovirt.engine.api.model.Cluster(), parameters.getClusterId()));
    externalVmImport.setStorageDomain(withIdLink(new StorageDomain(), parameters.getStorageDomainId()));
    if (externalVmImport.isSetHost()) {
        externalVmImport.setHost(withIdLink(new Host(), parameters.getProxyHostId()));
    }
    return Response.ok(externalVmImport).status(Response.Status.CREATED).build();
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) ImportVmFromExternalUrlParameters(org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Host(org.ovirt.engine.api.model.Host)

Example 88 with StorageDomain

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

the class BackendAttachedStorageDomainsResourceTest method doTestBadAdd.

private void doTestBadAdd(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AttachStorageDomainToPool, AttachStorageDomainToPoolParameters.class, new String[] { "StorageDomainId", "StoragePoolId" }, new Object[] { GUIDS[0], GUIDS[NAMES.length - 1] }, valid, success));
    StorageDomain model = new StorageDomain();
    model.setId(GUIDS[0].toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException)

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