Search in sources :

Example 6 with HostNic

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

the class BackendHostNicsResource method slave.

protected HostNic slave(String id) {
    HostNic slave = new HostNic();
    slave.setId(id);
    slave.setHost(new Host());
    slave.getHost().setId(hostId);
    slave = LinkHelper.addLinks(slave, null, false);
    slave.setHost(null);
    return slave;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Host(org.ovirt.engine.api.model.Host)

Example 7 with HostNic

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

the class BackendHostResource method mapBonds.

public CreateOrUpdateBond mapBonds(BusinessEntityMap<Bond> bonds, HostNic model) {
    Mapper<HostNic, Bond> hostNicMapper = getMapper(HostNic.class, Bond.class);
    Bond bond;
    if (model.isSetId()) {
        Guid nicId = asGuid(model.getId());
        bond = hostNicMapper.map(model, bonds.get(nicId));
    } else {
        Bond template = model.isSetName() ? bonds.get(model.getName()) : null;
        bond = hostNicMapper.map(model, template);
    }
    return CreateOrUpdateBond.fromBond(bond);
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Guid(org.ovirt.engine.core.compat.Guid) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 8 with HostNic

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

the class BackendHostNicsResource method doPopulate.

@Override
protected HostNic doPopulate(HostNic model, VdsNetworkInterface entity) {
    final HostNic hostNic = super.doPopulate(model, entity);
    final Guid nicId = entity.getId();
    final HostNicVfsConfig hostNicVfsConfig = findVfsConfig(nicId);
    if (hostNicVfsConfig == null) {
        final Map<Guid, Guid> vfMap = retriveVfMap();
        final Guid physicalFunctionNicId = vfMap.get(nicId);
        if (physicalFunctionNicId != null) {
            final HostNic physicalFunction = new HostNic();
            physicalFunction.setId(physicalFunctionNicId.toString());
            hostNic.setPhysicalFunction(physicalFunction);
        }
    } else {
        final Mapper<HostNicVfsConfig, HostNicVirtualFunctionsConfiguration> mapper = getMapper(HostNicVfsConfig.class, HostNicVirtualFunctionsConfiguration.class);
        final HostNicVirtualFunctionsConfiguration vfsConfigModel = mapper.map(hostNicVfsConfig, new HostNicVirtualFunctionsConfiguration());
        hostNic.setVirtualFunctionsConfiguration(vfsConfigModel);
    }
    return hostNic;
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostNicVirtualFunctionsConfiguration(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration) HostNic(org.ovirt.engine.api.model.HostNic) Guid(org.ovirt.engine.core.compat.Guid)

Example 9 with HostNic

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

the class HostNicMapper method map.

@Mapping(from = HostNic.class, to = VdsNetworkInterface.class)
public static VdsNetworkInterface map(HostNic model, VdsNetworkInterface template) {
    VdsNetworkInterface entity;
    if (template != null) {
        entity = template;
    } else if (model.isSetBonding()) {
        entity = new Bond();
    } else if (model.isSetVlan()) {
        entity = new Vlan();
    } else {
        entity = new Nic();
    }
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetNetwork() && model.getNetwork().isSetName()) {
        entity.setNetworkName(model.getNetwork().getName());
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetBaseInterface()) {
        entity.setBaseInterface(model.getBaseInterface());
    }
    mapIpv4FromModel(model, entity);
    mapIpv6FromModel(model, entity);
    if (model.isSetMac() && model.getMac().isSetAddress()) {
        entity.setMacAddress(model.getMac().getAddress());
    }
    if (model.isSetBonding()) {
        entity.setBonded(true);
        if (model.getBonding().isSetOptions()) {
            List<Option> bondingOptions = model.getBonding().getOptions().getOptions();
            String optionsString = bondingOptions.stream().filter(Option::isSetName).map(x -> x.getName() + "=" + x.getValue()).collect(joining(" "));
            entity.setBondOptions(optionsString);
        }
    }
    if (model.isSetQos()) {
        entity.setQos((HostNetworkQos) QosMapper.map(model.getQos(), null));
    }
    return entity;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) HostNic(org.ovirt.engine.api.model.HostNic) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) Option(org.ovirt.engine.api.model.Option) Network(org.ovirt.engine.api.model.Network) Mac(org.ovirt.engine.api.model.Mac) BootProtocol(org.ovirt.engine.api.model.BootProtocol) Bonding(org.ovirt.engine.api.model.Bonding) IpVersion(org.ovirt.engine.api.model.IpVersion) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors.joining(java.util.stream.Collectors.joining) NicStatus(org.ovirt.engine.api.model.NicStatus) UpdateHostNicVfsConfigParameters(org.ovirt.engine.core.common.action.UpdateHostNicVfsConfigParameters) List(java.util.List) HostNicVirtualFunctionsConfiguration(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Ip(org.ovirt.engine.api.model.Ip) Options(org.ovirt.engine.api.model.Options) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HostNic(org.ovirt.engine.api.model.HostNic) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Option(org.ovirt.engine.api.model.Option) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 10 with HostNic

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

the class UnmanagedNetworkMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.UnmanagedNetwork.class, to = UnmanagedNetwork.class)
public static UnmanagedNetwork map(org.ovirt.engine.core.common.businessentities.UnmanagedNetwork entity, UnmanagedNetwork template) {
    if (entity == null) {
        return template;
    }
    UnmanagedNetwork model = template == null ? new UnmanagedNetwork() : template;
    model.setId(HexUtils.string2hex(entity.getId()));
    if (entity.getNicId() != null) {
        HostNic hostNic = new HostNic();
        hostNic.setId(entity.getNicId().toString());
        model.setHostNic(hostNic);
    }
    model.setName(entity.getNetworkName());
    return model;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) UnmanagedNetwork(org.ovirt.engine.api.model.UnmanagedNetwork)

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