/** * Returns the underlying interface name of a given nic * * @return Base interface name if the nic is a vlan device. * Otherwise, the name of the nic */ public static String stripVlan(VdsNetworkInterface nic) { return isVlan(nic) ? nic.getBaseInterface() : nic.getName(); }
String nameWithoutVlan = nic.getBaseInterface(); if (nicToVlans.containsKey(nameWithoutVlan)) { nicToVlans.get(nameWithoutVlan).add((Vlan) nic);
private VdsNetworkInterface getPotentialVlanDevice(VdsNetworkInterface targetNic) { VdsNetworkInterface potentialVlanDeviceToAttachTo = networkModel.getSetupModel().getExistingVlanDeviceByVlanId(networkModel.getVlanId()); if (potentialVlanDeviceToAttachTo != null && potentialVlanDeviceToAttachTo.getBaseInterface().equals(targetNic.getName())) { return potentialVlanDeviceToAttachTo; } else { return null; } }
private void setVlanDeviceOnNetworkModelIfNeeded(String baseNicName, LogicalNetworkModel networkModel) { if (networkModel.hasVlan()) { VdsNetworkInterface existingVlanDevice = networkModel.getVlanDevice(); assert existingVlanDevice == null : "should have only one vlan device, but found " + existingVlanDevice; //$NON-NLS-1$ VdsNetworkInterface vlanDeviceWithTheSameVlanIdAsTheNetwork = getExistingVlanDeviceByVlanId(networkModel.getVlanId()); if (vlanDeviceWithTheSameVlanIdAsTheNetwork != null && baseNicName.equals(vlanDeviceWithTheSameVlanIdAsTheNetwork.getBaseInterface())) { networkModel.setVlanDevice(vlanDeviceWithTheSameVlanIdAsTheNetwork); } } }
/** * Validate the slave is configured properly by the following traits: * <ul> * <li>No network name</li> * <li>No vlan configured: {@link VdsNetworkInterface#getBaseInterface()} and * {@link VdsNetworkInterface#getVlanId()} are <code>null</code></li> * </ul> * * @param slave * The network interface represents a slave * @return {@code true} if the slave is configured properly. */ private boolean validateSlave(VdsNetworkInterface slave) { return isEmpty(slave.getNetworkName()) && isEmpty(slave.getBaseInterface()) && slave.getVlanId() == null; }
model.setName(entity.getName()); if (entity.getBaseInterface() != null) { model.setBaseInterface(entity.getBaseInterface());
.addValue("vds_id", nic.getVdsId()) .addValue("vlan_id", nic.getVlanId()) .addValue("base_interface", nic.getBaseInterface()) .addValue("mtu", nic.getMtu()) .addValue("bridged", nic.isBridged())