/** * Determine if a given network interface is a vlan device * * @param nic * the nic to check. * @return <code>true</code> iff the nic is a vlan. */ public static boolean isVlan(VdsNetworkInterface nic) { return nic.getVlanId() != null; }
private Map<Integer, VdsNetworkInterface> mapVlanDevicesByVlanId() { Map<Integer, VdsNetworkInterface> vlanDevicesByVlanId = new HashMap<>(); for (VdsNetworkInterface nic : allExistingNics) { if (nic.getVlanId() != null) { vlanDevicesByVlanId.put(nic.getVlanId(), nic); } } return vlanDevicesByVlanId; }
/** * Checks if a given nic is labeled properly: either an interface or a bond (not a slave nor vlan). * * @param iface * the nic to check * @return <code>true</code> iff the nic is properly labeled or if no labels provided for it, else * <code>false</code> */ private boolean validateLabel(VdsNetworkInterface iface) { return iface.getLabels() == null || iface.getLabels().isEmpty() ? true : isEmpty(iface.getBondName()) && iface.getVlanId() == null; } }
/** * 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; }
private ReportedConfiguration reportEqualVLAN() { return new ReportedConfiguration(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId(), true); }
private LogicalNetworkModel createUnmanagedNetworkModel(String networkName, VdsNetworkInterface nic) { Network unmanagedNetwork = new Network(); unmanagedNetwork.setName(networkName); unmanagedNetwork.setVlanId(nic.getVlanId()); unmanagedNetwork.setMtu(nic.getMtu()); unmanagedNetwork.setVmNetwork(nic.isBridged()); LogicalNetworkModel networkModel = new LogicalNetworkModel(unmanagedNetwork, null, this); return networkModel; }
isNetworkMtuInSync()); result.add(ReportedConfigurationType.BRIDGED, iface.isBridged(), network.isVmNetwork()); result.add(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId()); result.add(ReportedConfigurationType.SWITCH_TYPE, iface.getReportedSwitchType(),
.addValue("type", nic.getType()) .addValue("vds_id", nic.getVdsId()) .addValue("vlan_id", nic.getVlanId()) .addValue("base_interface", nic.getBaseInterface()) .addValue("mtu", nic.getMtu())