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;
}
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();
}
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);
}
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);
}
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();
}
Aggregations