Search in sources :

Example 1 with OpenStackVolumeType

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

the class V3OpenStackVolumeTypeInAdapter method adapt.

@Override
public OpenStackVolumeType adapt(V3OpenStackVolumeType from) {
    OpenStackVolumeType to = new OpenStackVolumeType();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOpenstackVolumeProvider()) {
        to.setOpenstackVolumeProvider(adaptIn(from.getOpenstackVolumeProvider()));
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    return to;
}
Also used : OpenStackVolumeType(org.ovirt.engine.api.model.OpenStackVolumeType) V3OpenStackVolumeType(org.ovirt.engine.api.v3.types.V3OpenStackVolumeType) Properties(org.ovirt.engine.api.model.Properties)

Example 2 with OpenStackVolumeType

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

the class BackendOpenStackVolumeTypeResource method get.

@Override
public OpenStackVolumeType get() {
    Guid storageDomainId = BackendOpenStackStorageProviderHelper.getStorageDomainId(this, providerId);
    IdQueryParameters parameters = new IdQueryParameters(storageDomainId);
    List<CinderVolumeType> volumeTypes = getBackendCollection(CinderVolumeType.class, QueryType.GetCinderVolumeTypesByStorageDomainId, parameters);
    return volumeTypes.stream().filter(v -> v.getId().equals(id)).findFirst().map(v -> addLinks(populate(map(v), v))).orElseGet(this::notFound);
}
Also used : AbstractBackendActionableResource(org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource) QueryType(org.ovirt.engine.core.common.queries.QueryType) List(java.util.List) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) OpenStackVolumeType(org.ovirt.engine.api.model.OpenStackVolumeType) Guid(org.ovirt.engine.core.compat.Guid) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) OpenstackVolumeTypeResource(org.ovirt.engine.api.resource.openstack.OpenstackVolumeTypeResource) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with OpenStackVolumeType

use of org.ovirt.engine.api.model.OpenStackVolumeType 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

OpenStackVolumeType (org.ovirt.engine.api.model.OpenStackVolumeType)3 Guid (org.ovirt.engine.core.compat.Guid)2 List (java.util.List)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 DiskProfile (org.ovirt.engine.api.model.DiskProfile)1 OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)1 Properties (org.ovirt.engine.api.model.Properties)1 Quota (org.ovirt.engine.api.model.Quota)1 Snapshot (org.ovirt.engine.api.model.Snapshot)1 StorageDomain (org.ovirt.engine.api.model.StorageDomain)1 StorageDomains (org.ovirt.engine.api.model.StorageDomains)1 OpenstackVolumeTypeResource (org.ovirt.engine.api.resource.openstack.OpenstackVolumeTypeResource)1 AbstractBackendActionableResource (org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource)1 V3OpenStackVolumeType (org.ovirt.engine.api.v3.types.V3OpenStackVolumeType)1 CinderVolumeType (org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1