Search in sources :

Example 56 with ConnectPoint

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

the class MultiPointToSinglePointIntentCodec method encode.

@Override
public ObjectNode encode(MultiPointToSinglePointIntent intent, CodecContext context) {
    checkNotNull(intent, "Multi Point to Single Point intent cannot be null");
    final JsonCodec<ConnectivityIntent> connectivityIntentCodec = context.codec(ConnectivityIntent.class);
    final ObjectNode result = connectivityIntentCodec.encode(intent, context);
    final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
    final ObjectNode egress = connectPointCodec.encode(intent.egressPoint(), context);
    // Check ingress are not null and not contain egress
    ObjectNode objectCP = context.mapper().createObjectNode();
    ArrayNode jsonconnectPoints = objectCP.putArray(CP_POINTS);
    if (intent.ingressPoints() != null) {
        for (final ConnectPoint cp : intent.ingressPoints()) {
            jsonconnectPoints.add(connectPointCodec.encode(cp, context));
        }
        result.set(INGRESS_POINT, jsonconnectPoints);
    }
    result.set(EGRESS_POINT, egress);
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 57 with ConnectPoint

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

the class SinglePointToMultiPointIntentCodec method decode.

@Override
public SinglePointToMultiPointIntent decode(ObjectNode json, CodecContext context) {
    SinglePointToMultiPointIntent.Builder builder = SinglePointToMultiPointIntent.builder();
    IntentCodec.intentAttributes(json, context, builder);
    ConnectivityIntentCodec.intentAttributes(json, context, builder);
    ObjectNode ingressJson = nullIsIllegal(get(json, INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    ConnectPoint ingress = context.codec(ConnectPoint.class).decode(ingressJson, context);
    builder.filteredIngressPoint(new FilteredConnectPoint(ingress));
    ArrayNode egressJson = nullIsIllegal((ArrayNode) json.get(EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
    Set<FilteredConnectPoint> egressCp = new HashSet<>();
    for (int i = 0; i < egressJson.size(); i++) {
        ConnectPoint cp = connectPointCodec.decode(get(egressJson, i), context);
        egressCp.add(new FilteredConnectPoint(cp));
    }
    builder.filteredEgressPoints(egressCp);
    return builder.build();
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 58 with ConnectPoint

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

the class LinkCodec method encode.

@Override
public ObjectNode encode(Link link, CodecContext context) {
    checkNotNull(link, "Link cannot be null");
    JsonCodec<ConnectPoint> codec = context.codec(ConnectPoint.class);
    ObjectNode result = context.mapper().createObjectNode();
    result.set(SRC, codec.encode(link.src(), context));
    result.set(DST, codec.encode(link.dst(), context));
    result.put(TYPE, link.type().toString());
    if (link.state() != null) {
        result.put(STATE, link.state().toString());
    }
    return annotate(result, link, context);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 59 with ConnectPoint

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

the class OfdpaPipelineTraceable method buildOutputFromDevice.

// Builds a possible output from this device
private void buildOutputFromDevice(TrafficSelector.Builder egressPacket, List<PortNumber> outputPorts, OutputInstruction outputInstruction, PipelineTraceableHitChain currentHitChain, PipelineTraceableOutput.Builder outputBuilder, TrafficSelector initialPacket, boolean dropped) {
    // Store the output port for further processing
    outputPorts.add(outputInstruction.port());
    // Create the final hit chain from the current one (deep copy)
    ConnectPoint outputPort = new ConnectPoint(deviceId, outputInstruction.port());
    PipelineTraceableHitChain finalHitChain = new PipelineTraceableHitChain(outputPort, Lists.newArrayList(currentHitChain.hitChain()), new PipelineTraceablePacket(egressPacket.build()));
    // Dropped early
    if (dropped) {
        log.debug("Packet {} has been dropped", egressPacket.build());
    } else {
        finalHitChain.pass();
    }
    if (outputPort.port().equals(PortNumber.CONTROLLER)) {
        handleVlanToController(finalHitChain, initialPacket);
    }
    // If there is already a chain do not add a copy
    outputBuilder.addHitChain(finalHitChain);
}
Also used : PipelineTraceableHitChain(org.onosproject.net.PipelineTraceableHitChain) ConnectPoint(org.onosproject.net.ConnectPoint) PipelineTraceablePacket(org.onosproject.net.PipelineTraceablePacket)

Example 60 with ConnectPoint

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

the class IntentPerfInstaller method createIntent.

private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
    // choose a random device for which this node is master
    List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
    Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));
    // FIXME we currently ignore the path length and always use the same device
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.valueOf(mac)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
    ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));
    return PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(ingress)).filteredEgressPoint(new FilteredConnectPoint(egress)).build();
}
Also used : Device(org.onosproject.net.Device) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

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