Usages of

org.onosproject.net.host.HostService.getHostsByMac(?)
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private OpenstackPort getOpenstackPort(MacAddress srcMac) { Optional<Host> host = hostService.getHostsByMac(srcMac).stream() .filter(h -> h.annotations().value(PORT_ID) != null) .findAny(); if (!host.isPresent()) { log.warn("Failed to find a host with MAC:{}", srcMac); return null; } return openstackService.port(host.get().annotations().value(PORT_ID)); }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... /** * Returns connect point of a given OpenStack port. * It assumes there's only one physical port associated with an OpenStack port. * * @param vPort openstack port * @return connect point, null if no such port exists */ private ConnectPoint getConnectPoint(OpenstackPort vPort) { try { Host host = hostService.getHostsByMac(vPort.macAddress()) .stream() .findFirst() .get(); return new ConnectPoint(host.location().deviceId(), host.location().port()); } catch (NoSuchElementException e) { log.debug("Not a valid host with {}", vPort.macAddress()); return null; } }
/** * Handles reply messages between VLAN tagged interfaces. * * @param context the message context * @param hostService the host service */ protected void handleReply(NeighbourMessageContext context, HostService hostService) { Set<Host> hosts = hostService.getHostsByMac(context.dstMac()); SetMultimap<String, Interface> interfaces = vplsConfigService.ifacesByVplsName(context.vlan(), context.inPort()); if (interfaces != null) { hosts.forEach(host -> interfaces.values().stream() .filter(intf -> intf.connectPoint().equals(host.location())) .filter(intf -> intf.vlan().equals(host.vlan())) .forEach(context::forward)); } else { log.debug(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan()); } }
/** * Handles reply messages between VLAN tagged interfaces. * * @param context the message context * @param hostService the host service */ protected void handleReply(NeighbourMessageContext context, HostService hostService) { SetMultimap<String, Interface> vplsNetwork = vplsConfigService.getVplsNetwork(context.vlan(), context.inPort()); Set<Host> hosts = hostService.getHostsByMac(context.dstMac()); if (vplsNetwork != null) { Collection<Interface> vplsInterfaces = vplsNetwork.values(); hosts.forEach(host -> vplsInterfaces.stream() .filter(intf -> intf.connectPoint().equals(host.location())) .filter(intf -> intf.vlan().equals(host.vlan())) .forEach(context::forward)); } else { log.debug(CAN_NOT_FIND_NETWORK, context.inPort(), context.vlan()); } }
/** * Handles reply messages between VLAN tagged interfaces. * * @param context the message context * @param hostService the host service */ protected void handleReply(NeighbourMessageContext context, HostService hostService) { SetMultimap<String, Interface> vplsNetwork = vplsConfigService.getVplsNetwork(context.vlan(), context.inPort()); Set<Host> hosts = hostService.getHostsByMac(context.dstMac()); if (vplsNetwork != null) { Collection<Interface> vplsInterfaces = vplsNetwork.values(); hosts.forEach(host -> vplsInterfaces.stream() .filter(intf -> intf.connectPoint().equals(host.location())) .filter(intf -> intf.vlan().equals(host.vlan())) .forEach(context::forward)); } else { log.debug(CAN_NOT_FIND_NETWORK, context.inPort(), context.vlan()); } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public DeviceId getSfToSffMaping(VirtualPortId portId) { checkNotNull(portId, "portId cannot be null"); VirtualPort vmPort = virtualPortService.getPort(portId); Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress()); for (Host host : hostSet) { if (host.annotations().value(IFACEID).equals(vmPort.portId().portId())) { return host.location().deviceId(); } } return null; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public DeviceId getSFToSFFMaping(VirtualPortId portId) { checkNotNull(portId, "portId cannot be null"); VirtualPort vmPort = virtualPortService.getPort(portId); Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress()); for (Host host : hostSet) { if (host.annotations().value(IFACEID).equals(vmPort.portId().portId())) { return host.location().deviceId(); } } return null; }
@Override public void handleMessage(NeighbourMessageContext context, HostService hostService) { switch (context.type()) { case REQUEST: interfaceService.getInterfacesByVlan(context.vlan()) .stream() .map(Interface::connectPoint) .forEach(context::forward); break; case REPLY: hostService.getHostsByMac(context.dstMac()) .stream() .filter(host -> host.vlan().equals(context.vlan())) .map(Host::location) .forEach(context::forward); break; default: log.warn("Unknown context type: {}", context.type()); break; } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override 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()); }); }
@Override public void handleMessage(NeighbourMessageContext context, HostService hostService) { switch (context.type()) { case REQUEST: interfaceService.getInterfacesByVlan(context.vlan()) .stream() .map(Interface::connectPoint) .forEach(context::proxy); break; case REPLY: hostService.getHostsByMac(context.dstMac()) .stream() .filter(host -> host.vlan().equals(context.vlan())) .map(Host::location) .forEach(context::proxy); break; default: log.warn("Unknown context type: {}", context.type()); break; } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes