Search in sources :

Example 6 with MacRange

use of org.ovirt.engine.core.common.businessentities.MacRange in project ovirt-engine by oVirt.

the class MacPoolModel method init.

protected void init() {
    if (getEntity() == null) {
        return;
    }
    allowDuplicates.setEntity(getEntity().isAllowDuplicateMacAddresses());
    List<MacRangeModel> rangeModels = new ArrayList<>();
    for (MacRange range : getEntity().getRanges()) {
        rangeModels.add(new MacRangeModel(range));
    }
    Collections.sort(rangeModels, Comparator.comparing((MacRangeModel m) -> m.getLeftBound().getEntity()).thenComparing(m -> m.getRightBound().getEntity()));
    macRanges.setItems(rangeModels);
}
Also used : List(java.util.List) MacPool(org.ovirt.engine.core.common.businessentities.MacPool) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) MacRange(org.ovirt.engine.core.common.businessentities.MacRange) Comparator(java.util.Comparator) Collections(java.util.Collections) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) MacRange(org.ovirt.engine.core.common.businessentities.MacRange) ArrayList(java.util.ArrayList)

Example 7 with MacRange

use of org.ovirt.engine.core.common.businessentities.MacRange in project ovirt-engine by oVirt.

the class MacPoolDaoTest method generateNewEntity.

@Override
protected MacPool generateNewEntity() {
    final MacPool macPool = new MacPool();
    macPool.setId(Guid.newGuid());
    macPool.setName("someName");
    macPool.setAllowDuplicateMacAddresses(true);
    macPool.setDescription("someDesc");
    macPool.setDefaultPool(false);
    final MacRange macRange = new MacRange();
    macRange.setMacPoolId(macPool.getId());
    macRange.setMacFrom("01:c0:81:21:71:17");
    macRange.setMacTo("01:c1:81:21:71:17");
    macPool.getRanges().add(macRange);
    return macPool;
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) MacRange(org.ovirt.engine.core.common.businessentities.MacRange)

Example 8 with MacRange

use of org.ovirt.engine.core.common.businessentities.MacRange in project ovirt-engine by oVirt.

the class MacPoolDaoImpl method update.

@Override
public void update(MacPool entity) {
    super.update(entity);
    // If ranges definition is also sent, update them as well.
    if (entity.getRanges() != null && !entity.getRanges().isEmpty()) {
        deleteAllRangesForMacPool(entity.getId());
        for (MacRange macRange : entity.getRanges()) {
            macRange.setMacPoolId(entity.getId());
            saveRange(macRange);
        }
    }
}
Also used : MacRange(org.ovirt.engine.core.common.businessentities.MacRange)

Example 9 with MacRange

use of org.ovirt.engine.core.common.businessentities.MacRange in project ovirt-engine by oVirt.

the class MacPoolMapper method mapRange.

private static MacRange mapRange(org.ovirt.engine.api.model.Range range) {
    final MacRange result = new MacRange();
    result.setMacFrom(range.getFrom());
    result.setMacTo(range.getTo());
    return result;
}
Also used : MacRange(org.ovirt.engine.core.common.businessentities.MacRange)

Aggregations

MacRange (org.ovirt.engine.core.common.businessentities.MacRange)9 MacPool (org.ovirt.engine.core.common.businessentities.MacPool)4 ArrayList (java.util.ArrayList)2 Range (org.ovirt.engine.api.model.Range)2 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Test (org.junit.Test)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)1