Search in sources :

Example 6 with DefaultL2TunnelDescription

use of org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription in project trellis-control by opennetworkinglab.

the class PseudowireCodec method decodePws.

/**
 * @param json The json containing the pseudowires.
 * @param context The context
 * @return A pair of lists.
 *         First list contains pseudowires that we were not able to decode
 *         along with the reason we could not decode them.
 *         Second list contains successfully decoded pseudowires which we are
 *         going to instantiate.
 */
public Pair<List<Pair<JsonNode, String>>, List<L2TunnelDescription>> decodePws(ArrayNode json, CodecContext context) {
    List<L2TunnelDescription> decodedPws = new ArrayList<>();
    List<Pair<JsonNode, String>> notDecodedPws = new ArrayList<>();
    for (JsonNode node : json) {
        DefaultL2TunnelDescription l2Description;
        try {
            l2Description = decode((ObjectNode) node, context);
            decodedPws.add(l2Description);
        } catch (IllegalArgumentException e) {
            // the reason why we could not decode this pseudowire is encoded in the
            // exception, we need to store it now
            notDecodedPws.add(Pair.of(node, e.getMessage()));
        }
    }
    return Pair.of(notDecodedPws, decodedPws);
}
Also used : DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription) Pair(org.apache.commons.lang3.tuple.Pair)

Example 7 with DefaultL2TunnelDescription

use of org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription in project trellis-control by opennetworkinglab.

the class PseudowireCodec method decode.

@Override
public DefaultL2TunnelDescription decode(ObjectNode json, CodecContext context) {
    Integer id = parsePwId(json.path(PW_ID).asText());
    ConnectPoint cP1, cP2;
    cP1 = ConnectPoint.deviceConnectPoint(json.path(CP1).asText());
    cP2 = ConnectPoint.deviceConnectPoint(json.path(CP2).asText());
    VlanId cP1InnerVlan, cP1OuterVlan, cP2InnerVlan, cP2OuterVlan, sdTag;
    cP1InnerVlan = parseVlan(json.path(CP1_INNER_TAG).asText());
    cP1OuterVlan = parseVlan(json.path(CP1_OUTER_TAG).asText());
    cP2InnerVlan = parseVlan(json.path(CP2_INNER_TAG).asText());
    cP2OuterVlan = parseVlan(json.path(CP2_OUTER_TAG).asText());
    sdTag = parseVlan(json.path(SERVICE_DELIM_TAG).asText());
    L2Mode mode = parseMode(json.path(MODE).asText());
    MplsLabel pwLabel = parsePWLabel(json.path(PW_LABEL).asText());
    DefaultL2Tunnel l2Tunnel = new DefaultL2Tunnel(mode, sdTag, id, pwLabel);
    DefaultL2TunnelPolicy l2Policy = new DefaultL2TunnelPolicy(id, cP1, cP1InnerVlan, cP1OuterVlan, cP2, cP2InnerVlan, cP2OuterVlan);
    return new DefaultL2TunnelDescription(l2Tunnel, l2Policy);
}
Also used : DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) MplsLabel(org.onlab.packet.MplsLabel) L2Mode(org.onosproject.segmentrouting.pwaas.L2Mode) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) VlanId(org.onlab.packet.VlanId)

Aggregations

DefaultL2TunnelDescription (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription)7 ArrayList (java.util.ArrayList)5 L2TunnelDescription (org.onosproject.segmentrouting.pwaas.L2TunnelDescription)5 L2TunnelHandler (org.onosproject.segmentrouting.pwaas.L2TunnelHandler)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Pair (org.apache.commons.lang3.tuple.Pair)4 SegmentRoutingService (org.onosproject.segmentrouting.SegmentRoutingService)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 List (java.util.List)2 Path (javax.ws.rs.Path)2 ItemNotFoundException (org.onlab.util.ItemNotFoundException)2 DefaultL2Tunnel (org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel)2 DefaultL2TunnelPolicy (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy)2 L2Tunnel (org.onosproject.segmentrouting.pwaas.L2Tunnel)2 L2TunnelPolicy (org.onosproject.segmentrouting.pwaas.L2TunnelPolicy)2 IOException (java.io.IOException)1