Search in sources :

Example 1 with HostNic

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

the class BackendHostNicNetworkAttachmentsResourceTest method getModel.

@Override
protected org.ovirt.engine.api.model.NetworkAttachment getModel(int index) {
    org.ovirt.engine.api.model.NetworkAttachment model = super.getModel(index);
    model.setHostNic(new HostNic());
    model.getHostNic().setId(HOST_NIC_ID.toString());
    return model;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic)

Example 2 with HostNic

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

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

the class CompletenessAssertorTest method testMissingListSubFields.

@Test
public void testMissingListSubFields() throws Exception {
    HostNic bond = new HostNic();
    try {
        CompletenessAssertor.validateParameters(bond, "name", "network.id|name", "bonding.slaves.id|name");
        fail("expected WebApplicationException on incomplete model");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "HostNic", "name, network.id|name, bonding.slaves.id|name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) HostNic(org.ovirt.engine.api.model.HostNic) Test(org.junit.Test)

Example 4 with HostNic

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

the class BackendHostNicsResource method addParents.

@Override
public HostNic addParents(HostNic hostNic) {
    final HostNic nic = super.addParents(hostNic);
    final Host host = new Host();
    host.setId(hostId);
    nic.setHost(host);
    if (nic.getPhysicalFunction() != null) {
        nic.getPhysicalFunction().setHost(host);
    }
    return nic;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Host(org.ovirt.engine.api.model.Host)

Example 5 with HostNic

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

Aggregations

HostNic (org.ovirt.engine.api.model.HostNic)30 Test (org.junit.Test)7 Host (org.ovirt.engine.api.model.Host)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 Guid (org.ovirt.engine.core.compat.Guid)6 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)4 Bonding (org.ovirt.engine.api.model.Bonding)3 HostNics (org.ovirt.engine.api.model.HostNics)3 Network (org.ovirt.engine.api.model.Network)3 BootProtocol (org.ovirt.engine.api.model.BootProtocol)2 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)2 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)2 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)2 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 List (java.util.List)1 Collectors.joining (java.util.stream.Collectors.joining)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 UriInfo (javax.ws.rs.core.UriInfo)1 StringUtils (org.apache.commons.lang.StringUtils)1