org.onosproject.net.intf.Interface Java Examples

The following examples show how to use org.onosproject.net.intf.Interface. 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: DeviceConfiguration.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the router ipv6 address of segment router that has the
 * specified ip address in its subnets.
 *
 * @param destIpAddress target ip address
 * @return router ip address
 */
public Ip6Address getRouterIpAddressForASubnetHost(Ip6Address destIpAddress) {
    Interface matchIntf = srManager.interfaceService.getMatchingInterface(destIpAddress);

    if (matchIntf == null) {
        log.debug("No router was found for {}", destIpAddress);
        return null;
    }

    DeviceId routerDeviceId = matchIntf.connectPoint().deviceId();
    SegmentRouterInfo srInfo = deviceConfigMap.get(routerDeviceId);
    if (srInfo == null) {
        log.debug("No device config was found for {}", routerDeviceId);
        return null;
    }

    return srInfo.ipv6Loopback;
}
 
Example #2
Source File: InterfaceManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isConfigured(ConnectPoint connectPoint) {
    Set<Interface> intfs = interfaces.get(connectPoint);
    if (intfs == null) {
        return false;
    }
    for (Interface intf : intfs) {
        if (!intf.ipAddressesList().isEmpty() || intf.vlan() != VlanId.NONE
                || intf.vlanNative() != VlanId.NONE
                || intf.vlanUntagged() != VlanId.NONE
                || !intf.vlanTagged().isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #3
Source File: MockInterfaceService.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isConfigured(ConnectPoint connectPoint) {
    Set<Interface> intfs = getInterfacesByPort(connectPoint);
    if (intfs == null) {
        return false;
    }
    for (Interface intf : intfs) {
        if (!intf.ipAddressesList().isEmpty() || intf.vlan() != VlanId.NONE
                || intf.vlanNative() != VlanId.NONE
                || intf.vlanUntagged() != VlanId.NONE
                || !intf.vlanTagged().isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #4
Source File: VplsNeighbourHandlerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Sends reply messages to hosts in VPLS 4.
 * Reply messages should be received by the host with MAC address equal to
 * the dstMac of the message context.
 */
@Test
public void vpls4ReplyMessage() {
    // Reply messages from v400h1 (VPLS 4) should be received by vNoneh3
    TestMessageContext replyMessage =
            makeReplyContext(V400HOST1, VNONEHOST3);
    Set<Interface> expectInterfaces = ImmutableSet.of(VNONEH3);
    ((TestNeighbourService) vplsNeighbourHandler.neighbourService).sendNeighourMessage(replyMessage);
    assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);

    // Reply messages from vNoneh3 (VPLS 4) should be received by v400h1
    replyMessage = makeReplyContext(VNONEHOST3, V400HOST1);
    expectInterfaces = ImmutableSet.of(V400H1);
    ((TestNeighbourService) vplsNeighbourHandler.neighbourService).sendNeighourMessage(replyMessage);
    assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
}
 
Example #5
Source File: DistributedVplsStore.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Writes all VPLS data to the network configuration store.
 *
 * @param vplsDataCollection the VPLSs data
 */
public void writeVplsToNetConfig(Collection<VplsData> vplsDataCollection) {
    VplsAppConfig config = networkConfigService.addConfig(appId, VplsAppConfig.class);
    if (config == null) {
        log.debug("VPLS config is not available now");
        return;
    }
    config.clearVplsConfig();

    // Setup update time for this VPLS application configuration
    WallClockTimestamp ts = new WallClockTimestamp();
    config.updateTime(ts.unixTimestamp());

    vplsDataCollection.forEach(vplsData -> {
        Set<String> interfaceNames = vplsData.interfaces()
                .stream()
                .map(Interface::name)
                .collect(Collectors.toSet());
        VplsConfig vplsConfig = new VplsConfig(vplsData.name(), interfaceNames,
                                               vplsData.encapsulationType());
        config.addVpls(vplsConfig);
    });

    networkConfigService.applyConfig(appId, VplsAppConfig.class, config.node());
}
 
Example #6
Source File: SdnIpFib.java    From onos with Apache License 2.0 6 votes vote down vote up
private TrafficSelector.Builder buildIngressTrafficSelector(Interface intf, IpPrefix prefix) {
    TrafficSelector.Builder selector = buildTrafficSelector(intf);

    // Match the destination IP prefix at the first hop
    if (prefix.isIp4()) {
        selector.matchEthType(Ethernet.TYPE_IPV4);
        // if it is default route, then we do not need match destination
        // IP address
        if (prefix.prefixLength() != 0) {
            selector.matchIPDst(prefix);
        }
    } else {
        selector.matchEthType(Ethernet.TYPE_IPV6);
        // if it is default route, then we do not need match destination
        // IP address
        if (prefix.prefixLength() != 0) {
            selector.matchIPv6Dst(prefix);
        }
    }
    return selector;
}
 
Example #7
Source File: FibInstaller.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Installs or removes unicast filtering objectives relating to an interface.
 *
 * @param routerIntf interface to update objectives for
 * @param install true to install the objectives, false to remove them
 */
private void updateFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
    Interface intf = routerIntf.intf();
    VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
            VlanId.vlanId(ASSIGNED_VLAN) :
            egressVlan();

    FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
    // first add filter for the interface
    fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
        .addCondition(Criteria.matchEthDst(intf.mac()))
        .addCondition(Criteria.matchVlanId(intf.vlan()));
    fob.withPriority(PRIORITY_OFFSET);
    if (intf.vlan() == VlanId.NONE) {
        TrafficTreatment tt = DefaultTrafficTreatment.builder()
                .pushVlan().setVlanId(assignedVlan).build();
        fob.withMeta(tt);
    }
    fob.permit().fromApp(fibAppId);
    sendFilteringObjective(install, fob, intf);

    // then add the same mac/vlan filters for control-plane connect point
    fob.withKey(Criteria.matchInPort(routerIntf.controlPlaneConnectPoint().port()));
    sendFilteringObjective(install, fob, intf);
}
 
Example #8
Source File: VplsNeighbourHandlerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Sends reply messages to hosts in VPLS 2.
 * Reply messages should be received by the host with MAC address equal to
 * the dstMac of the message context.
 */
@Test
public void vpls2ReplyMessage() {
    // Reply messages from v100h2 (VPLS 2) should be received by v200h2
    TestMessageContext replyMessage =
            makeReplyContext(V100HOST2, V200HOST2);
    Set<Interface> expectInterfaces = ImmutableSet.of(V200H2);
    ((TestNeighbourService) vplsNeighbourHandler.neighbourService).sendNeighourMessage(replyMessage);
    assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);

    // Reply messages from v200h2 (VPLS 2) should be received by v100h2
    replyMessage = makeReplyContext(V200HOST2, V100HOST2);
    expectInterfaces = ImmutableSet.of(V100H2);
    ((TestNeighbourService) vplsNeighbourHandler.neighbourService).sendNeighourMessage(replyMessage);
    assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
}
 
Example #9
Source File: PimInterfaceManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private void updateInterface(PimInterfaceConfig config) {
    ConnectPoint cp = config.subject();

    if (!config.isEnabled()) {
        removeInterface(cp);
        return;
    }

    String intfName = config.getInterfaceName();
    Interface intf = interfaceService.getInterfaceByName(cp, intfName);

    if (intf == null) {
        log.debug("Interface configuration missing: {}", config.getInterfaceName());
        return;
    }


    log.debug("Updating Interface for " + intf.connectPoint().toString());
    pimInterfaces.computeIfAbsent(cp, k -> buildPimInterface(config, intf));
}
 
Example #10
Source File: VplsIntentTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the interface configuration:
 *  On devices 1 and 2 is configured an interface on port 1 with vlan 100.
 *  On device 3 is configured an interface on port 3 with no vlan.
 *  On devices 3 and 4 is configured an interface on port 1 with vlan 200.
 *  On device 4 is an interface configured on port 2 with vlan 400.
 *  On device 5 are configured two interfaces on port 1 and 2 with no vlan.
 *  On device 5 and 6 is configured an interface on port 1 with vlan 300.
 */
private void addIfaceConfig() {
    Set<Interface> interfaces = ImmutableSet.copyOf(AVAILABLE_INTERFACES);
    Set<Interface> vlanOneSet = ImmutableSet.of(V100H1, V100H2);
    Set<Interface> vlanTwoSet = ImmutableSet.of(V200H1, V200H2);
    Set<Interface> vlanThreeSet = ImmutableSet.of(VNONEH1, VNONEH2);
    Set<Interface> vlanFourSet = ImmutableSet.of(V400H1, VNONEH3);

    AVAILABLE_INTERFACES.forEach(intf -> {
        expect(interfaceService.getInterfacesByPort(intf.connectPoint()))
                .andReturn(Sets.newHashSet(intf)).anyTimes();
    });
    expect(interfaceService.getInterfacesByVlan(VLAN100))
            .andReturn(vlanOneSet).anyTimes();
    expect(interfaceService.getInterfacesByVlan(VLAN200))
            .andReturn(vlanTwoSet).anyTimes();
    expect(interfaceService.getInterfacesByVlan(VLAN300))
            .andReturn(vlanThreeSet).anyTimes();
    expect(interfaceService.getInterfacesByVlan(VLAN400))
            .andReturn(vlanFourSet).anyTimes();
    expect(interfaceService.getInterfacesByVlan(VlanId.NONE))
            .andReturn(vlanFourSet).anyTimes();
    expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();

    replay(interfaceService);
}
 
Example #11
Source File: L2BridgingComponent.java    From ngsdn-tutorial with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a set of ports for the given device that are used to connect
 * hosts to the fabric.
 *
 * @param deviceId device ID
 * @return set of host facing ports
 */
private Set<PortNumber> getHostFacingPorts(DeviceId deviceId) {
    // Get all interfaces configured via netcfg for the given device ID and
    // return the corresponding device port number. Interface configuration
    // in the netcfg.json looks like this:
    // "device:leaf1/3": {
    //   "interfaces": [
    //     {
    //       "name": "leaf1-3",
    //       "ips": ["2001:1:1::ff/64"]
    //     }
    //   ]
    // }
    return interfaceService.getInterfaces().stream()
            .map(Interface::connectPoint)
            .filter(cp -> cp.deviceId().equals(deviceId))
            .map(ConnectPoint::port)
            .collect(Collectors.toSet());
}
 
Example #12
Source File: ControlPlaneRedirectManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests adding new Device to a openflow router.
 */
@Test
public void testAddDevice() {
    ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
    List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
    interfaceIpAddresses.add(
            new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24"))
    );
    interfaceIpAddresses.add(
            new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120"))
    );

    Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses,
            MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
    interfaces.add(sw1Eth4);
    EasyMock.reset(flowObjectiveService);
    setUpFlowObjectiveService();
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3));
    verify(flowObjectiveService);
}
 
Example #13
Source File: RoutingRulePopulator.java    From onos with Apache License 2.0 5 votes vote down vote up
private boolean processSinglePortFiltersInternal(DeviceId deviceId, PortNumber portnum,
                                                  boolean pushVlan, VlanId vlanId, boolean install) {
    boolean doTMAC = true;

    if (!pushVlan) {
        // Skip the tagged vlans belonging to an interface without an IP address
        Set<Interface> ifaces = srManager.interfaceService
                .getInterfacesByPort(new ConnectPoint(deviceId, portnum))
                .stream()
                .filter(intf -> intf.vlanTagged().contains(vlanId) && intf.ipAddressesList().isEmpty())
                .collect(Collectors.toSet());
        if (!ifaces.isEmpty()) {
            log.debug("processSinglePortFiltersInternal: skipping TMAC for vlan {} at {}/{} - no IP",
                      vlanId, deviceId, portnum);
            doTMAC = false;
        }
    }

    FilteringObjective.Builder fob = buildFilteringObjective(deviceId, portnum, pushVlan, vlanId, doTMAC);
    if (fob == null) {
        // error encountered during build
        return false;
    }
    log.debug("{} filtering objectives for dev/port: {}/{}",
             install ? "Installing" : "Removing", deviceId, portnum);
    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("Filter for {}/{} {}", deviceId, portnum,
                    install ? "installed" : "removed"),
            (objective, error) -> log.warn("Failed to {} filter for {}/{}: {}",
                    install ? "install" : "remove", deviceId, portnum, error));
    if (install) {
        srManager.flowObjectiveService.filter(deviceId, fob.add(context));
    } else {
        srManager.flowObjectiveService.filter(deviceId, fob.remove(context));
    }
    return true;
}
 
Example #14
Source File: InterfaceConfig.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an interface to the config.
 *
 * @param intf interface to add
 */
public void addInterface(Interface intf) {
    checkNotNull(intf, INTF_NULL_ERROR);
    checkArgument(!intf.name().equals(Interface.NO_INTERFACE_NAME), INTF_NAME_ERROR);

    // Remove old interface with this name if it exists
    removeInterface(intf.name());

    ObjectNode intfNode = array.addObject();

    intfNode.put(NAME, intf.name());

    if (intf.mac() != null) {
        intfNode.put(MAC, intf.mac().toString());
    }

    if (!intf.ipAddressesList().isEmpty()) {
        intfNode.set(IPS, putIps(intf.ipAddressesList()));
    }

    if (!intf.vlan().equals(VlanId.NONE)) {
        intfNode.put(VLAN, intf.vlan().toString());
    }

    if (!intf.vlanUntagged().equals(VlanId.NONE)) {
        intfNode.put(VLAN_UNTAGGED, intf.vlanUntagged().toString());
    }

    if (!intf.vlanTagged().isEmpty()) {
        intfNode.set(VLAN_TAGGED, putVlans(intf.vlanTagged()));
    }

    if (!intf.vlanNative().equals(VlanId.NONE)) {
        intfNode.put(VLAN_NATIVE, intf.vlanNative().toString());
    }
}
 
Example #15
Source File: InterfaceCodec.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Interface decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    String name = nullIsIllegal(json.findValue(NAME),
            NAME + MISSING_NAME_MESSAGE).asText();
    ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(nullIsIllegal(json.findValue(CONNECT_POINT),
            CONNECT_POINT + MISSING_CONNECT_POINT_MESSAGE).asText());
    List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
    if (json.findValue(IPS) != null) {
        json.findValue(IPS).forEach(ip -> {
            ipAddresses.add(InterfaceIpAddress.valueOf(ip.asText()));
        });
    }

    MacAddress macAddr =  json.findValue(MAC) == null ?
            null : MacAddress.valueOf(json.findValue(MAC).asText());
    VlanId vlanId =  json.findValue(VLAN) == null ?
            VlanId.NONE : VlanId.vlanId(Short.parseShort(json.findValue(VLAN).asText()));
    Interface inter = new Interface(
            name,
            connectPoint,
            ipAddresses,
            macAddr,
            vlanId);

    return inter;
}
 
Example #16
Source File: Dhcp6HandlerUtil.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Determind if an Interface contains a vlan id.
 *
 * @param iface the Interface
 * @param vlanId the vlan id
 * @return true if the Interface contains the vlan id
 */
public static boolean interfaceContainsVlan(Interface iface, VlanId vlanId) {
    if (vlanId.equals(VlanId.NONE)) {
        // untagged packet, check if vlan untagged or vlan native is not NONE
        return !iface.vlanUntagged().equals(VlanId.NONE) ||
                !iface.vlanNative().equals(VlanId.NONE);
    }
    // tagged packet, check if the interface contains the vlan
    return iface.vlanTagged().contains(vlanId);
}
 
Example #17
Source File: Dhcp6HandlerUtil.java    From onos with Apache License 2.0 5 votes vote down vote up
private static boolean isConnectMacEmpty(DhcpServerInfo serverInfo, Set<Interface> clientInterfaces) {
    if (!serverInfo.getDhcpConnectMac().isPresent()) {
        log.warn("DHCP6 {} not yet resolved .. Aborting DHCP "
                        + "packet processing from client on port: {}",
                !serverInfo.getDhcpGatewayIp6().isPresent() ? "server IP " + serverInfo.getDhcpServerIp6()
                        : "gateway IP " + serverInfo.getDhcpGatewayIp6(),
                clientInterfaces.iterator().next().connectPoint());
        return true;
    }
    return false;
}
 
Example #18
Source File: SdnIpReactiveRouting.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Classifies the traffic and return the traffic type.
 *
 * @param srcConnectPoint the connect point where the packet comes from
 * @param dstIp the destination IP address in packet
 * @return the traffic type which this packet belongs to
 */
private TrafficType trafficTypeClassifier(ConnectPoint srcConnectPoint,
                                          IpAddress dstIp) {
    LocationType dstIpLocationType = getLocationType(dstIp);
    Optional<Interface> srcInterface =
            interfaceService.getInterfacesByPort(srcConnectPoint).stream().findFirst();

    Set<ConnectPoint> bgpPeerConnectPoints = config.getBgpPeerConnectPoints();



    switch (dstIpLocationType) {
    case INTERNET:
        if (srcInterface.isPresent() &&
                (!bgpPeerConnectPoints.contains(srcConnectPoint))) {
            return TrafficType.HOST_TO_INTERNET;
        } else {
            return TrafficType.INTERNET_TO_INTERNET;
        }
    case LOCAL:
        if (srcInterface.isPresent() &&
                (!bgpPeerConnectPoints.contains(srcConnectPoint))) {
            return TrafficType.HOST_TO_HOST;
        } else {
            // TODO Currently we only consider local public prefixes.
            // In the future, we will consider the local private prefixes.
            // If dstIpLocationType is a local private, we should return
            // TrafficType.DROP.
            return TrafficType.INTERNET_TO_HOST;
        }
    case NO_ROUTE:
        return TrafficType.DROP;
    default:
        return TrafficType.UNKNOWN;
    }
}
 
Example #19
Source File: SdnIpReactiveRouting.java    From onos with Apache License 2.0 5 votes vote down vote up
public ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress) {
    LocationType type = getLocationType(dstIpAddress);
    if (type == LocationType.LOCAL) {
        Set<Host> hosts = hostService.getHostsByIp(dstIpAddress);
        if (!hosts.isEmpty()) {
            return hosts.iterator().next().location();
        } else {
            hostService.startMonitoringIp(dstIpAddress);
            return null;
        }
    } else if (type == LocationType.INTERNET) {
        IpAddress nextHopIpAddress = null;
        Route route = routeService.longestPrefixMatch(dstIpAddress);
        if (route != null) {
            nextHopIpAddress = route.nextHop();
            Interface it = interfaceService.getMatchingInterface(nextHopIpAddress);
            if (it != null) {
                return it.connectPoint();
            } else {
                return null;
            }
        } else {
            return null;
        }
    } else {
        return null;
    }
}
 
Example #20
Source File: VplsManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void addInterfaces(VplsData vplsData, Collection<Interface> interfaces) {
    requireNonNull(vplsData);
    requireNonNull(interfaces);
    VplsData newData = VplsData.of(vplsData);
    newData.addInterfaces(interfaces);
    updateVplsStatus(newData, VplsData.VplsState.UPDATING);
}
 
Example #21
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 #22
Source File: Dhcp6HandlerUtil.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the first interface ip from interface.
 *
 * @param iface interface of one connect point
 * @return the first interface IP; null if not exists an IP address in
 *         these interfaces
 */
private static Ip6Address getFirstIpFromInterface(Interface iface) {
    checkNotNull(iface, "Interface can't be null");
    return iface.ipAddressesList().stream()
            .map(InterfaceIpAddress::ipAddress)
            .filter(IpAddress::isIp6)
            .map(IpAddress::getIp6Address)
            .findFirst()
            .orElse(null);
}
 
Example #23
Source File: SdnIpFibTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests removing an existing interface.
 *
 * We first push an intent with destination sw3 and source sw1 and sw2. We
 * then remove the ingress interface on sw1.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testRemoveIngressInterface() {
    // Add a route first
    testRouteAddToNoVlan();

    // Create the new expected intent
    MultiPointToSinglePointIntent remainingIntent =
            createIntentToThreeSrcTwo(PREFIX1);

    reset(intentSynchronizer);

    intentSynchronizer.submit(eqExceptId(remainingIntent));
    expectLastCall().once();

    replay(intentSynchronizer);

    // Define the existing ingress interface and remove it
    Interface intf = new Interface("sw1-eth1", SW1_ETH1,
                                   Collections.singletonList(IIP1),
                                   MAC1, VLAN10);
    InterfaceEvent intfEvent =
            new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
    interfaceListener.event(intfEvent);

    verify(intentSynchronizer);
}
 
Example #24
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 #25
Source File: SimpleFabricManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private Interface getInterfaceByName(String interfaceName) {
    Interface intf = interfaceService.getInterfaces().stream()
                      .filter(iface -> iface.name().equals(interfaceName))
                      .findFirst()
                      .orElse(null);
    if (intf == null) {
        log.warn("simple fabric unknown interface name: {}", interfaceName);
    }
    return intf;
}
 
Example #26
Source File: InterfaceManager.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns native VLAN configured on given connect point.
 * <p>
 * Only returns the first match if there are multiple native VLAN configured
 * on the connect point.
 *
 * @param connectPoint connect point
 * @return native VLAN or null if not configured
 */
@Override
public VlanId getNativeVlanId(ConnectPoint connectPoint) {
    Set<Interface> interfaces = getInterfacesByPort(connectPoint);
    return interfaces.stream()
            .filter(intf -> !intf.vlanNative().equals(VlanId.NONE))
            .map(Interface::vlanNative)
            .findFirst()
            .orElse(null);
}
 
Example #27
Source File: VplsManager.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the network interface of the host.
 *
 * @param host the host
 * @return the network interface of the host; null if no network
 * interface found
 */
private Interface getHostInterface(Host host) {
    Set<Interface> interfaces = interfaceService.getInterfaces();
    return interfaces.stream()
            .filter(iface -> iface.connectPoint().equals(host.location()) &&
                    iface.vlan().equals(host.vlan()))
            .findFirst()
            .orElse(null);
}
 
Example #28
Source File: VplsManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<Interface> removeInterfaces(VplsData vplsData, Collection<Interface> interfaces) {
    requireNonNull(vplsData);
    requireNonNull(interfaces);
    VplsData newData = VplsData.of(vplsData);
    newData.removeInterfaces(interfaces);
    updateVplsStatus(newData, VplsData.VplsState.UPDATING);
    return interfaces;
}
 
Example #29
Source File: ControlPlaneRedirectManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Interface getMatchingInterface(IpAddress ip) {
    Interface intff = null;
    for (Interface intf : interfaces) {
        for (InterfaceIpAddress address : intf.ipAddressesList()) {
            if (address.ipAddress().equals(ip)) {
                intff = intf;
                break;
            }
        }
    }

    return intff;
}
 
Example #30
Source File: ControlPlaneRedirectManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Setup flow Configuration for all configured Interfaces.
 *
 **/
private void setUpFlowObjectiveService() {
    expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
    for (Interface intf : interfaceService.getInterfaces()) {
        setUpInterfaceConfiguration(intf, true);
    }
    replay(flowObjectiveService);
}