Usages of

org.onosproject.net.host.HostService.getHostsByIp(?)
private HostService hostService; // code omitted ... /** * Sets expectations on the host service for a given host. * * @param host host */ private void expectHost(Host host) { // Assume the host only has one IP address IpAddress ip = host.ipAddresses().iterator().next(); expect(hostService.getHostsByIp(ip)) .andReturn(Sets.newHashSet(host)).anyTimes(); hostService.startMonitoringIp(ip); expectLastCall().anyTimes(); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public Optional<MacAddress> getDhcpServerMacAddress() { // TODO: depreated it DefaultDhcpRelayConfig config = cfgService.getConfig(appId, DefaultDhcpRelayConfig.class); DhcpServerConfig serverConfig = config.dhcpServerConfigs().get(0); Ip4Address serverip = serverConfig.getDhcpServerIp4().get(); return hostService.getHostsByIp(serverip) .stream() .map(Host::mac) .findFirst(); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private Host getFirstHostByIp(IpAddress ip) { Set<Host> dstHosts = hostService.getHostsByIp(ip); if (null != dstHosts && dstHosts.size() > 0) { return (Host) dstHosts.toArray()[0]; } return null; }
private HostService hostService; // code omitted ... /** * Tests {@link ProxyArpManager#isKnown(org.onlab.packet.IpAddress)} in the * case where the IP address is not known. * Verifies the method returns false. */ @Test public void testNotKnown() { expect(hostService.getHostsByIp(IP1)).andReturn(Collections.emptySet()); replay(hostService); replay(interfaceService); assertFalse(proxyArp.isKnown(IP1)); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public boolean isKnown(IpAddress addr) { checkPermission(PACKET_READ); checkNotNull(addr, MAC_ADDR_NULL); Set<Host> hosts = hostService.getHostsByIp(addr); return !hosts.isEmpty(); }
private HostService hostService; // code omitted ... /** * Tests {@link ProxyArpManager#isKnown(org.onlab.packet.IpAddress)} in the * case where the IP address is not known. * Verifies the method returns false. */ @Test public void testNotKnown() { expect(hostService.getHostsByIp(IP1)).andReturn(Collections.emptySet()); replay(hostService); replay(interfaceService); assertFalse(proxyArp.isKnown(IP1)); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public boolean isKnown(IpAddress addr) { checkPermission(Permission.PACKET_READ); checkNotNull(addr, MAC_ADDR_NULL); Set<Host> hosts = hostService.getHostsByIp(addr); return !hosts.isEmpty(); }
private HostService hostService; // code omitted ... /** * Tests {@link ProxyArpManager#isKnown(org.onlab.packet.IpAddress)} in the * case where the IP address is not known. * Verifies the method returns false. */ @Test public void testNotKnown() { expect(hostService.getHostsByIp(IP1)).andReturn(Collections.<Host>emptySet()); replay(hostService); replay(interfaceService); assertFalse(proxyArp.isKnown(IP1)); }
public CordVtnArpProxy(ApplicationId appId, PacketService packetService, HostService hostService) { // code omitted ... /** * Returns MAC address of a host with a given target IP address by asking to * host service. It does not support overlapping IP. * * @param targetIp target ip * @return mac address, or NONE mac address if it fails to find the mac */ private MacAddress getMacFromHostService(IpAddress targetIp) { checkNotNull(targetIp); Host host = hostService.getHostsByIp(targetIp) .stream() .findFirst() .orElse(null); if (host != null) { log.trace("Found MAC from host service for {}", targetIp.toString()); return host.mac(); } else { return MacAddress.NONE; } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private ResolvedRoute resolve(Route route) { hostService.startMonitoringIp(route.nextHop()); Set<Host> hosts = hostService.getHostsByIp(route.nextHop()); Optional<Host> host = hosts.stream().findFirst(); if (host.isPresent()) { return new ResolvedRoute(route, host.get().mac(), host.get().vlan(), host.get().location()); } else { return null; } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes