Search in sources :

Example 1 with AsymmetricPathConstraint

use of org.onosproject.net.intent.constraint.AsymmetricPathConstraint 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 2 with AsymmetricPathConstraint

use of org.onosproject.net.intent.constraint.AsymmetricPathConstraint in project onos by opennetworkinglab.

the class HostToHostIntentCompiler method compile.

@Override
public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) {
    // If source and destination are the same, there are never any installables.
    if (Objects.equals(intent.one(), intent.two())) {
        return ImmutableList.of();
    }
    boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint());
    Path pathOne = getPathOrException(intent, intent.one(), intent.two());
    Path pathTwo = isAsymmetric ? getPathOrException(intent, intent.two(), intent.one()) : invertPath(pathOne);
    Host one = hostService.getHost(intent.one());
    Host two = hostService.getHost(intent.two());
    return Arrays.asList(createLinkCollectionIntent(pathOne, one, two, intent), createLinkCollectionIntent(pathTwo, two, one, intent));
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) Host(org.onosproject.net.Host) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint)

Example 3 with AsymmetricPathConstraint

use of org.onosproject.net.intent.constraint.AsymmetricPathConstraint in project onos by opennetworkinglab.

the class ConstraintCodecTest method asymmetricPathConstraint.

/**
 * Tests asymmetric path constraint.
 */
@Test
public void asymmetricPathConstraint() {
    Constraint constraint = getConstraint("AsymmetricPathConstraint.json");
    assertThat(constraint, instanceOf(AsymmetricPathConstraint.class));
}
Also used : WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) DomainConstraint(org.onosproject.net.intent.constraint.DomainConstraint) MeteredConstraint(org.onosproject.net.intent.constraint.MeteredConstraint) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) Constraint(org.onosproject.net.intent.Constraint) TierConstraint(org.onosproject.net.intent.constraint.TierConstraint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) LinkTypeConstraint(org.onosproject.net.intent.constraint.LinkTypeConstraint) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) Test(org.junit.Test)

Aggregations

AsymmetricPathConstraint (org.onosproject.net.intent.constraint.AsymmetricPathConstraint)3 Test (org.junit.Test)2 Constraint (org.onosproject.net.intent.Constraint)2 AnnotationConstraint (org.onosproject.net.intent.constraint.AnnotationConstraint)2 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)2 LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)2 ObstacleConstraint (org.onosproject.net.intent.constraint.ObstacleConstraint)2 WaypointConstraint (org.onosproject.net.intent.constraint.WaypointConstraint)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DefaultPath (org.onosproject.net.DefaultPath)1 DeviceId (org.onosproject.net.DeviceId)1 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)1 Host (org.onosproject.net.Host)1 Lambda (org.onosproject.net.Lambda)1 Path (org.onosproject.net.Path)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1