Search in sources :

Example 26 with FilteredConnectPoint

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));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) Constraint(org.onosproject.net.intent.Constraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) DeviceId(org.onosproject.net.DeviceId) WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Lambda(org.onosproject.net.Lambda) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 27 with FilteredConnectPoint

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)));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 28 with FilteredConnectPoint

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);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 29 with FilteredConnectPoint

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);
}
Also used : ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 30 with FilteredConnectPoint

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

FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)161 Test (org.junit.Test)101 Intent (org.onosproject.net.intent.Intent)101 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)92 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)80 TrafficSelector (org.onosproject.net.flow.TrafficSelector)65 ConnectPoint (org.onosproject.net.ConnectPoint)64 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)53 List (java.util.List)52 Collectors (java.util.stream.Collectors)52 VlanId (org.onlab.packet.VlanId)52 DeviceId (org.onosproject.net.DeviceId)50 FlowRule (org.onosproject.net.flow.FlowRule)50 DomainService (org.onosproject.net.domain.DomainService)48 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)48 ImmutableSet (com.google.common.collect.ImmutableSet)47 LOCAL (org.onosproject.net.domain.DomainId.LOCAL)47 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)47 Before (org.junit.Before)46