org.onosproject.net.Host Java Examples

The following examples show how to use org.onosproject.net.Host. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatsFlowRuleManager.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a set of flow infos by referring to underlay destination port.
 *
 * @return flow infos
 */
private Set<FlowInfo> getUnderlayDstPortBasedFlowInfos() {
    Set<FlowInfo> flowInfos = Sets.newConcurrentHashSet();

    for (Device d : getUnderlayDevices()) {
        List<PortStatistics> stats =
                new ArrayList<>(deviceService.getPortStatistics(d.id()));
        stats.forEach(s -> {
            Host host = hostService.getConnectedHosts(new ConnectPoint(d.id(), s.portNumber()))
                    .stream().findFirst().orElse(null);
            if (host != null) {
                flowInfos.add(buildTxFlowInfoFromHost(host, s));
                flowInfos.add(buildRxFlowInfoFromHost(host, s));
            }
        });
    }

    return flowInfos;
}
 
Example #2
Source File: VplsIntentTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a unicast intent.
 *
 * @param key the key to identify the intent
 * @param srcs the ingress connect points
 * @param dst the egress connect point
 * @param host the destination Host
 * @return the generated multi-point to single-point intent
 */
private MultiPointToSinglePointIntent buildUniIntent(Key key,
                                                     Set<FilteredConnectPoint> srcs,
                                                     FilteredConnectPoint dst,
                                                     Host host,
                                                     EncapsulationType encap) {
    MultiPointToSinglePointIntent.Builder intentBuilder;
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthDst(host.mac())
            .build();
    intentBuilder = MultiPointToSinglePointIntent.builder()
            .appId(APPID)
            .key(key)
            .selector(selector)
            .filteredIngressPoints(srcs)
            .filteredEgressPoint(dst)
            .constraints(VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT)
            .priority(PRIORITY_OFFSET);
    VplsIntentUtility.setEncap(intentBuilder,
                               VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT,
                               encap);

    return intentBuilder.build();
}
 
Example #3
Source File: TroubleshootManager.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Matches src and dst IPs based on host information.
 *
 * @param host            the host
 * @param failTrace       the trace to use in case of failure
 * @param selectorBuilder the packet we are building to trace
 * @param etherType       the traffic type
 * @param src             is this src host or dst host
 * @return true if properly matched
 */
private boolean matchIP(Host host, StaticPacketTrace failTrace, Builder selectorBuilder,
                        EtherType etherType, boolean src) {
    List<IpAddress> ips = getIpAddresses(host, etherType, true);

    if (ips.size() > 0) {
        if (etherType.equals(EtherType.IPV4)) {
            if (src) {
                selectorBuilder.matchIPSrc(ips.get(0).toIpPrefix());
            } else {
                selectorBuilder.matchIPDst(ips.get(0).toIpPrefix());
            }
        } else if (etherType.equals(EtherType.IPV6)) {
            if (src) {
                selectorBuilder.matchIPv6Src(ips.get(0).toIpPrefix());
            } else {
                selectorBuilder.matchIPv6Dst(ips.get(0).toIpPrefix());
            }
        }
    } else {
        failTrace.addResultMessage("Host " + host + " has no " + etherType + " address");
        failTrace.setSuccess(false);
        return false;
    }
    return true;
}
 
Example #4
Source File: Topo2Jsonifier.java    From onos with Apache License 2.0 6 votes vote down vote up
private ObjectNode json(String ridStr, UiHost host) {
    ObjectNode node = objectNode()
            .put("id", host.idAsString())
            .put("nodeType", HOST)
            .put("layer", host.layer());
    // TODO: complete host details
    Host h = host.backingHost();

    // h will be null, for example, after a HOST_REMOVED event
    if (h != null) {
        addIps(node, h);
        addProps(node, h);
        addGeoGridLocation(node, h);
        node.put("configured", h.configured());
    }
    addMetaUi(node, ridStr, host.idAsString());

    return node;
}
 
Example #5
Source File: VplsIntentTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Generates a list of expected mp2sp intents for a given VPLS.
 *
 * @param fcPoints the filtered connect point
 * @param hosts the hosts
 * @param name the name of the VPLS
 * @param encap the encapsulation type
 * @return the list of expected mp2sp intents for the given VPLS
 */
private List<MultiPointToSinglePointIntent>
generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts,
                String name, EncapsulationType encap) {
    List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();

    hosts.forEach(host -> {
        FilteredConnectPoint hostPoint = getHostPoint(host, fcPoints);

        Set<FilteredConnectPoint> otherPoints =
                fcPoints.stream()
                        .filter(fcp -> !fcp.equals(hostPoint))
                        .collect(Collectors.toSet());

        Key uniKey = buildKey(VplsIntentUtility.PREFIX_UNICAST,
                              host.location(), name, host.mac());

        intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
    });

    return intents;
}
 
Example #6
Source File: VtnManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private DeviceId getDeviceIdOfFloatingIP(FloatingIp floatingIp) {
    VirtualPortId vmPortId = floatingIp.portId();
    VirtualPort vmPort = virtualPortService.getPort(vmPortId);
    if (vmPort == null) {
        vmPort = VtnData.getPort(vPortStore, vmPortId);
    }
    Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
    Host host = null;
    for (Host h : hostSet) {
        String ifaceid = h.annotations().value(IFACEID);
        if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
            host = h;
            break;
        }
    }
    if (host == null) {
        log.debug("Host is null {}.", floatingIp);
        return null;
    } else {
        return host.location().deviceId();
    }
}
 
Example #7
Source File: HostHandlerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public void testDualHomedHostRemoved() {
    // Add a dual-homed host that has 2 locations
    // Expect: add two routing rules and two bridging rules
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED,
            Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11), false);
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(2, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertEquals(2, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV2, HOST_MAC, INTF_VLAN_UNTAGGED)));

    // Remove a dual-homed host that has 2 locations
    // Expect: all routing and bridging rules are removed
    hostHandler.processHostRemovedEvent(new HostEvent(HostEvent.Type.HOST_REMOVED, subject));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(0, BRIDGING_TABLE.size());
}
 
Example #8
Source File: VplsNeighbourHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Handles reply messages between VLAN tagged interfaces.
 *
 * @param context the message context
 * @param hostService the host service
 */
protected void handleReply(NeighbourMessageContext context,
                           HostService hostService) {
    // Find target VPLS, then reply to the host
    VplsData vplsData = findVpls(context);
    if (vplsData != null) {
        MacAddress dstMac = context.dstMac();
        Set<Host> hosts = hostService.getHostsByMac(dstMac);
        hosts = hosts.stream()
                .filter(host -> vplsData.interfaces().contains(getHostInterface(host)))
                .collect(Collectors.toSet());

        // reply to all host in same VPLS
        hosts.stream()
                .map(this::getHostInterface)
                .filter(Objects::nonNull)
                .forEach(context::forward);
    } else {
        // this might be happened when we remove an interface from VPLS
        // just ignore this message
        log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
        context.drop();
    }
}
 
Example #9
Source File: DemoInstaller.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    List<Constraint> constraint = Lists.newArrayList();
    List<Host> hosts = Lists.newArrayList(hostService.getHosts());
    while (!hosts.isEmpty()) {
        Host src = hosts.remove(0);
        for (Host dst : hosts) {
            HostToHostIntent intent = HostToHostIntent.builder()
                    .appId(appId)
                    .one(src.id())
                    .two(dst.id())
                    .selector(selector)
                    .treatment(treatment)
                    .constraints(constraint)
                    .build();
            existingIntents.add(intent);
            intentService.submit(intent);
        }
    }
}
 
Example #10
Source File: Ipv6RoutingComponent.java    From ngsdn-tutorial with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isRelevant(HostEvent event) {
    switch (event.type()) {
        case HOST_ADDED:
            break;
        case HOST_REMOVED:
        case HOST_UPDATED:
        case HOST_MOVED:
        default:
            // Ignore other events.
            // Food for thoughts:
            // how to support host moved/removed events?
            return false;
    }
    // Process host event only if this controller instance is the master
    // for the device where this host is attached.
    final Host host = event.subject();
    final DeviceId deviceId = host.location().deviceId();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example #11
Source File: TroubleshootPingAllCommand.java    From onos with Apache License 2.0 6 votes vote down vote up
private void printResultOnly(StaticPacketTrace trace, boolean ipv4) {
    if (trace.getEndpointHosts().isPresent()) {
        Host source = trace.getEndpointHosts().get().getLeft();
        Host destination = trace.getEndpointHosts().get().getRight();
        IpAddress srcIP;
        IpAddress dstIP;
        if (ipv4 && trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC) != null) {
            srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC)).ip().address();
            dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_DST)).ip().address();
            print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
        } else if (trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC) != null) {
            srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC)).ip().address();
            dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_DST)).ip().address();
            print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
        } else {
            print("Source %s --> Destination %s", source.id(), destination.id());
        }
        print("%s", trace.resultMessage());
    } else {
        print("Can't gather host information from trace");
        print("%s", trace.resultMessage());
    }
}
 
Example #12
Source File: Ipv6RoutingComponent.java    From onos-p4-tutorial with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isRelevant(HostEvent event) {
    switch (event.type()) {
        case HOST_ADDED:
            break;
        case HOST_REMOVED:
        case HOST_UPDATED:
        case HOST_MOVED:
        default:
            // Ignore other events.
            // Food for thoughts:
            // how to support host moved/removed events?
            return false;
    }
    // Process host event only if this controller instance is the master
    // for the device where this host is attached.
    final Host host = event.subject();
    final DeviceId deviceId = host.location().deviceId();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example #13
Source File: HostLocationProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
private void sendProbe(Host host, IpAddress targetIp) {
    Ethernet probePacket = null;
    if (targetIp.isIp4()) {
        // IPv4: Use ARP
        probePacket = buildArpRequest(targetIp, host);
    } else {
        // IPv6: Use Neighbor Discovery
        //TODO need to implement ndp probe
        log.info("Triggering probe on device {} ", host);
        return;
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(host.location().port()).build();

    OutboundPacket outboundPacket = new DefaultOutboundPacket(host.location().deviceId(), treatment,
            ByteBuffer.wrap(probePacket.serialize()));

    packetService.emit(outboundPacket);
}
 
Example #14
Source File: HostProbingManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void probeHost(Host host, ConnectPoint connectPoint, ProbeMode probeMode) {
    HostProbingProvider provider = getProvider(SCHEME);
    if (provider == null) {
        log.warn("Unable to find host probing provider. Cannot {} {} at {}",
                probeMode, host, connectPoint);
        return;
    }
    provider.probeHost(host, connectPoint, probeMode);
}
 
Example #15
Source File: HostEventTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void withTime() {
    Host host = createHost();
    HostEvent event = new HostEvent(HostEvent.Type.HOST_ADDED, host, 123L);
    validateEvent(event, HostEvent.Type.HOST_ADDED, host, 123L);
}
 
Example #16
Source File: AccessNetworkLayout.java    From onos with Apache License 2.0 5 votes vote down vote up
private void placeServiceLeavesAndHosts() {
    List<DeviceId> leaves = deviceCategories.get(LEAF);
    List<HostId> computes = hostCategories.get(COMPUTE);
    List<HostId> gateways = hostCategories.get(GATEWAY);
    Set<HostId> placed = Sets.newHashSet();

    serviceLeaf = 1;
    leaves.stream().sorted(Comparators.ELEMENT_ID_COMPARATOR).forEach(id -> {
        gateway = 1;
        place(id, c(serviceLeaf++, leaves.size(), serviceGap), serviceY);

        List<HostId> gwHosts = hostService.getConnectedHosts(id).stream()
                .map(Host::id)
                .filter(gateways::contains)
                .filter(hid -> !placed.contains(hid))
                .sorted(Comparators.ELEMENT_ID_COMPARATOR)
                .collect(Collectors.toList());

        gwHosts.forEach(hid -> {
            place(hid, serviceLeaf <= 2 ? -gatewayX : gatewayX,
                  c(gateway++, gwHosts.size(), gatewayGap, gatewayOffset));
            placed.add(hid);
        });

        List<HostId> hosts = hostService.getConnectedHosts(id).stream()
                .map(Host::id)
                .filter(computes::contains)
                .filter(hid -> !placed.contains(hid))
                .sorted(Comparators.ELEMENT_ID_COMPARATOR)
                .collect(Collectors.toList());

        placeHostBlock(hosts, serviceLeaf <= 2 ? -computeOffset : computeOffset,
                       computeY, computePerRow, computeRowGap,
                       serviceLeaf <= 2 ? -colGap : colGap);
        placed.addAll(hosts);
    });
}
 
Example #17
Source File: IpHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Forwards IP packets in the buffer to the destination IP address.
 * It is called when the controller finds the destination MAC address
 * via NDP replies.
 *
 * @param deviceId the target device
 * @param destIpAddress the destination ip address
 */
public void forwardPackets(DeviceId deviceId, Ip6Address destIpAddress) {
    if (ipPacketQueue.get(destIpAddress) == null) {
        return;
    }
    for (IP ipPacket : ipPacketQueue.get(destIpAddress)) {
        if (ipPacket.getVersion() == ((byte) 6)) {
            IPv6 ipv6Packet = (IPv6) ipPacket;
            Ip6Address destAddress = Ip6Address.valueOf(ipv6Packet.getDestinationAddress());
            if (config.inSameSubnet(deviceId, destAddress)) {
                ipv6Packet.setHopLimit((byte) (ipv6Packet.getHopLimit() - 1));
                for (Host dest : srManager.hostService.getHostsByIp(destIpAddress)) {
                    Ethernet eth = new Ethernet();
                    eth.setDestinationMACAddress(dest.mac());
                    try {
                        eth.setSourceMACAddress(config.getDeviceMac(deviceId));
                    } catch (DeviceConfigNotFoundException e) {
                        log.warn(e.getMessage()
                                         + " Skipping forwardPackets for this destination.");
                        continue;
                    }
                    eth.setEtherType(Ethernet.TYPE_IPV6);
                    eth.setPayload(ipv6Packet);
                    forwardToHost(deviceId, eth, dest);
                    ipPacketQueue.get(destIpAddress).remove(ipPacket);
                }
                ipPacketQueue.get(destIpAddress).remove(ipPacket);
            }
        }
        ipPacketQueue.get(destIpAddress).remove(ipPacket);
    }
}
 
Example #18
Source File: NetworkConfigHostProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void triggerProbe(Host host) {
    /*
     * Note: All hosts are configured in network config host provider.
     * Therefore no probe is required.
     */
}
 
Example #19
Source File: HostViewMessageHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void populateRow(TableModel.Row row, Host host) {
    row.cell(TYPE_IID, getTypeIconId(host))
            .cell(NAME, getHostName(host))
            .cell(ID, host.id())
            .cell(MAC, host.mac())
            .cell(VLAN, host.vlan())
            .cell(CONFIGURED, host.configured())
            .cell(IPS, host.ipAddresses())
            .cell(LOCATION, host.location());
    // Note: leave complete list of all LOCATIONS to the details panel
}
 
Example #20
Source File: SimpleFabricForwarding.java    From onos with Apache License 2.0 5 votes vote down vote up
protected FilteredConnectPoint buildFilteredConnectedPoint(Host host) {
    Objects.requireNonNull(host);
    TrafficSelector.Builder trafficSelector = DefaultTrafficSelector.builder();

    if (host.vlan() != null && !host.vlan().equals(VlanId.NONE)) {
        trafficSelector.matchVlanId(host.vlan());
    }
    return new FilteredConnectPoint(host.location(), trafficSelector.build());
}
 
Example #21
Source File: HostLocationProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Create or update host information.
 * Will not update IP if IP is null, all zero or self-assigned.
 *
 * @param hid       host ID
 * @param mac       source Mac address
 * @param vlan      VLAN ID
 * @param innerVlan inner VLAN ID
 * @param outerTpid outer TPID
 * @param hloc      host location
 * @param ip        source IP address or null if not updating
 */
private void createOrUpdateHost(HostId hid, MacAddress mac, VlanId vlan,
                                VlanId innerVlan, EthType outerTpid,
                                HostLocation hloc, IpAddress ip) {
    Set<HostLocation> newLocations = Sets.newHashSet(hloc);

    if (multihomingEnabled) {
        Host existingHost = hostService.getHost(hid);
        if (existingHost != null) {
            Set<HostLocation> prevLocations = existingHost.locations();

            if (prevLocations.stream().noneMatch(loc -> loc.deviceId().equals(hloc.deviceId()))) {
                // New location is on a device that we haven't seen before
                // Could be a dual-home host.
                newLocations.addAll(prevLocations);
            } else {
                // Move within the same switch
                // Simply replace old location that is on the same device
                prevLocations.stream().filter(loc -> !loc.deviceId().equals(hloc.deviceId()))
                        .forEach(newLocations::add);
            }
        }
    }

    HostDescription desc = ip == null || ip.isZero() || ip.isSelfAssigned() ?
            new DefaultHostDescription(mac, vlan, newLocations, Sets.newHashSet(),
                                       innerVlan, outerTpid, false) :
            new DefaultHostDescription(mac, vlan, newLocations, Sets.newHashSet(ip),
                                       innerVlan, outerTpid, false);
    try {
        providerService.hostDetected(hid, desc, false);
    } catch (IllegalStateException e) {
        log.debug("Host {} suppressed", hid);
    }
}
 
Example #22
Source File: AbstractTopoModelTest.java    From onos with Apache License 2.0 5 votes vote down vote up
MockHostService() {
    for (Device d : ALL_DEVS) {
        for (Host h : createHostPair(d)) {
            hosts.put(h.id(), h);
        }
    }
}
 
Example #23
Source File: HostHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Send a probe on all locations with the same VLAN on pair device, excluding pair port.
 *
 * @param host host to probe
 * @param location newly discovered host location
 * @param pairDeviceId pair device id
 * @param pairRemotePort pair remote port
 */
// TODO Current implementation does not handle dual-homed hosts with auxiliary locations.
private void probe(Host host, ConnectPoint location, DeviceId pairDeviceId, PortNumber pairRemotePort) {
    //Check if the host still exists in the host store
    if (hostService.getHost(host.id()) == null) {
        log.debug("Host entry for host {} no more present. Aborting hostprobe discover for this host", host.id());
        return;
    }

    VlanId vlanToProbe = host.vlan().equals(VlanId.NONE) ?
            srManager.getInternalVlanId(location) : host.vlan();
    if (srManager.symmetricProbing) {
        srManager.interfaceService.getInterfaces().stream()
                .filter(i -> i.vlanTagged().contains(vlanToProbe) ||
                        i.vlanUntagged().equals(vlanToProbe) ||
                        i.vlanNative().equals(vlanToProbe))
                .filter(i -> i.connectPoint().deviceId().equals(pairDeviceId))
                .filter(i -> i.connectPoint().port().equals(location.port()))
                .forEach(i -> {
                    log.debug("Probing host {} on pair device {}", host.id(), i.connectPoint());
                    srManager.probingService.probeHost(host, i.connectPoint(), ProbeMode.DISCOVER);
                });
    } else {
        srManager.interfaceService.getInterfaces().stream()
                .filter(i -> i.vlanTagged().contains(vlanToProbe) ||
                        i.vlanUntagged().equals(vlanToProbe) ||
                        i.vlanNative().equals(vlanToProbe))
                .filter(i -> i.connectPoint().deviceId().equals(pairDeviceId))
                .filter(i -> !i.connectPoint().port().equals(pairRemotePort))
                .forEach(i -> {
                    log.debug("Probing host {} on pair device {}", host.id(), i.connectPoint());
                    srManager.probingService.probeHost(host, i.connectPoint(), ProbeMode.DISCOVER);
                });
    }
}
 
Example #24
Source File: HostHandlerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Test
public void testEffectiveLocations() {
    Host regularHost = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_TAGGED,
            Sets.newHashSet(HOST_LOC11, HOST_LOC12), Sets.newHashSet(HOST_IP11), false);
    Host auxHost = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_TAGGED,
            Sets.newHashSet(HOST_LOC11, HOST_LOC12), Sets.newHashSet(HOST_LOC21, HOST_LOC22),
            Sets.newHashSet(HOST_IP11), VlanId.NONE, EthType.EtherType.UNKNOWN.ethType(), false, false);

    assertEquals(Sets.newHashSet(HOST_LOC11, HOST_LOC12), hostHandler.effectiveLocations(regularHost));
    assertEquals(Sets.newHashSet(HOST_LOC21, HOST_LOC22), hostHandler.effectiveLocations(auxHost));
}
 
Example #25
Source File: SimpleFabricManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Interface hostInterface(Host host) {
    return interfaceService.getInterfaces().stream()
            .filter(iface -> iface.connectPoint().equals(host.location()) &&
                             iface.vlan().equals(host.vlan()))
            .findFirst()
            .orElse(null);
}
 
Example #26
Source File: SimpleHostStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Host> getConnectedHosts(DeviceId deviceId) {
    Set<Host> hostset = new HashSet<>();
    for (ConnectPoint p : locations.keySet()) {
        if (p.deviceId().equals(deviceId)) {
            hostset.addAll(locations.get(p));
        }
    }
    return hostset;
}
 
Example #27
Source File: SimpleFabricManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private Interface findAvailableDeviceHostInterface(Host host) {
    return interfaceService.getInterfaces().stream()
            .filter(iface -> iface.connectPoint().equals(host.location()) &&
                             iface.vlan().equals(host.vlan()))
            .filter(iface -> deviceService.isAvailable(iface.connectPoint().deviceId()))
            .findFirst()
            .orElse(null);
}
 
Example #28
Source File: HostsListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * 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.auxLocations(),
              host.vlan(), host.ipAddresses(), annotations(host.annotations()),
              host.innerVlan(), host.tpid().toString(),
              host.providerId().scheme(), host.providerId().id(),
              host.configured());
    }
}
 
Example #29
Source File: Topo2Jsonifier.java    From onos with Apache License 2.0 5 votes vote down vote up
private void addIps(ObjectNode node, Host h) {
    Set<IpAddress> ips = h.ipAddresses();

    ArrayNode a = arrayNode();
    for (IpAddress ip : ips) {
        a.add(ip.toString());
    }

    node.set("ips", a);
}
 
Example #30
Source File: TopologyViewMessageHandlerBase.java    From onos with Apache License 2.0 5 votes vote down vote up
protected PropertyPanel hostDetails(HostId hostId) {
    log.debug("generate prop panel data for host {}", hostId);
    Host host = services.host().getHost(hostId);
    Annotations annot = host.annotations();
    String glyphId = glyphForHost(annot);
    LionBundle lion = getLionBundle(LION_TOPO);

    PropertyPanel pp = new PropertyPanel(nameForHost(host), glyphId)
            .navPath(HOST_NAV_PATH)
            .id(hostId.toString());
    addHostBasicProps(pp, host, lion);
    addLocationProps(pp, annot, lion);
    return pp;
}