Search in sources :

Example 51 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class DefaultVirtualLinkTest method testBuilderNullNetworkId.

/**
 * Tests the DefaultVirtualLink Builder to ensure that the networkId cannot be null.
 */
@Test(expected = NullPointerException.class)
public void testBuilderNullNetworkId() {
    DefaultVirtualDevice device1 = new DefaultVirtualDevice(NetworkId.networkId(0), DID1);
    DefaultVirtualDevice device2 = new DefaultVirtualDevice(NetworkId.networkId(0), DID2);
    ConnectPoint src = new ConnectPoint(device1.id(), PortNumber.portNumber(1));
    ConnectPoint dst = new ConnectPoint(device2.id(), PortNumber.portNumber(2));
    DefaultVirtualLink.builder().networkId(null).build();
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 52 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class DefaultVirtualPortTest method testEquality.

@Test
public void testEquality() {
    DefaultVirtualDevice device1 = new DefaultVirtualDevice(NetworkId.networkId(0), DID1);
    DefaultVirtualDevice device2 = new DefaultVirtualDevice(NetworkId.networkId(0), DID2);
    ConnectPoint cpA = new ConnectPoint(device1.id(), PortNumber.portNumber(1));
    ConnectPoint cpB = new ConnectPoint(device1.id(), PortNumber.portNumber(2));
    ConnectPoint cpC = new ConnectPoint(device2.id(), PortNumber.portNumber(2));
    DefaultVirtualPort port1 = new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), cpA);
    DefaultVirtualPort port2 = new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), cpA);
    DefaultVirtualPort port3 = new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(2), cpB);
    DefaultVirtualPort port4 = new DefaultVirtualPort(NetworkId.networkId(1), device2, PortNumber.portNumber(2), cpC);
    new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3).addEqualityGroup(port4).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 53 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class VirtualPortCodec method decode.

@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
    VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
    Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
    VirtualDevice vDev = vDevs.stream().filter(virtualDevice -> virtualDevice.id().equals(dId)).findFirst().orElse(null);
    nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
    PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
    DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
    PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
    ConnectPoint realizedBy = new ConnectPoint(physDId, physPortNum);
    return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
Also used : DeviceId(org.onosproject.net.DeviceId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultVirtualPort(org.onosproject.incubator.net.virtual.DefaultVirtualPort)

Example 54 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class UiLinkId method canonicalizeIdentifier.

private static UiLinkId canonicalizeIdentifier(ConnectPoint src, ConnectPoint dst) {
    if (src == null || dst == null) {
        throw new NullPointerException("null src or dst connect point (illegal for UiLinkId)");
    }
    ElementId srcId = src.elementId();
    ElementId dstId = dst.elementId();
    // canonicalize
    int comp = srcId.toString().compareTo(dstId.toString());
    return comp <= 0 ? new UiLinkId(srcId, src.port(), dstId, dst.port()) : new UiLinkId(dstId, dst.port(), srcId, src.port());
}
Also used : ElementId(org.onosproject.net.ElementId) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 55 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class DefaultTopology method findInfrastructurePoints.

// Collects and returns an set of all infrastructure link end-points.
private ImmutableSet<ConnectPoint> findInfrastructurePoints() {
    ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder();
    for (TopologyEdge edge : graph.getEdges()) {
        if (edge.link().type() == Type.EDGE) {
            // - Device <-> remote domain Device
            continue;
        }
        builder.add(edge.link().src());
        builder.add(edge.link().dst());
    }
    return builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyEdge(org.onosproject.net.topology.TopologyEdge)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)536 Test (org.junit.Test)149 DeviceId (org.onosproject.net.DeviceId)125 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)91 Link (org.onosproject.net.Link)88 Set (java.util.Set)86 PortNumber (org.onosproject.net.PortNumber)86 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)83 VlanId (org.onlab.packet.VlanId)78 TrafficSelector (org.onosproject.net.flow.TrafficSelector)75 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)72 Logger (org.slf4j.Logger)71 Port (org.onosproject.net.Port)70 List (java.util.List)69 Ethernet (org.onlab.packet.Ethernet)69 DeviceService (org.onosproject.net.device.DeviceService)67 Collectors (java.util.stream.Collectors)66 MacAddress (org.onlab.packet.MacAddress)64 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)64 Intent (org.onosproject.net.intent.Intent)62