Search in sources :

Example 41 with DataCenter

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

the class DataCenterMapper method map.

@Mapping(from = StoragePool.class, to = DataCenter.class)
public static DataCenter map(StoragePool entity, DataCenter template) {
    DataCenter model = template != null ? template : new DataCenter();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    model.setLocal(entity.isLocal());
    if (!StringUtils.isEmpty(entity.getdescription())) {
        model.setDescription(entity.getdescription());
    }
    if (!StringUtils.isEmpty(entity.getComment())) {
        model.setComment(entity.getComment());
    }
    if (entity.getStatus() != null) {
        model.setStatus(mapDataCenterStatus(entity.getStatus()));
    }
    if (entity.getCompatibilityVersion() != null) {
        model.setVersion(VersionMapper.map(entity.getCompatibilityVersion()));
    }
    if (entity.getStoragePoolFormatType() != null) {
        StorageFormat storageFormat = StorageFormatMapper.map(entity.getStoragePoolFormatType(), null);
        if (storageFormat != null) {
            model.setStorageFormat(storageFormat);
        }
    }
    if (entity.getMacPoolId() != null) {
        model.setMacPool(new MacPool());
        model.getMacPool().setId(entity.getMacPoolId().toString());
    }
    if (entity.getQuotaEnforcementType() != null) {
        model.setQuotaMode(map(entity.getQuotaEnforcementType()));
    }
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) MacPool(org.ovirt.engine.api.model.MacPool) StorageFormat(org.ovirt.engine.api.model.StorageFormat)

Example 42 with DataCenter

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

DataCenter (org.ovirt.engine.api.model.DataCenter)42 Test (org.junit.Test)10 WebApplicationException (javax.ws.rs.WebApplicationException)6 Network (org.ovirt.engine.api.model.Network)6 StorageDomain (org.ovirt.engine.api.model.StorageDomain)5 Response (javax.ws.rs.core.Response)4 Qos (org.ovirt.engine.api.model.Qos)4 Quota (org.ovirt.engine.api.model.Quota)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Cluster (org.ovirt.engine.api.model.Cluster)3 Permission (org.ovirt.engine.api.model.Permission)3 Role (org.ovirt.engine.api.model.Role)3 AddNetworkStoragePoolParameters (org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters)3 QosBase (org.ovirt.engine.core.common.businessentities.qos.QosBase)3 QosQueryParameterBase (org.ovirt.engine.core.common.queries.QosQueryParameterBase)3 Cpu (org.ovirt.engine.api.model.Cpu)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1