@Override public boolean test(VdsNetworkInterface iface) { return iface.getNetworkName() != null && iface.getNetworkName().equals(hostManagementNetworkName); } }
public static <E extends VdsNetworkInterface> Map<String, E> hostInterfacesByNetworkName(Collection<E> hostNics) { return hostNics == null ? Collections.emptyMap() : hostNics.stream() .filter(hostNic -> hostNic.getNetworkName() != null) .collect(Collectors.toMap(VdsNetworkInterface::getNetworkName, Function.identity())); }
private org.ovirt.engine.core.common.businessentities.network.Network getOldNetwork(VdsNetworkInterface originalInter) { String oldNetworkName = originalInter.getNetworkName(); if (!StringUtils.isEmpty(oldNetworkName)) { return lookupAtachedNetwork(originalInter.getNetworkName()); } else { InterfaceAndIdQueryParameters params = new InterfaceAndIdQueryParameters( originalInter.getVdsId(), originalInter); List<VdsNetworkInterface> vlans = getBackendCollection(VdsNetworkInterface.class, QueryType.GetAllChildVlanInterfaces, params); if (vlans!=null && !vlans.isEmpty()) { return lookupAtachedNetwork(vlans.get(0).getNetworkName()); } else { return null; } } }
public void createModelsForUnamangedNetworks(Map<String, Set<LogicalNetworkModel>> nicToNetworks) { for (VdsNetworkInterface nic : allExistingNics) { if (shouldCreateUnmanagedNetworkModel(nic)) { LogicalNetworkModel networkModel = createUnmanagedNetworkModel(nic.getNetworkName(), nic); networkModelByName.put(networkModel.getName(), networkModel); String baseNicName = NetworkCommonUtils.stripVlan(nic); if (!nicToNetworks.containsKey(baseNicName)) { nicToNetworks.put(baseNicName, new HashSet<LogicalNetworkModel>()); } nicToNetworks.get(baseNicName).add(networkModel); } } }
private boolean shouldCreateUnmanagedNetworkModel(VdsNetworkInterface nic) { return nic.getNetworkImplementationDetails() != null && !nic.getNetworkImplementationDetails().isManaged() && !hostSetupNetworksParametersData.getRemovedUnmanagedNetworks().contains(nic.getNetworkName()); }
/** * 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 HostInterfaceLineModel lineModelFromInterface(VdsNetworkInterface nic) { HostInterfaceLineModel model = new HostInterfaceLineModel(); model.setInterfaces(new ArrayList<HostInterface>()); model.setVLans(new ArrayList<HostVLan>()); model.setNetworkName(nic.getNetworkName()); model.setIsManagement(nic.getIsManagement()); model.setIpv4Address(nic.getIpv4Address()); model.setIpv6Address(nic.getIpv6Address()); return model; }
@Override public HostNics list() { HostNics ret = new HostNics(); List<VdsNetworkInterface> ifaces = getCollection(); Map<String, Guid> networkNameToNetworkIdMap = mapNetworkNamesToNetworkIds(); Map<Guid, NetworkAttachment> attachmentsByNetworkId = getAttachmentsByNetworkId(); for (VdsNetworkInterface iface : ifaces) { HostNic hostNic = populate(map(iface, ifaces), iface); setCustomProperties(attachmentsByNetworkId, networkNameToNetworkIdMap, hostNic); String networkName = iface.getNetworkName(); if (networkNameToNetworkIdMap.containsKey(networkName)) { Guid networkId = networkNameToNetworkIdMap.get(networkName); hostNic.getNetwork().setId(networkId.toString()); hostNic.getNetwork().setName(null); } ret.getHostNics().add(addLinks(hostNic)); } return addActions(ret); }
@Test public void massClearNetworkFromNicsTest() { VdsNetworkInterface nic1 = dao.get(FixturesTool.VDS_NETWORK_INTERFACE); VdsNetworkInterface nic2 = dao.get(FixturesTool.VDS_NETWORK_INTERFACE_WITHOUT_QOS); VdsNetworkInterface nic3 = dao.get(FixturesTool.VDS_NETWORK_INTERFACE2); assertNotNull(nic1.getNetworkName()); assertNotNull(nic2.getNetworkName()); assertNotNull(nic3.getNetworkName()); dao.massClearNetworkFromNics(Arrays.asList(nic1.getId(), nic2.getId())); nic1 = dao.get(nic1.getId()); nic2 = dao.get(nic2.getId()); nic3 = dao.get(nic3.getId()); assertNull(nic1.getNetworkName()); assertNull(nic2.getNetworkName()); assertNotNull(nic3.getNetworkName()); }
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; }
public HostNic lookupNic(String id, boolean forcePopulate) { List<VdsNetworkInterface> ifaces = getCollection(); for (VdsNetworkInterface iface : ifaces) { if (iface.getId().toString().equals(id)) { HostNic hostNic = map(iface, ifaces); if (forcePopulate) { deprecatedPopulate(hostNic, iface); doPopulate(hostNic, iface); } else { populate(hostNic, iface); } for (org.ovirt.engine.core.common.businessentities.network.Network nwk : getClusterNetworks()) { if (nwk.getName().equals(iface.getNetworkName())) { hostNic.getNetwork().setId(nwk.getId().toString()); hostNic.getNetwork().setName(null); break; } } return addLinks(hostNic); } } return notFound(); }
model.setId(entity.getId().toString()); if (entity.getNetworkName() != null) { model.setNetwork(new Network()); model.getNetwork().setName(entity.getNetworkName());
protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return tsb.append("id", getId()) .append("name", getName()) .append("vdsId", getVdsId()) .append("networkName", getNetworkName()) .append("ipv4BootProtocol", getIpv4BootProtocol()) .append("ipv4Address", getIpv4Address()) .append("ipv4Subnet", getIpv4Subnet()) .append("ipv4Gateway", getIpv4Gateway()) .append("ipv6BootProtocol", getIpv6BootProtocol()) .append("ipv6Address", getIpv6Address()) .append("ipv6Prefix", getIpv6Prefix()) .append("ipv6Gateway", getIpv6Gateway()) .append("mtu", getMtu()) .append("bridged", isBridged()) .append("reportedSwitchType", getReportedSwitchType()) .append("type", getType()) .append("networkImplementationDetails", getNetworkImplementationDetails()) .append("qos", getQos()) .append("adPartnerMac", getAdPartnerMac()) .append("adAggregatorId", adAggregatorId); }
.addValue("mac_addr", nic.getMacAddress()) .addValue("name", nic.getName()) .addValue("network_name", nic.getNetworkName()) .addValue("speed", nic.getSpeed()) .addValue("subnet", nic.getIpv4Subnet())