/** * 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()); } } }
@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; }
/** * 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()); } }
protected boolean isValidHost(Host host) { return !host.ipAddresses().isEmpty() && host.annotations().value(VXLAN_ID) != null && host.annotations().value(NETWORK_ID) != null && host.annotations().value(TENANT_ID) != null && host.annotations().value(PORT_ID) != null; }
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 applyHostMonitoredL2Rules(Host host, Objective.Operation type) { DeviceId deviceId = host.location().deviceId(); if (!mastershipService.isLocalMaster(deviceId)) { return; String ifaceId = host.annotations().value(IFACEID); if (ifaceId == null) { log.error("The ifaceId of Host is null"); hosts.put(host.id(), host); hostsOfSubnet.put(subnetId, hosts); } else if (type == Objective.Operation.REMOVE) { hosts.remove(host.id()); if (hosts.size() != 0) { hostsOfSubnet.put(subnetId, hosts); PortNumber inPort = host.location().port(); MacAddress mac = host.mac(); Device device = deviceService.getDevice(deviceId); String controllerIp = VtnData.getControllerIpOfSwitch(device);
@Override public HostEvent removeHost(HostId hostId) { synchronized (this) { Host host = hosts.remove(hostId); if (host != null) { locations.remove((host.location()), host); return new HostEvent(HOST_REMOVED, host); } return null; } }
if (allHosts != null) { Sets.newHashSet(allHosts).stream().forEach(host -> { MacAddress hostMac = host.mac(); String ifaceId = host.annotations().value(IFACEID); if (ifaceId == null) { log.error("The ifaceId of Host is null"); .getNetwork(virtualPort.networkId()); SegmentationId segmentationId = network.segmentationId(); DeviceId remoteDeviceId = host.location().deviceId(); Device remoteDevice = deviceService.getDevice(remoteDeviceId); String remoteControllerIp = VtnData
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); }); }
protected String getVni(Host host) { return host.annotations().value(VXLAN_ID); }
@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; } } }
@Override public Set<Host> getHosts(IpAddress ip) { Set<Host> ipset = new HashSet<>(); for (Host h : hosts.values()) { if (h.ipAddresses().contains(ip)) { ipset.add(h); } } return ipset; }
@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; }
public void removeDuplicates(HostId hostId, HostDescription desc) { desc.ipAddress().forEach(ip -> { Set<Host> allHosts = store.getHosts(ip); allHosts.forEach(eachHost -> { if (!(eachHost.id().equals(hostId))) { log.info("Duplicate ip {} found on host {} and {}", ip, hostId.toString(), eachHost.id().toString()); store.removeIp(eachHost.id(), ip); } }); }); }
Host host = store.getHost(hostId); if (host != null && host.configured()) { return; if ((host == null || !host.ipAddresses().contains(targetIp6Address))) {
desc = BasicHostOperator.combine(cfg, desc); if (desc != null) { he = store.createOrUpdateHost(host.providerId(), hostId, desc, false); HostProvider hp = (host == null) ? null : getProvider(host.providerId()); HostDescription desc = (host == null) ? null : BasicHostOperator.descriptionOf(host); Optional<Config> prevConfig = event.prevConfig(); he = store.createOrUpdateHost(hp.id(), hostId, desc, false); if (he != null && he.subject() != null) { log.debug("Host annotations update - Host Event : {}", he.subject().annotations());
@Override public Set<Host> getHosts(VlanId vlanId) { Set<Host> vlanset = new HashSet<>(); for (Host h : hosts.values()) { if (h.vlan().equals(vlanId)) { vlanset.add(h); } } return vlanset; }
/** * Providers should only be able to remove a host that is provided by itself, * or a host that is not configured. */ private boolean allowedToChange(HostId hostId) { Host host = store.getHost(hostId); return host == null || !host.configured() || host.providerId().equals(provider().id()); } }
private void peerRemoved(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("Removing peer {}/{} on {} but the interface is not configured", peer.mac(), peer.vlan(), peer.location()); return; flowObjectiveService.forward(peer.location().deviceId(), createPeerObjBuilder(toRouterL3Unicast, routerIp.ipAddress().toIpPrefix()).remove()); }); peer.ipAddresses().forEach(peerIp -> { flowObjectiveService.forward(peer.location().deviceId(), createPeerObjBuilder(toPeerL3Unicast, peerIp.toIpPrefix()).remove()); });