Search in sources :

Example 6 with CpuProfile

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

the class CpuProfileMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.profiles.CpuProfile.class, to = CpuProfile.class)
public static CpuProfile map(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile entity, CpuProfile template) {
    CpuProfile model = template != null ? template : new CpuProfile();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getClusterId() != null) {
        model.setCluster(new Cluster());
        model.getCluster().setId(entity.getClusterId().toString());
    }
    if (entity.getQosId() != null) {
        model.setQos(new Qos());
        model.getQos().setId(entity.getQosId().toString());
    }
    return model;
}
Also used : Qos(org.ovirt.engine.api.model.Qos) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster)

Example 7 with CpuProfile

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

the class AbstractBackendCpuProfilesResource method mapCollection.

protected CpuProfiles mapCollection(List<org.ovirt.engine.core.common.businessentities.profiles.CpuProfile> entities) {
    CpuProfiles collection = new CpuProfiles();
    Map<Guid, Qos> qosMap = new HashMap<>();
    for (org.ovirt.engine.core.common.businessentities.profiles.CpuProfile entity : entities) {
        CpuProfile profile = populate(map(entity), entity);
        collection.getCpuProfiles().add(profile);
        if (entity.getQosId() != null) {
            qosMap.put(entity.getQosId(), profile.getQos());
        }
    }
    handleQosDataCenterLinks(qosMap);
    for (CpuProfile cpuProfile : collection.getCpuProfiles()) {
        addLinks(cpuProfile);
    }
    return collection;
}
Also used : CpuProfiles(org.ovirt.engine.api.model.CpuProfiles) Qos(org.ovirt.engine.api.model.Qos) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos) HashMap(java.util.HashMap) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with CpuProfile

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

the class VmBaseMapper method mapVmBaseEntityToModel.

/**
 * Common for VM and template
 */
protected static void mapVmBaseEntityToModel(VmBase model, org.ovirt.engine.core.common.businessentities.VmBase entity) {
    mapCommonEntityToModel(model, entity);
    model.setComment(entity.getComment());
    if (entity.getClusterId() != null) {
        Cluster cluster = new Cluster();
        cluster.setId(entity.getClusterId().toString());
        model.setCluster(cluster);
    }
    if (entity.getVmType() != null) {
        model.setType(mapVmType(entity.getVmType()));
    }
    if (entity.getResumeBehavior() != null) {
        model.setStorageErrorResumeBehaviour(mapResumeBehavior(entity.getResumeBehavior()));
    }
    if (entity.getOrigin() != null) {
        model.setOrigin(map(entity.getOrigin(), null));
    }
    model.setBios(new Bios());
    model.getBios().setBootMenu(new BootMenu());
    model.getBios().getBootMenu().setEnabled(entity.isBootMenuEnabled());
    if (entity.getTimeZone() != null) {
        model.setTimeZone(new TimeZone());
        model.getTimeZone().setName(entity.getTimeZone());
    }
    if (entity.getVmInit() != null && entity.getVmInit().getDomain() != null && StringUtils.isNotBlank(entity.getVmInit().getDomain())) {
        Domain domain = new Domain();
        domain.setName(entity.getVmInit().getDomain());
        model.setDomain(domain);
    }
    model.setStateless(entity.isStateless());
    model.setDeleteProtected(entity.isDeleteProtected());
    model.setSso(SsoMapper.map(entity.getSsoMethod(), null));
    model.setTunnelMigration(entity.getTunnelMigration());
    if (entity.getSerialNumberPolicy() != null) {
        model.setSerialNumber(SerialNumberMapper.map(entity, null));
    }
    model.setStartPaused(entity.isRunAndPause());
    if (entity.getCpuProfileId() != null) {
        CpuProfile cpuProfile = new CpuProfile();
        cpuProfile.setId(entity.getCpuProfileId().toString());
        model.setCpuProfile(cpuProfile);
    }
    if (!StringUtils.isEmpty(entity.getCustomProperties())) {
        CustomProperties hooks = new CustomProperties();
        hooks.getCustomProperties().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(), false));
        model.setCustomProperties(hooks);
    }
    model.setCpuShares(entity.getCpuShares());
    if (entity.getLargeIconId() != null) {
        if (!model.isSetLargeIcon()) {
            model.setLargeIcon(new Icon());
        }
        model.getLargeIcon().setId(entity.getLargeIconId().toString());
    }
    if (entity.getSmallIconId() != null) {
        if (!model.isSetSmallIcon()) {
            model.setSmallIcon(new Icon());
        }
        model.getSmallIcon().setId(entity.getSmallIconId().toString());
    }
    if (entity.getQuotaId() != null) {
        Quota quota = new Quota();
        quota.setId(entity.getQuotaId().toString());
        model.setQuota(quota);
    }
    model.setLease(StorageDomainLeaseMapper.map(entity.getLeaseStorageDomainId()));
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) BootMenu(org.ovirt.engine.api.model.BootMenu) Bios(org.ovirt.engine.api.model.Bios) Quota(org.ovirt.engine.api.model.Quota) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster) Icon(org.ovirt.engine.api.model.Icon) Domain(org.ovirt.engine.api.model.Domain) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Example 9 with CpuProfile

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

the class AbstractBackendCpuProfilesResourceTest method doTestBadAddCpuProfile.

private void doTestBadAddCpuProfile(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddCpuProfile, CpuProfileParameters.class, new String[] {}, new Object[] {}, valid, success));
    CpuProfile model = getModel(0);
    model.setCluster(new Cluster());
    model.getCluster().setId(CLUSTER_ID.toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster) CpuProfileParameters(org.ovirt.engine.core.common.action.CpuProfileParameters)

Example 10 with CpuProfile

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

the class AbstractBackendCpuProfilesResourceTest method getModel.

static CpuProfile getModel(int index) {
    CpuProfile model = new CpuProfile();
    model.setId(GUIDS[index].toString());
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    return model;
}
Also used : CpuProfile(org.ovirt.engine.api.model.CpuProfile)

Aggregations

CpuProfile (org.ovirt.engine.api.model.CpuProfile)10 Cluster (org.ovirt.engine.api.model.Cluster)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Test (org.junit.Test)3 Qos (org.ovirt.engine.api.model.Qos)2 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 Bios (org.ovirt.engine.api.model.Bios)1 BootMenu (org.ovirt.engine.api.model.BootMenu)1 CpuProfiles (org.ovirt.engine.api.model.CpuProfiles)1 CustomProperties (org.ovirt.engine.api.model.CustomProperties)1 Domain (org.ovirt.engine.api.model.Domain)1 Icon (org.ovirt.engine.api.model.Icon)1 Quota (org.ovirt.engine.api.model.Quota)1 TimeZone (org.ovirt.engine.api.model.TimeZone)1 CpuProfileParameters (org.ovirt.engine.core.common.action.CpuProfileParameters)1 CpuQos (org.ovirt.engine.core.common.businessentities.qos.CpuQos)1 Guid (org.ovirt.engine.core.compat.Guid)1