Usages of

org.onosproject.net.host.HostService.getHost(?)
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private boolean isPortInUse(PortId portId) { ServicePort sport = servicePort(portId); if (sport == null) { final String error = String.format(MSG_SERVICE_PORT, portId, ERR_NOT_FOUND); throw new IllegalStateException(error); } // TODO use instance service to see if there's running instance for the port Host host = hostService.getHost(HostId.hostId(sport.mac())); return host != null; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... //send the response to the requestor host. private void sendReply(Ethernet ethPacket, DHCP dhcpPayload) { MacAddress descMac = new MacAddress(dhcpPayload.getClientHardwareAddress()); Host host = hostService.getHost(HostId.hostId(descMac, VlanId.vlanId(ethPacket.getVlanID()))); // Send packet out to requestor if the host information is available if (host != null) { TrafficTreatment t = DefaultTrafficTreatment.builder() .setOutput(host.location().port()).build(); OutboundPacket o = new DefaultOutboundPacket( host.location().deviceId(), t, ByteBuffer.wrap(ethPacket.serialize())); packetService.emit(o); } }
private static final HostService HOST_SERVICE = get(HostService.class); // code omitted ... private String findNextHopIp(Predicate<IpAddress> ipFilter, MacAddress nextHopMac, VlanId vlanId) { if (ipFilter == null || nextHopMac == null || vlanId == null) { return NA; } Host host = HOST_SERVICE.getHost(HostId.hostId(nextHopMac, vlanId)); if (host == null) { return NA; } return host.ipAddresses().stream() .filter(ipFilter) .filter(ip -> !ip.isLinkLocal()) .map(Object::toString) .findFirst() .orElse(NA); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... public void onVirtualPortDeleted(VtnRscEventFeedback l3Feedback) { VirtualPort vPort = l3Feedback.virtualPort(); HostId hostId = HostId.hostId(vPort.macAddress()); BasicHostConfig basicHostConfig = networkConfigService.addConfig(hostId, BasicHostConfig.class); Set<IpAddress> ips = hostService.getHost(hostId).ipAddresses(); for (FixedIp fixedIp : vPort.fixedIps()) { ips.remove(fixedIp.ip()); } basicHostConfig.setIps(ips).apply(); }
private final HostService hostService = DefaultServiceDirectory.getService(HostService.class); // code omitted ... @Override public void modifyHostDetails(PropertyPanel pp, HostId hostId) { String vni = hostService.getHost(hostId).annotations().value(ANNOTATION_SEGMENT_ID); pp.removeProps(VLAN); pp.addProp(SONA, VNI, vni == null ? NOT_AVAILABLE : vni) .addButton(FLOW_TRACE_BUTTON) .addButton(RESET_BUTTON) .addButton(TO_GATEWAY_BUTTON) .addButton(TO_EXTERNAL_BUTTON); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... //send the response to the requestor host. private void sendReply(Ethernet ethPacket) { //get the host info Host host = hostService.getHost(HostId.hostId(ethPacket.getDestinationMAC(), VlanId.vlanId(ethPacket.getVlanID()))); ConnectPoint dhcpRequestor = new ConnectPoint(host.location().elementId(), host.location().port()); //send Packetout to requestor host. if (dhcpRequestor != null) { TrafficTreatment t = DefaultTrafficTreatment.builder() .setOutput(dhcpRequestor.port()).build(); OutboundPacket o = new DefaultOutboundPacket( dhcpRequestor.deviceId(), t, ByteBuffer.wrap(ethPacket.serialize())); packetService.emit(o); } }
protected HostService hostService; // code omitted ... // the element ID is not a host ID, returns NOT_HOST edge link. private EdgeLink getEdgeLink(ElementId elementId, boolean isIngress) { if (elementId instanceof HostId) { // Resolve the host, return null. Host host = hostService.getHost((HostId) elementId); if (host == null) { return null; } return new DefaultEdgeLink(PID, new ConnectPoint(elementId, P0), host.location(), isIngress); } return NOT_HOST; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... //send the response to the requestor host. private void sendReply(Ethernet ethPacket, DHCP dhcpPayload) { MacAddress descMac = new MacAddress(dhcpPayload.getClientHardwareAddress()); Host host = hostService.getHost(HostId.hostId(descMac, VlanId.vlanId(ethPacket.getVlanID()))); ConnectPoint dhcpRequestor = new ConnectPoint(host.location().elementId(), host.location().port()); //send Packetout to requestor host. if (dhcpRequestor != null) { TrafficTreatment t = DefaultTrafficTreatment.builder() .setOutput(dhcpRequestor.port()).build(); OutboundPacket o = new DefaultOutboundPacket( dhcpRequestor.deviceId(), t, ByteBuffer.wrap(ethPacket.serialize())); packetService.emit(o); } }
private HostService hostService; // code omitted ... /** * Tests {@link ProxyArpManager#reply(Ethernet)} in the case where the * destination host is known. * Verifies the correct ARP reply is sent out the correct port. */ @Test public void testReplyKnown() { Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(4), Collections.singleton(IP1)); Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5), Collections.singleton(IP2)); expect(hostService.getHostsByIp(IP1)) .andReturn(Collections.singleton(replyer)); expect(hostService.getHost(HID2)).andReturn(requestor); replay(hostService); Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1); proxyArp.reply(arpRequest, getLocation(5)); assertEquals(1, packetService.packets.size()); Ethernet arpReply = buildArp(ARP.OP_REPLY, MAC1, MAC2, IP1, IP2); verifyPacketOut(arpReply, getLocation(5), packetService.packets.get(0)); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { // If source and destination are the same, there are never any installables. if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPathOrException(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPathOrException(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createLinkCollectionIntent(pathOne, one, two, intent), createLinkCollectionIntent(pathTwo, two, one, intent)); }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes