Search in sources :

Example 31 with DataCenter

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

the class QosMapper method map.

@Mapping(from = QosBase.class, to = Qos.class)
public static Qos map(QosBase entity, Qos template) {
    Qos model = template != null ? template : new Qos();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    Guid storagePoolId = entity.getStoragePoolId();
    if (storagePoolId != null) {
        DataCenter dataCenter = new DataCenter();
        dataCenter.setId(storagePoolId.toString());
        model.setDataCenter(dataCenter);
    }
    model.setDescription(entity.getDescription());
    mapQosTypeToModel(entity, model);
    if (entity.getQosType() != null) {
        model.setType(QosTypeMapper.map(entity.getQosType(), null));
    }
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Qos(org.ovirt.engine.api.model.Qos) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) Guid(org.ovirt.engine.core.compat.Guid)

Example 32 with DataCenter

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

the class QuotaMapper method map.

private static void map(QuotaClusterLimit template, QuotaCluster quotaCluster, String clusterId, String dataCenterId, String quotaId) {
    template.setQuota(new Quota());
    template.getQuota().setId(quotaId);
    template.getQuota().setDataCenter(new DataCenter());
    template.getQuota().getDataCenter().setId(dataCenterId);
    if (clusterId != null) {
        template.setCluster(new Cluster());
        template.getCluster().setId(clusterId);
    }
    if (quotaCluster.getMemSizeMB() != null) {
        // show GB instead of MB (ignore -1)
        double value = quotaCluster.getMemSizeMB() == -1 ? quotaCluster.getMemSizeMB().doubleValue() : quotaCluster.getMemSizeMB().doubleValue() / 1024.0;
        template.setMemoryLimit(value);
    }
    if (quotaCluster.getMemSizeMBUsage() != null) {
        template.setMemoryUsage(quotaCluster.getMemSizeMBUsage() / 1024.0);
    }
    if (quotaCluster.getVirtualCpu() != null) {
        template.setVcpuLimit(quotaCluster.getVirtualCpu());
    }
    if (quotaCluster.getVirtualCpuUsage() != null) {
        template.setVcpuUsage(quotaCluster.getVirtualCpuUsage());
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Quota(org.ovirt.engine.api.model.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Cluster(org.ovirt.engine.api.model.Cluster)

Example 33 with DataCenter

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

the class QuotaMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.Quota.class, to = Quota.class)
public static Quota map(org.ovirt.engine.core.common.businessentities.Quota template, Quota model) {
    Quota ret = (model == null) ? new Quota() : model;
    if (template.getId() != null) {
        ret.setId(template.getId().toString());
    }
    if (template.getQuotaName() != null) {
        ret.setName(template.getQuotaName());
    }
    if (template.getDescription() != null) {
        ret.setDescription(template.getDescription());
    }
    if (template.getStoragePoolId() != null) {
        if (ret.getDataCenter() == null) {
            ret.setDataCenter(new DataCenter());
        }
        ret.getDataCenter().setId(template.getStoragePoolId().toString());
    }
    ret.setClusterHardLimitPct(template.getGraceClusterPercentage());
    ret.setStorageHardLimitPct(template.getGraceStoragePercentage());
    ret.setClusterSoftLimitPct(template.getThresholdClusterPercentage());
    ret.setStorageSoftLimitPct(template.getThresholdStoragePercentage());
    return ret;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Quota(org.ovirt.engine.api.model.Quota)

Example 34 with DataCenter

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

the class BackendNetworksResourceTest method doTestBadAddNetwork.

private void doTestBadAddNetwork(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddNetwork, AddNetworkStoragePoolParameters.class, new String[] { "StoragePoolId" }, new Object[] { DATA_CENTER_ID }, valid, success));
    Network model = getModel(0);
    model.setDataCenter(new DataCenter());
    model.getDataCenter().setId(DATA_CENTER_ID.toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) WebApplicationException(javax.ws.rs.WebApplicationException) AddNetworkStoragePoolParameters(org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters) Network(org.ovirt.engine.api.model.Network)

Example 35 with DataCenter

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

the class BackendDataCenterClustersResourceTest method getModel.

static org.ovirt.engine.api.model.Cluster getModel(int index) {
    org.ovirt.engine.api.model.Cluster model = new org.ovirt.engine.api.model.Cluster();
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    model.setDataCenter(new DataCenter());
    model.setCpu(new Cpu());
    model.getCpu().setType("Intel Xeon");
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Cpu(org.ovirt.engine.api.model.Cpu)

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