Usages of

org.onosproject.net.host.HostService.getConnectedHosts(?)
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) private HostService hostService; // code omitted ... /** * Find Host connected to a device at a designated port. * * @param deviceId DeviceId of the device to check. * @param inPort Port of the device to check. * @return Host connected to the port or null if not found. */ private Host findConnectedHost(DeviceId deviceId, PortNumber inPort) { for (Host connectedHost : hostService.getConnectedHosts(deviceId)) { if (connectedHost.location().port().equals(inPort)) { return connectedHost; } } return null; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void removeHosts(ConnectPoint connectPoint) { hostService.getConnectedHosts(connectPoint).stream() .forEach(host -> { dhcpService.removeStaticMapping(host.mac()); hostProvider.hostVanished(host.id()); }); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void processPortRemoved(Port port) { ConnectPoint connectPoint = new ConnectPoint(port.element().id(), port.number()); hostService.getConnectedHosts(connectPoint).forEach(host -> { hostProvider.hostVanished(host.id()); }); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public void removeInstance(ConnectPoint connectPoint) { hostService.getConnectedHosts(connectPoint).forEach(host -> { hostProvider.hostVanished(host.id()); }); }
// Finds an available connect point among edge ports of the specified device private HostLocation findAvailablePort(DeviceId deviceId) { EdgePortService eps = get(EdgePortService.class); HostService hs = get(HostService.class); Iterator<ConnectPoint> points = eps.getEdgePoints(deviceId).iterator(); while (points.hasNext()) { ConnectPoint point = points.next(); if (hs.getConnectedHosts(point).isEmpty()) { return new HostLocation(point, System.currentTimeMillis()); } } return null; }
// Finds an available connect point among edge ports of the specified device private ConnectPoint findAvailablePort(DeviceId deviceId, ConnectPoint otherPoint) { EdgePortService eps = get(EdgePortService.class); HostService hs = get(HostService.class); Iterator<ConnectPoint> points = eps.getEdgePoints(deviceId).iterator(); while (points.hasNext()) { ConnectPoint point = points.next(); if (!Objects.equals(point, otherPoint) && hs.getConnectedHosts(point).isEmpty()) { return point; } } return null; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override // TODO address service specific task in a separate package public void updateVirtualSubscriberGateways(HostId vSgHostId, String serviceVlan, Map<IpAddress, MacAddress> vSgs) { Host vSgHost = hostService.getHost(vSgHostId); if (vSgHost == null || !vSgHost.annotations().value(S_TAG).equals(serviceVlan)) { log.debug("Invalid vSG updates for {}", serviceVlan); return; } log.info("Updates vSGs in {} with {}", vSgHost.id(), vSgs.toString()); vSgs.entrySet().stream() .filter(entry -> hostService.getHostsByMac(entry.getValue()).isEmpty()) .forEach(entry -> addVirtualSubscriberGateway( vSgHost, entry.getKey(), entry.getValue(), serviceVlan)); hostService.getConnectedHosts(vSgHost.location()).stream() .filter(host -> !host.mac().equals(vSgHost.mac())) .filter(host -> !vSgs.values().contains(host.mac())) .forEach(host -> { log.info("Removed vSG {}", host.toString()); hostProvider.hostVanished(host.id()); }); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... /** * Performs tasks after node initialization. * First disconnect unnecessary OVSDB connection and then installs flow rules * for existing VMs if there are any. * * @param node cordvtn node */ private void postInit(CordVtnNode node) { disconnect(node); Set<OpenstackNetwork> vNets = Sets.newHashSet(); hostService.getConnectedHosts(node.intBrId()) .stream() .forEach(host -> { OpenstackNetwork vNet = getOpenstackNetworkByHost(host); if (vNet != null) { log.info("VM {} is detected", host.id()); hostNetworkMap.put(host.id(), vNet.id()); vNets.add(vNet); } }); vNets.stream().forEach(this::installFlowRules); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void forwardManagementArpRequest(PacketContext context, Ethernet ethPacket) { DeviceId deviceId = context.inPacket().receivedFrom().deviceId(); PortNumber hostMgmtPort = nodeManager.hostManagementPort(deviceId); Host host = hostService.getConnectedHosts(context.inPacket().receivedFrom()) .stream() .findFirst().orElse(null); if (host == null || !Instance.of(host).netType().name().contains("MANAGEMENT") || hostMgmtPort == null) { context.block(); return; } TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(hostMgmtPort) .build(); packetService.emit(new DefaultOutboundPacket( context.inPacket().receivedFrom().deviceId(), treatment, ByteBuffer.wrap(ethPacket.serialize()))); log.trace("Forward ARP request to management network"); context.block(); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... public DeviceId getLocatedDevice(TrafficFeature tf) { DeviceId deviceId = null; List<DeviceId> devices = getDeviceId(); for (DeviceId did : devices) { for (Host host : hostService.getConnectedHosts(did)) { for (IpAddress ipAddress : host.ipAddresses()) { if (ipAddress.equals(tf.getSrc().address())) { return did; } } } } return null; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes