Search in sources :

Example 26 with Link

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

the class DisjointPathCodec method encode.

@Override
public ObjectNode encode(DisjointPath disjointPath, CodecContext context) {
    checkNotNull(disjointPath, "Path cannot be null");
    JsonCodec<Link> codec = context.codec(Link.class);
    ObjectNode result = context.mapper().createObjectNode();
    ObjectNode primary = context.mapper().createObjectNode().put("cost", disjointPath.primary().cost());
    result.set("primary", primary);
    ArrayNode jsonLinks = primary.putArray("links");
    for (Link link : disjointPath.primary().links()) {
        jsonLinks.add(codec.encode(link, context));
    }
    if (disjointPath.backup() != null) {
        ObjectNode backup = context.mapper().createObjectNode().put("cost", disjointPath.backup().cost());
        result.set("backup", backup);
        ArrayNode jsonLinks1 = backup.putArray("links");
        for (Link link1 : disjointPath.backup().links()) {
            jsonLinks1.add(codec.encode(link1, context));
        }
    }
    return annotate(result, disjointPath, context);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Link(org.onosproject.net.Link)

Example 27 with Link

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

the class PathCodec method encode.

@Override
public ObjectNode encode(Path path, CodecContext context) {
    checkNotNull(path, "Path cannot be null");
    JsonCodec<Link> codec = context.codec(Link.class);
    ObjectNode result = context.mapper().createObjectNode().put("cost", path.cost());
    ArrayNode jsonLinks = result.putArray("links");
    for (Link link : path.links()) {
        jsonLinks.add(codec.encode(link, context));
    }
    return annotate(result, path, context);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Link(org.onosproject.net.Link)

Example 28 with Link

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

the class TunnelQueryCommand method showPath.

private String showPath(Path path) {
    if (path == null) {
        return "null";
    }
    StringBuilder builder = new StringBuilder("(");
    for (Link link : path.links()) {
        builder.append("(DeviceId:" + link.src().deviceId() + " Port:" + link.src().port().toString());
        builder.append(" DeviceId:" + link.dst().deviceId() + " Port:" + link.dst().port().toString() + ")");
    }
    builder.append(annotations(path.annotations()) + ")");
    return builder.toString();
}
Also used : Link(org.onosproject.net.Link)

Example 29 with Link

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

the class LinksListCommand method doExecute.

@Override
protected void doExecute() {
    LinkService service = get(LinkService.class);
    Iterable<Link> links = uri != null ? service.getDeviceLinks(deviceId(uri)) : service.getLinks();
    if (outputJson()) {
        print("%s", json(this, links));
    } else {
        Tools.stream(links).sorted(Comparator.comparing(link -> linkKey(link).toString())).forEach(link -> {
            print(linkString(link));
        });
    }
}
Also used : LinkService(org.onosproject.net.link.LinkService) Link(org.onosproject.net.Link)

Example 30 with Link

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

the class LinkCollectionCompiler method computePorts.

/**
 * Helper method to compute input and output ports
 * for each device crossed in the path.
 *
 * @param intent the related intents
 * @param inputPorts the input ports to compute
 * @param outputPorts the output ports to compute
 */
protected void computePorts(LinkCollectionIntent intent, SetMultimap<DeviceId, PortNumber> inputPorts, SetMultimap<DeviceId, PortNumber> outputPorts) {
    for (Link link : intent.links()) {
        inputPorts.put(link.dst().deviceId(), link.dst().port());
        outputPorts.put(link.src().deviceId(), link.src().port());
    }
    for (ConnectPoint ingressPoint : intent.ingressPoints()) {
        inputPorts.put(ingressPoint.deviceId(), ingressPoint.port());
    }
    for (ConnectPoint egressPoint : intent.egressPoints()) {
        outputPorts.put(egressPoint.deviceId(), egressPoint.port());
    }
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Link(org.onosproject.net.Link)

Aggregations

Link (org.onosproject.net.Link)210 ConnectPoint (org.onosproject.net.ConnectPoint)92 Test (org.junit.Test)66 DeviceId (org.onosproject.net.DeviceId)62 DefaultLink (org.onosproject.net.DefaultLink)50 Intent (org.onosproject.net.intent.Intent)40 List (java.util.List)38 Set (java.util.Set)33 Collectors (java.util.stream.Collectors)30 Device (org.onosproject.net.Device)30 TrafficSelector (org.onosproject.net.flow.TrafficSelector)30 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)28 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)28 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 ArrayList (java.util.ArrayList)24 Collections (java.util.Collections)24 Path (org.onosproject.net.Path)24 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24