Search in sources :

Example 1 with Values

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

the class V3StatisticInAdapter method adapt.

@Override
public Statistic adapt(V3Statistic from) {
    Statistic to = new Statistic();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBrick()) {
        to.setBrick(adaptIn(from.getBrick()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDisk()) {
        to.setDisk(adaptIn(from.getDisk()));
    }
    if (from.isSetGlusterVolume()) {
        to.setGlusterVolume(adaptIn(from.getGlusterVolume()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptIn(from.getHost()));
    }
    if (from.isSetHostNic()) {
        to.setHostNic(adaptIn(from.getHostNic()));
    }
    if (from.isSetHostNumaNode()) {
        to.setHostNumaNode(adaptIn(from.getHostNumaNode()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.getType() != null) {
        switch(from.getType()) {
            case COUNTER:
                to.setKind(StatisticKind.COUNTER);
                break;
            case GAUGE:
                to.setKind(StatisticKind.GAUGE);
                break;
        }
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNic()) {
        to.setNic(adaptIn(from.getNic()));
    }
    if (from.isSetStep()) {
        to.setStep(adaptIn(from.getStep()));
    }
    if (from.isSetUnit()) {
        switch(from.getUnit()) {
            case NONE:
                to.setUnit(StatisticUnit.NONE);
                break;
            case PERCENT:
                to.setUnit(StatisticUnit.PERCENT);
                break;
            case BYTES:
                to.setUnit(StatisticUnit.BYTES);
                break;
            case SECONDS:
                to.setUnit(StatisticUnit.SECONDS);
                break;
            case BYTES_PER_SECOND:
                to.setUnit(StatisticUnit.BYTES_PER_SECOND);
                break;
            case BITS_PER_SECOND:
                to.setUnit(StatisticUnit.BITS_PER_SECOND);
                break;
            case COUNT_PER_SECOND:
                to.setUnit(StatisticUnit.COUNT_PER_SECOND);
                break;
        }
    }
    if (from.isSetValues()) {
        V3Values fromValues = from.getValues();
        if (fromValues.isSetType()) {
            switch(fromValues.getType()) {
                case DECIMAL:
                    to.setType(ValueType.DECIMAL);
                    break;
                case INTEGER:
                    to.setType(ValueType.INTEGER);
                    break;
                case STRING:
                    to.setType(ValueType.STRING);
                    break;
            }
        }
        to.setValues(new Values());
        to.getValues().getValues().addAll(adaptIn(fromValues.getValues()));
    }
    if (from.isSetVm()) {
        to.setVm(adaptIn(from.getVm()));
    }
    return to;
}
Also used : V3Values(org.ovirt.engine.api.v3.types.V3Values) Statistic(org.ovirt.engine.api.model.Statistic) V3Statistic(org.ovirt.engine.api.v3.types.V3Statistic) V3Values(org.ovirt.engine.api.v3.types.V3Values) Values(org.ovirt.engine.api.model.Values)

Example 2 with Values

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

the class StatisticResourceUtils method create.

public static Statistic create(String name, String description, StatisticKind kind, StatisticUnit unit, ValueType valueType) {
    Statistic statistic = new Statistic();
    statistic.setId(asId(name));
    statistic.setName(name);
    statistic.setDescription(description);
    statistic.setKind(kind);
    statistic.setUnit(unit);
    statistic.setValues(new Values());
    statistic.setType(valueType);
    return statistic;
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Values(org.ovirt.engine.api.model.Values)

Example 3 with Values

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

the class BackendStatisticsResourceTest method getPrototype.

static Statistic getPrototype(String name) {
    Statistic statistic = new Statistic();
    statistic.setName(name);
    statistic.setId(UUID.nameUUIDFromBytes(statistic.getName().getBytes()).toString());
    statistic.setUnit(StatisticUnit.BYTES);
    statistic.setKind(StatisticKind.GAUGE);
    Value value = new Value();
    statistic.setValues(new Values());
    statistic.setType(ValueType.INTEGER);
    statistic.getValues().getValues().add(value);
    statistic.setHost(new Host());
    statistic.getHost().setId(GUIDS[2].toString());
    return statistic;
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Value(org.ovirt.engine.api.model.Value) Values(org.ovirt.engine.api.model.Values) Host(org.ovirt.engine.api.model.Host)

Aggregations

Statistic (org.ovirt.engine.api.model.Statistic)3 Values (org.ovirt.engine.api.model.Values)3 Host (org.ovirt.engine.api.model.Host)1 Value (org.ovirt.engine.api.model.Value)1 V3Statistic (org.ovirt.engine.api.v3.types.V3Statistic)1 V3Values (org.ovirt.engine.api.v3.types.V3Values)1