use of org.ovirt.engine.core.common.businessentities.network.Vlan in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method addHostVlanDevices.
/**
* Updates the host interfaces list with vlan devices
*
* @param vds
* The host to update
* @param struct
* a map contains pairs of vlan device name and vlan data
*/
private static void addHostVlanDevices(VDS vds, Map<String, Object> struct) {
// vlans
Map<String, Map<String, Object>> vlans = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_VLANS);
if (vlans != null) {
for (Entry<String, Map<String, Object>> entry : vlans.entrySet()) {
VdsNetworkInterface vlan = new Vlan();
updateCommonInterfaceData(vlan, vds, entry);
String vlanDeviceName = entry.getKey();
Map<String, Object> vlanProperties = entry.getValue();
if (vlanProperties.get(VdsProperties.VLAN_ID) != null && vlanProperties.get(VdsProperties.BASE_INTERFACE) != null) {
vlan.setVlanId((Integer) vlanProperties.get(VdsProperties.VLAN_ID));
vlan.setBaseInterface((String) vlanProperties.get(VdsProperties.BASE_INTERFACE));
} else if (vlanDeviceName.contains(".")) {
String[] names = vlanDeviceName.split("[.]", -1);
String vlanId = names[1];
vlan.setVlanId(Integer.parseInt(vlanId));
vlan.setBaseInterface(names[0]);
}
vds.getInterfaces().add(vlan);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Vlan in project ovirt-engine by oVirt.
the class HostInterfaceListModel method classifyNics.
private void classifyNics(List<Bond> nonEmptyBonds, List<Nic> independentNics, Map<String, List<Nic>> bondToNics, Map<String, List<Vlan>> nicToVlans) {
for (VdsNetworkInterface nic : getOriginalItems()) {
if (nic instanceof Bond) {
nonEmptyBonds.add((Bond) nic);
} else if (nic instanceof Nic) {
if (nic.getBondName() == null) {
independentNics.add((Nic) nic);
} else {
if (bondToNics.containsKey(nic.getBondName())) {
bondToNics.get(nic.getBondName()).add((Nic) nic);
} else {
List<Nic> nicList = new ArrayList<>();
nicList.add((Nic) nic);
bondToNics.put(nic.getBondName(), nicList);
}
}
} else if (nic instanceof Vlan) {
String nameWithoutVlan = nic.getBaseInterface();
if (nicToVlans.containsKey(nameWithoutVlan)) {
nicToVlans.get(nameWithoutVlan).add((Vlan) nic);
} else {
List<Vlan> vlanList = new ArrayList<>();
vlanList.add((Vlan) nic);
nicToVlans.put(nameWithoutVlan, vlanList);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Vlan 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.core.common.businessentities.network.Vlan in project ovirt-engine by oVirt.
the class NetworkUtilsTest method createVlan.
private VdsNetworkInterface createVlan(String baseIfaceName) {
VdsNetworkInterface iface = new Vlan();
iface.setVlanId(RandomUtils.instance().nextInt(100));
iface.setBaseInterface(baseIfaceName);
return iface;
}
Aggregations