Search in sources :

Example 1 with Bonding

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

the class CompletenessAssertorTest method testCompleteListSubFields.

@Test
public void testCompleteListSubFields() throws Exception {
    HostNic bond = new HostNic();
    bond.setName("joe");
    bond.setNetwork(new Network());
    bond.getNetwork().setId("0");
    bond.setBonding(new Bonding());
    bond.getBonding().setSlaves(new HostNics());
    HostNic slave = new HostNic();
    slave.setId("0");
    bond.getBonding().getSlaves().getHostNics().add(slave);
    slave = new HostNic();
    slave.setId("0");
    bond.getBonding().getSlaves().getHostNics().add(slave);
    CompletenessAssertor.validateParameters(bond, "name", "network.id|name", "bonding.slaves.id|name");
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Network(org.ovirt.engine.api.model.Network) Bonding(org.ovirt.engine.api.model.Bonding) HostNics(org.ovirt.engine.api.model.HostNics) Test(org.junit.Test)

Example 2 with Bonding

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

the class V3BondingInAdapter method adapt.

@Override
public Bonding adapt(V3Bonding from) {
    Bonding to = new Bonding();
    if (from.isSetOptions()) {
        to.setOptions(new Options());
        to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
    }
    if (from.isSetSlaves()) {
        to.setSlaves(new HostNics());
        to.getSlaves().getHostNics().addAll(adaptIn(from.getSlaves().getSlaves()));
    }
    return to;
}
Also used : Options(org.ovirt.engine.api.model.Options) V3Bonding(org.ovirt.engine.api.v3.types.V3Bonding) Bonding(org.ovirt.engine.api.model.Bonding) HostNics(org.ovirt.engine.api.model.HostNics)

Example 3 with Bonding

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

the class HostNicMapperTest method testBondMapping.

@Test
public void testBondMapping() {
    HostNic model = new HostNic();
    model.setId(Guid.newGuid().toString());
    model.setName(RandomUtils.instance().nextString(10));
    model.setBonding(new Bonding());
    model.getBonding().setSlaves(new HostNics());
    HostNic slaveA = new HostNic();
    slaveA.setName(RandomUtils.instance().nextString(10));
    model.getBonding().getSlaves().getHostNics().add(slaveA);
    Bond entity = HostNicMapper.map(model, null);
    assertNotNull(entity);
    assertEquals(model.getId(), entity.getId().toString());
    assertEquals(model.getName(), entity.getName());
    assertEquals(model.getBonding().getSlaves().getHostNics().size(), entity.getSlaves().size());
    for (HostNic slave : model.getBonding().getSlaves().getHostNics()) {
        assertTrue(entity.getSlaves().contains(slave.getName()));
    }
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Bonding(org.ovirt.engine.api.model.Bonding) HostNics(org.ovirt.engine.api.model.HostNics) Test(org.junit.Test)

Aggregations

Bonding (org.ovirt.engine.api.model.Bonding)3 HostNics (org.ovirt.engine.api.model.HostNics)3 Test (org.junit.Test)2 HostNic (org.ovirt.engine.api.model.HostNic)2 Network (org.ovirt.engine.api.model.Network)1 Options (org.ovirt.engine.api.model.Options)1 V3Bonding (org.ovirt.engine.api.v3.types.V3Bonding)1 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)1