Search in sources :

Example 26 with HostNic

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

the class BackendHostResource method completeSlaveNames.

private void completeSlaveNames(BusinessEntityMap<VdsNetworkInterface> nicsFromBackend, HostNic bond) {
    if (bond.isSetBonding() && bond.getBonding().isSetSlaves()) {
        for (HostNic slave : bond.getBonding().getSlaves().getHostNics()) {
            if (!slave.isSetName() && slave.isSetId()) {
                Guid slaveId = new Guid(slave.getId());
                String slaveNameFromBackend = nicsFromBackend.get(slaveId).getName();
                slave.setName(slaveNameFromBackend);
            }
        }
    }
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Guid(org.ovirt.engine.core.compat.Guid)

Example 27 with HostNic

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

the class BackendHostNicNetworkAttachmentsResource method add.

@Override
public Response add(org.ovirt.engine.api.model.NetworkAttachment attachment) {
    verifyHostAndNicExistence();
    if (attachment.isSetHostNic()) {
        Guid hostNicGuid = Guid.createGuidFromString(attachment.getHostNic().getId());
        if (!nicId.equals(hostNicGuid)) {
            // TODO MM: add message.
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
    } else {
        HostNic hostNIC = new HostNic();
        hostNIC.setId(nicId.toString());
        attachment.setHostNic(hostNIC);
    }
    return super.add(attachment);
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Guid(org.ovirt.engine.core.compat.Guid)

Example 28 with HostNic

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

the class BackendHostNicNetworkAttachmentsResource method addParents.

@Override
protected org.ovirt.engine.api.model.NetworkAttachment addParents(org.ovirt.engine.api.model.NetworkAttachment model) {
    model.setHostNic(new HostNic());
    model.getHostNic().setId(nicId.toString());
    model.getHostNic().setHost(new Host());
    model.getHostNic().getHost().setId(getHostId().toString());
    return model;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Host(org.ovirt.engine.api.model.Host)

Example 29 with HostNic

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

the class BackendHostNicsResource method map.

protected HostNic map(VdsNetworkInterface iface, HostNic template, List<VdsNetworkInterface> ifaces) {
    HostNic nic = super.map(iface, template);
    if (iface.getBonded() != null && iface.getBonded()) {
        nic = addSlaveLinks(nic, getCollection(ifaces));
        nic = addActiveSlaveLink(nic, iface, getCollection(ifaces));
    } else if (iface.getBondName() != null) {
        nic = addMasterLink(nic, iface.getBondName(), getCollection(ifaces));
    }
    return nic;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic)

Example 30 with HostNic

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

the class BackendHostNicsResource method lookupNic.

public HostNic lookupNic(String id, boolean forcePopulate) {
    List<VdsNetworkInterface> ifaces = getCollection();
    for (VdsNetworkInterface iface : ifaces) {
        if (iface.getId().toString().equals(id)) {
            HostNic hostNic = map(iface, ifaces);
            if (forcePopulate) {
                deprecatedPopulate(hostNic, iface);
                doPopulate(hostNic, iface);
            } else {
                populate(hostNic, iface);
            }
            for (org.ovirt.engine.core.common.businessentities.network.Network nwk : getClusterNetworks()) {
                if (nwk.getName().equals(iface.getNetworkName())) {
                    hostNic.getNetwork().setId(nwk.getId().toString());
                    hostNic.getNetwork().setName(null);
                    break;
                }
            }
            return addLinks(hostNic);
        }
    }
    return notFound();
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

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