use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class IntentCodecTest method intentWithTreatmentSelectorAndConstraints.
/**
* Tests the encoding of an intent with treatment, selector and constraints
* specified.
*/
@Test
public void intentWithTreatmentSelectorAndConstraints() {
ConnectPoint ingress = NetTestTools.connectPoint("ingress", 1);
ConnectPoint egress = NetTestTools.connectPoint("egress", 2);
DeviceId did1 = did("device1");
DeviceId did2 = did("device2");
DeviceId did3 = did("device3");
Lambda ochSignal = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8);
final TrafficSelector selector = DefaultTrafficSelector.builder().matchIPProtocol((byte) 3).matchMplsLabel(MplsLabel.mplsLabel(4)).add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)).add(Criteria.matchLambda(ochSignal)).matchEthDst(MacAddress.BROADCAST).matchIPDst(IpPrefix.valueOf("1.2.3.4/24")).build();
final TrafficTreatment treatment = DefaultTrafficTreatment.builder().setMpls(MplsLabel.mplsLabel(44)).setOutput(PortNumber.CONTROLLER).setEthDst(MacAddress.BROADCAST).build();
final List<Constraint> constraints = ImmutableList.of(new BandwidthConstraint(Bandwidth.bps(1.0)), new AnnotationConstraint("key", 33.0), new AsymmetricPathConstraint(), new LatencyConstraint(Duration.ofSeconds(2)), new ObstacleConstraint(did1, did2), new WaypointConstraint(did3));
final PointToPointIntent intent = PointToPointIntent.builder().appId(appId).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(ingress)).filteredEgressPoint(new FilteredConnectPoint(egress)).constraints(constraints).build();
final JsonCodec<PointToPointIntent> intentCodec = context.codec(PointToPointIntent.class);
assertThat(intentCodec, notNullValue());
final ObjectNode intentJson = intentCodec.encode(intent, context);
assertThat(intentJson, matchesIntent(intent));
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class FilteredConnectPointCodecTest method testEmptySelector.
@Test
public void testEmptySelector() {
FilteredConnectPoint original = new FilteredConnectPoint(CP);
ObjectNode json = sut.encode(original, context);
assertNotNull(json);
FilteredConnectPoint decoded = sut.decode(json, context);
assertThat(decoded, is(equalTo(original)));
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class FilteredConnectPointSerializer method read.
@Override
public FilteredConnectPoint read(Kryo kryo, Input input, Class<FilteredConnectPoint> type) {
ConnectPoint connectPoint = (ConnectPoint) kryo.readClassAndObject(input);
TrafficSelector trafficSelector = (TrafficSelector) kryo.readClassAndObject(input);
return new FilteredConnectPoint(connectPoint, trafficSelector);
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class OplinkSwitchProtection method getProtectedTransportEndpointDescription.
/*
* return the protected endpoint description of this devices
*/
private ProtectedTransportEndpointDescription getProtectedTransportEndpointDescription() {
List<TransportEndpointDescription> teds = new ArrayList<>();
FilteredConnectPoint fcpPrimary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), PortNumber.portNumber(PRIMARY_PORT)));
FilteredConnectPoint fcpSecondary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), PortNumber.portNumber(SECONDARY_PORT)));
TransportEndpointDescription tedPrimary = TransportEndpointDescription.builder().withOutput(fcpPrimary).build();
TransportEndpointDescription tedSecondary = TransportEndpointDescription.builder().withOutput(fcpSecondary).build();
teds.add(tedPrimary);
teds.add(tedSecondary);
return ProtectedTransportEndpointDescription.of(teds, getPeerId(), OPLINK_FINGERPRINT);
}
use of org.onosproject.net.FilteredConnectPoint 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