Search in sources :

Example 1 with HostNics

use of org.ovirt.engine.api.model.HostNics 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 HostNics

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

the class BackendHostNicsResource method list.

@Override
public HostNics list() {
    HostNics ret = new HostNics();
    List<VdsNetworkInterface> ifaces = getCollection();
    Map<String, Guid> networkNameToNetworkIdMap = mapNetworkNamesToNetworkIds();
    Map<Guid, NetworkAttachment> attachmentsByNetworkId = getAttachmentsByNetworkId();
    for (VdsNetworkInterface iface : ifaces) {
        HostNic hostNic = populate(map(iface, ifaces), iface);
        setCustomProperties(attachmentsByNetworkId, networkNameToNetworkIdMap, hostNic);
        String networkName = iface.getNetworkName();
        if (networkNameToNetworkIdMap.containsKey(networkName)) {
            Guid networkId = networkNameToNetworkIdMap.get(networkName);
            hostNic.getNetwork().setId(networkId.toString());
            hostNic.getNetwork().setName(null);
        }
        ret.getHostNics().add(addLinks(hostNic));
    }
    return addActions(ret);
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) HostNics(org.ovirt.engine.api.model.HostNics) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 3 with HostNics

use of org.ovirt.engine.api.model.HostNics 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 4 with HostNics

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

the class V3HostNicsInAdapter method adapt.

@Override
public HostNics adapt(V3HostNics from) {
    HostNics to = new HostNics();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getHostNics().addAll(adaptIn(from.getHostNics()));
    return to;
}
Also used : HostNics(org.ovirt.engine.api.model.HostNics) V3HostNics(org.ovirt.engine.api.v3.types.V3HostNics)

Example 5 with HostNics

use of org.ovirt.engine.api.model.HostNics 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

HostNics (org.ovirt.engine.api.model.HostNics)5 Bonding (org.ovirt.engine.api.model.Bonding)3 HostNic (org.ovirt.engine.api.model.HostNic)3 Test (org.junit.Test)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 V3HostNics (org.ovirt.engine.api.v3.types.V3HostNics)1 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 Guid (org.ovirt.engine.core.compat.Guid)1