@Override public Set<Host> getHosts(MacAddress mac) { Set<Host> macset = new HashSet<>(); for (Host h : hosts.values()) { if (h.mac().equals(mac)) { macset.add(h); } } return macset; }
/** * 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 null 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.debug("Found MAC from host service for {}", targetIp.toString()); return host.mac(); } else { return null; } } }
@Override public void event(HostEvent event) { log.debug("Received HostEvent {}", event); Host host = event.subject(); switch (event.type()) { case HOST_ADDED: // FALLTHROUGH case HOST_UPDATED: for (IpAddress ipAddress : host.ipAddresses()) { updateMac(ipAddress, host.mac()); } break; case HOST_REMOVED: for (IpAddress ipAddress : host.ipAddresses()) { ip2Mac.remove(ipAddress); } break; default: break; } } }
/** * Returns a description of the given host. * * @param host the host * @return a description of the host */ public static HostDescription descriptionOf(Host host) { checkNotNull(host, "Must supply a non-null Host"); return new DefaultHostDescription(host.mac(), host.vlan(), host.locations(), host.ipAddresses(), host.configured(), (SparseAnnotations) host.annotations()); } }
if (!peerIntf.isPresent()) { log.debug("Removing peer {}/{} on {} but the interface is not configured", peer.mac(), peer.vlan(), peer.location()); return;
@Override public ObjectNode encode(Host host, CodecContext context) { checkNotNull(host, "Host cannot be null"); final JsonCodec<HostLocation> locationCodec = context.codec(HostLocation.class); final ObjectNode result = context.mapper().createObjectNode() .put("id", host.id().toString()) .put("mac", host.mac().toString()) .put("vlan", host.vlan().toString()) .put("innerVlan", host.innerVlan().toString()) .put("outerTpid", host.tpid().toString()) .put("configured", host.configured()); final ArrayNode jsonIpAddresses = result.putArray("ipAddresses"); for (final IpAddress ipAddress : host.ipAddresses()) { jsonIpAddresses.add(ipAddress.toString()); } result.set("ipAddresses", jsonIpAddresses); final ArrayNode jsonLocations = result.putArray("locations"); for (final HostLocation location : host.locations()) { jsonLocations.add(locationCodec.encode(location, context)); } result.set("locations", jsonLocations); return annotate(result, host, context); }
private void peerAdded(HostEvent event) { Host peer = event.subject(); Optional<Interface> peerIntf = interfaceService.getInterfacesByPort(peer.location()).stream() .filter(intf -> interfaces.isEmpty() || interfaces.contains(intf.name())) .filter(intf -> peer.vlan().equals(intf.vlan())) .findFirst(); if (!peerIntf.isPresent()) { log.debug("Adding peer {}/{} on {} but the interface is not configured", peer.mac(), peer.vlan(), peer.location()); return; } // Generate L3 Unicast groups and store it in the map int toRouterL3Unicast = createPeerGroup(peer.mac(), peerIntf.get().mac(), peer.vlan(), peer.location().deviceId(), controlPlaneConnectPoint.port()); int toPeerL3Unicast = createPeerGroup(peerIntf.get().mac(), peer.mac(), peer.vlan(), peer.location().deviceId(), peer.location().port()); peerNextId.put(peer, ImmutableSortedSet.of(toRouterL3Unicast, toPeerL3Unicast)); // From peer to router peerIntf.get().ipAddresses().forEach(routerIp -> { flowObjectiveService.forward(peer.location().deviceId(), createPeerObjBuilder(toRouterL3Unicast, routerIp.ipAddress().toIpPrefix()).add()); }); // From router to peer peer.ipAddresses().forEach(peerIp -> { flowObjectiveService.forward(peer.location().deviceId(), createPeerObjBuilder(toPeerL3Unicast, peerIp.toIpPrefix()).add()); }); }
private void sendEastWestL3Flows(Host h, MacAddress srcVmGwMac, SegmentationId l3vni, IpAddress srcGwIp, TenantNetwork network, IpAddress dstVmIP, MacAddress dstVmGwMac, Objective.Operation operation) { classifierService .programL3InPortClassifierRules(h.location().deviceId(), h.location().port(), h.mac(), srcVmGwMac, l3vni, operation); classifierService .programArpClassifierRules(h.location().deviceId(), h.location().port(), srcGwIp, network.segmentationId(), operation); Iterable<Device> devices = deviceService.getAvailableDevices(); Sets.newHashSet(devices).stream() .filter(d -> Device.Type.SWITCH == d.type()).forEach(d -> { // L3FWD rules l3ForwardService.programRouteRules(d.id(), l3vni, dstVmIP, network.segmentationId(), dstVmGwMac, h.mac(), operation); }); }
Set<Host> hosts = hostService.getHostsByIp(routeEntry.nextHop()); if (!hosts.isEmpty()) { nextHopMacAddress = hosts.iterator().next().mac();
/** * Prints information about a host. * * @param host end-station host */ protected void printHost(Host host) { if (shortOnly) { print(FMT_SHORT, host.id(), host.mac(), host.locations(), host.vlan(), host.ipAddresses()); } else { print(FMT, host.id(), host.mac(), host.locations(), host.vlan(), host.ipAddresses(), annotations(host.annotations()), host.innerVlan(), host.tpid().toString(), host.providerId().scheme(), host.providerId().id(), host.configured()); } } }
MacAddress mac = host.mac(); Device device = deviceService.getDevice(deviceId); String controllerIp = VtnData.getControllerIpOfSwitch(device);
private void sendNorthSouthL3Flows(DeviceId deviceId, FloatingIp floatingIp, IpAddress dstVmGwIp, MacAddress dstVmGwMac, SegmentationId l3vni, TenantNetwork vmNetwork, VirtualPort vmPort, Host host, Objective.Operation operation) { l3ForwardService .programRouteRules(deviceId, l3vni, floatingIp.fixedIp(), vmNetwork.segmentationId(), dstVmGwMac, vmPort.macAddress(), operation); classifierService.programL3InPortClassifierRules(deviceId, host.location().port(), host.mac(), dstVmGwMac, l3vni, operation); classifierService.programArpClassifierRules(deviceId, host.location() .port(), dstVmGwIp, vmNetwork.segmentationId(), operation); }
if (allHosts != null) { Sets.newHashSet(allHosts).stream().forEach(host -> { MacAddress hostMac = host.mac(); String ifaceId = host.annotations().value(IFACEID); if (ifaceId == null) {