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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations