Search in sources :

Example 56 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method testGetInterfacesByVlan.

@Test
public void testGetInterfacesByVlan() throws Exception {
    VlanId vlanId = VlanId.vlanId((short) 1);
    Set<Interface> byVlan = Collections.singleton(createInterface(1));
    assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
Also used : VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 57 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method setUp.

@Before
public void setUp() throws Exception {
    for (int i = 0; i < NUM_INTERFACES; i++) {
        ConnectPoint cp = createConnectPoint(i);
        subjects.add(cp);
        Interface intf = createInterface(i);
        interfaces.add(intf);
        InterfaceConfig ic = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
        configs.put(cp, ic);
    }
    TestNetworkConfigService configService = new TestNetworkConfigService(subjects, configs);
    interfaceManager = new InterfaceManager();
    interfaceManager.configService = configService;
    interfaceManager.activate();
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) Before(org.junit.Before)

Example 58 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceCodec method decode.

@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;
}
Also used : MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Example 59 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsIntentTest method tenInterfacesConfiguredHostsPresent.

/**
 * Ten ports are configured with VLANs and ten hosts are registered by the
 * HostService.
 *
 * The first three ports have an interface configured on VPLS 1,
 * the other three on VPLS 2, two on VPLS3 and two on VPLS4.
 *
 * The number of intents expected is twenty: six
 * for VPLS 1, six for VPLS 2. four for VPLS 3, four for VPLS 4.
 * That is ten sp2mp intents, ten mp2sp intents. For VPLS 1
 * IPs are added to demonstrate this doesn't influence the number of intents
 * created. Checks if the number of intents submitted to the intent
 * framework is equal to the number of intents expected and if all intents
 * are equivalent.
 */
@Test
public void tenInterfacesConfiguredHostsPresent() {
    hostsAvailable.addAll(AVAILABLE_HOSTS);
    List<Intent> expectedIntents = Lists.newArrayList();
    Set<FilteredConnectPoint> fcPoints;
    Set<Host> hosts;
    Set<Interface> interfaces;
    VplsData vplsData;
    Set<Intent> brcIntents;
    Set<Intent> uniIntents;
    interfaces = ImmutableSet.of(V100H1, V200H1, V300H1);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V100HOST1, V200HOST1, V300HOST1);
    vplsData = createVplsData(VPLS1, VLAN, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS1, VLAN));
    interfaces = ImmutableSet.of(V100H2, V200H2, V300H2);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V100HOST2, V200HOST2, V300HOST2);
    vplsData = createVplsData(VPLS2, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS2, NONE));
    interfaces = ImmutableSet.of(VNONEH1, VNONEH2);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(VNONEHOST1, VNONEHOST2);
    vplsData = createVplsData(VPLS3, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS3, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS3, NONE));
    interfaces = ImmutableSet.of(V400H1, VNONEH3);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V400HOST1, VNONEHOST3);
    vplsData = createVplsData(VPLS4, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS4, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS4, NONE));
    checkIntents(expectedIntents);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 60 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsIntentTest method activateNoHosts.

/**
 * Seven ports are configured with VLANs, while three ports are not. No hosts are
 * registered by the HostService.
 *
 * The first three ports have an interface configured on VPLS 1,
 * the other three on VPLS 2. Two ports are defined for VPLS 3, while
 * the two remaining ports are configured on VPLS 4.
 *
 * The number of intents expected is 10: three for VPLS 1, three for VPLS 2,
 * two for VPLS 3, two for VPLS 4. Eight MP2SP intents.
 * Checks if the number of intents submitted to the intent framework is
 * equal to the number of intents expected and if all intents are equivalent.
 */
@Test
public void activateNoHosts() {
    List<Intent> expectedIntents = Lists.newArrayList();
    Set<FilteredConnectPoint> fcPoints;
    Set<Interface> interfaces;
    interfaces = ImmutableSet.of(V100H1, V200H1, V300H1);
    VplsData vplsData = createVplsData(VPLS1, VLAN, interfaces);
    Set<Intent> brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    brcIntents.forEach(intentService::submit);
    fcPoints = buildFCPoints(interfaces);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
    checkIntents(expectedIntents);
    interfaces = ImmutableSet.of(V100H2, V200H2, V300H2);
    vplsData = createVplsData(VPLS2, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    brcIntents.forEach(intentService::submit);
    fcPoints = buildFCPoints(interfaces);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
    checkIntents(expectedIntents);
    interfaces = ImmutableSet.of(VNONEH1, VNONEH2);
    vplsData = createVplsData(VPLS3, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    brcIntents.forEach(intentService::submit);
    fcPoints = buildFCPoints(interfaces);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS3, NONE));
    checkIntents(expectedIntents);
    interfaces = ImmutableSet.of(V400H1, VNONEH3);
    vplsData = createVplsData(VPLS4, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    brcIntents.forEach(intentService::submit);
    fcPoints = buildFCPoints(interfaces);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS4, NONE));
    checkIntents(expectedIntents);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) Interface(org.onosproject.net.intf.Interface) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Aggregations

Interface (org.onosproject.net.intf.Interface)92 ConnectPoint (org.onosproject.net.ConnectPoint)51 MacAddress (org.onlab.packet.MacAddress)35 VlanId (org.onlab.packet.VlanId)34 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)32 Ethernet (org.onlab.packet.Ethernet)28 IpAddress (org.onlab.packet.IpAddress)28 ArrayList (java.util.ArrayList)26 DeviceId (org.onosproject.net.DeviceId)26 Host (org.onosproject.net.Host)25 InterfaceService (org.onosproject.net.intf.InterfaceService)25 Logger (org.slf4j.Logger)25 Set (java.util.Set)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)23 LoggerFactory (org.slf4j.LoggerFactory)23 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)22 Test (org.junit.Test)21 ApplicationId (org.onosproject.core.ApplicationId)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)20