private String getKey(VdsNetworkInterface nic) { return nic.getName(); } }
private static List<String> getNicNames(List<VdsNetworkInterface> nics) { List<String> result = new ArrayList<>(nics.size()); for (VdsNetworkInterface nic : nics) { result.add(nic.getName()); } return result; }
private List<HostVLan> gatherVlans(VdsNetworkInterface nic, Map<String, List<Vlan>> nicToVlans) { List<HostVLan> hostVlanList = new ArrayList<>(); if (nicToVlans.containsKey(nic.getName())) { for (Vlan vlan : nicToVlans.get(nic.getName())) { hostVlanList.add(hostVlanFromNic(vlan)); } } return hostVlanList; }
protected VdsNetworkInterface lookupInterfaceByName(String name) { for (VdsNetworkInterface iface : getCollection()) { if (iface.getName().equals(name)) { return iface; } } return null; }
@Override public String getName() { return getOriginalIface().getName(); }
private boolean isPhysicalNic(VdsNetworkInterface nic, Set<String> bondNames, Set<String> slaveNames) { boolean isBond = bondNames.contains(nic.getName()); boolean isRemovedBond = hostSetupNetworksParametersData.getRemovedBonds().contains(nic.getId()); boolean isSlave = slaveNames.contains(nic.getName()); boolean isVlanDevice = NetworkCommonUtils.isVlan(nic); return !(isBond || isRemovedBond || isSlave || isVlanDevice); }
/** * 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(); }
protected HostNic addMasterLink(HostNic nic, String bondName, List<VdsNetworkInterface> ifaces) { for (VdsNetworkInterface i : ifaces) { if (i.getName().equals(bondName)) { nic.getLinks().add(masterLink(i.getId().toString())); break; } } return nic; }
public NetworkAttachment(VdsNetworkInterface baseNic, Network network, IpConfiguration ipConfiguration) { this.networkId = network.getId(); this.networkName = network.getName(); this.nicId = baseNic.getId(); this.nicName = baseNic.getName(); this.ipConfiguration = ipConfiguration; }
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 assertBond(CreateOrUpdateBond bond, Guid bondId, List<VdsNetworkInterface> slaves) { assertThat("id mismatch", bond.getId(), is(bondId)); //$NON-NLS-1$ for (VdsNetworkInterface slave : slaves) { assertThat("missing slave", bond.getSlaves().contains(slave.getName()), is(true)); //$NON-NLS-1$ } assertThat("invalid slaves count", bond.getSlaves().size(), is(slaves.size())); //$NON-NLS-1$ }
private NetworkInterfaceModel createSlaveModel(final Map<Guid, VdsNetworkInterface> nicsById, VdsNetworkInterface slave) { final VdsNetworkInterface physicalFunction = findPhysicalFunction(nicsById, slave.getId()); NetworkInterfaceModel slaveModel = new NetworkInterfaceModel(slave, nicToVfsConfig.containsKey(slave.getId()), physicalFunction == null ? null : physicalFunction.getName(), this); slaveModel.setBonded(true); return slaveModel; }
private void initNicLabelsParameters() { for (VdsNetworkInterface nic : allExistingNics) { if (nic.getLabels() != null) { for (String label : nic.getLabels()) { getHostSetupNetworksParametersData().getLabels() .add(new NicLabel(nic.getId(), nic.getName(), label)); } getHostSetupNetworksParametersData().getOriginalLabels().addAll(nic.getLabels()); } } }
private CreateOrUpdateBond createBond(Guid id, String bondName, List<VdsNetworkInterface> slaves) { CreateOrUpdateBond result = new CreateOrUpdateBond(); result.setId(id); result.setName(bondName); for (VdsNetworkInterface slave : slaves) { result.getSlaves().add(slave.getName()); } return result; }
private void testUpdateInterface(Guid interface_id) { VdsNetworkInterface iface = dao.get(interface_id); iface.setName(iface.getName().toUpperCase()); iface.setQos(newQos); dao.updateInterfaceForVds(iface); VdsNetworkInterface ifaced = dao.get(interface_id); assertEquals(iface.getName(), ifaced.getName()); assertEquals(iface.getQos(), ifaced.getQos()); verifyIpv6Properties(iface, ifaced); }
private HostInterfaceLineModel lineModelFromBond(VdsNetworkInterface nic) { HostInterfaceLineModel model = lineModelFromInterface(nic); model.setInterface(nic); model.setIsBonded(true); model.setBondName(nic.getName()); model.setIpv4Address(nic.getIpv4Address()); model.setIpv6Address(nic.getIpv6Address()); return model; }
@Test public void testGetByName() { VdsNetworkInterface result = dao.get(existingVdsInterface.getVdsId(), existingVdsInterface.getName()); assertEquals(existingVdsInterface, result); } }
private HostVLan hostVlanFromNic(VdsNetworkInterface nic) { HostVLan hv = new HostVLan(); hv.setInterface(nic); hv.setName(nic.getName()); hv.setNetworkName(nic.getNetworkName()); hv.setIpv4Address(nic.getIpv4Address()); hv.setIpv6Address(nic.getIpv6Address()); hv.getPropertyChangedEvent().addListener(this); return hv; }
private void completeSlaveNames(BusinessEntityMap<VdsNetworkInterface> nicsFromBackend, HostNic bond) { if (bond.isSetBonding() && bond.getBonding().isSetSlaves()) { for (HostNic slave : bond.getBonding().getSlaves().getHostNics()) { if (!slave.isSetName() && slave.isSetId()){ Guid slaveId = new Guid(slave.getId()); String slaveNameFromBackend = nicsFromBackend.get(slaveId).getName(); slave.setName(slaveNameFromBackend); } } } }