Ray Milkey
Committed by Gerrit Code Review

Add priority to remaining intent types

Change-Id: I77a7c2fbdb0f6b6a9d3c08cf190ab8cf4968668d
......@@ -231,12 +231,14 @@ public class BandwidthCalendarResource extends BaseResource {
HostId srcPoint = HostId.hostId(src);
HostId dstPoint = HostId.hostId(dst);
return new HostToHostIntent(appId(), key, srcPoint, dstPoint,
selector, treatment, constraints);
selector, treatment, constraints,
Intent.DEFAULT_INTENT_PRIORITY);
} else {
ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort));
ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort));
return new TwoWayP2PIntent(appId(), key, srcPoint, dstPoint,
selector, treatment, constraints);
selector, treatment, constraints,
Intent.DEFAULT_INTENT_PRIORITY);
}
}
......
......@@ -214,7 +214,8 @@ public class DemoInstaller implements DemoAPI {
for (Host dst : hosts) {
HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(),
selector, treatment,
constraint);
constraint,
Intent.DEFAULT_INTENT_PRIORITY);
existingIntents.add(intent);
intentService.submit(intent);
}
......@@ -414,7 +415,8 @@ public class DemoInstaller implements DemoAPI {
this.src = src;
this.dst = dst;
this.intent = new HostToHostIntent(appId, src.id(), dst.id(),
selector, treatment, constraint);
selector, treatment, constraint,
Intent.DEFAULT_INTENT_PRIORITY);
}
public HostToHostIntent h2hIntent() {
......
......@@ -57,7 +57,7 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand {
HostToHostIntent intent = new HostToHostIntent(appId(), key(),
oneId, twoId,
selector, treatment,
constraints);
constraints, priority());
service.submit(intent);
print("Host to Host intent submitted:\n%s", intent.toString());
}
......
package org.onosproject.cli.net;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
import java.util.List;
import java.util.Optional;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.onlab.packet.MplsLabel;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
......@@ -20,6 +16,9 @@ import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.MplsIntent;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
@Command(scope = "onos", name = "add-mpls-intent", description = "Installs mpls connectivity intent")
public class AddMplsIntent extends ConnectivityIntentCommand {
......@@ -78,7 +77,8 @@ public class AddMplsIntent extends ConnectivityIntentCommand {
MplsIntent intent = new MplsIntent(appId(), selector, treatment,
ingress, ingressLabel, egress,
egressLabel, constraints);
egressLabel, constraints,
priority());
service.submit(intent);
}
......
......@@ -52,7 +52,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
this(appId, one, two,
DefaultTrafficSelector.emptySelector(),
DefaultTrafficTreatment.emptyTreatment(),
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
DEFAULT_INTENT_PRIORITY);
}
/**
......@@ -69,7 +70,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
TrafficSelector selector,
TrafficTreatment treatment) {
this(appId, one, two, selector, treatment,
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
DEFAULT_INTENT_PRIORITY);
}
/**
......@@ -81,13 +83,15 @@ public final class HostToHostIntent extends ConnectivityIntent {
* @param selector action
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
TrafficSelector selector,
TrafficTreatment treatment,
List<Constraint> constraints) {
this(appId, null, one, two, selector, treatment, constraints);
List<Constraint> constraints,
int priority) {
this(appId, null, one, two, selector, treatment, constraints, priority);
}
/**
* Creates a new host-to-host intent with the supplied host pair.
......@@ -99,15 +103,17 @@ public final class HostToHostIntent extends ConnectivityIntent {
* @param selector action
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
public HostToHostIntent(ApplicationId appId, Key key,
HostId one, HostId two,
TrafficSelector selector,
TrafficTreatment treatment,
List<Constraint> constraints) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
DEFAULT_INTENT_PRIORITY);
List<Constraint> constraints,
int priority) {
super(appId, key, Collections.emptyList(), selector, treatment,
constraints, priority);
// TODO: consider whether the case one and two are same is allowed
this.one = checkNotNull(one);
......
......@@ -49,7 +49,8 @@ public final class MplsIntent extends ConnectivityIntent {
ConnectPoint egressPoint,
Optional<MplsLabel> egressLabel) {
this(appId, selector, treatment, ingressPoint, ingressLabel, egressPoint, egressLabel,
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
DEFAULT_INTENT_PRIORITY);
}
/**
......@@ -64,6 +65,7 @@ public final class MplsIntent extends ConnectivityIntent {
* @param egressPoint egress port
* @param egressLabel egress MPLS label
* @param constraints optional list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
*/
public MplsIntent(ApplicationId appId, TrafficSelector selector,
......@@ -72,10 +74,11 @@ public final class MplsIntent extends ConnectivityIntent {
Optional<MplsLabel> ingressLabel,
ConnectPoint egressPoint,
Optional<MplsLabel> egressLabel,
List<Constraint> constraints) {
List<Constraint> constraints,
int priority) {
super(appId, Collections.emptyList(), selector, treatment, constraints,
DEFAULT_INTENT_PRIORITY);
priority);
checkNotNull(ingressPoint);
checkNotNull(egressPoint);
......@@ -99,7 +102,6 @@ public final class MplsIntent extends ConnectivityIntent {
this.ingressLabel = null;
this.egressPoint = null;
this.egressLabel = null;
}
/**
......
......@@ -39,7 +39,7 @@ public final class MplsPathIntent extends PathIntent {
TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Optional<MplsLabel> egressLabel) {
this(appId, selector, treatment, path, ingressLabel, egressLabel,
Collections.emptyList());
Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
}
......@@ -54,13 +54,15 @@ public final class MplsPathIntent extends PathIntent {
* @param ingressLabel MPLS egress label
* @param egressLabel MPLS ingress label
* @param constraints optional list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException {@code path} is null
*/
public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Optional<MplsLabel> egressLabel, List<Constraint> constraints) {
Optional<MplsLabel> egressLabel, List<Constraint> constraints,
int priority) {
super(appId, selector, treatment, path, constraints,
DEFAULT_INTENT_PRIORITY);
priority);
checkNotNull(ingressLabel);
checkNotNull(egressLabel);
......
......@@ -41,7 +41,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
private final ConnectPoint two;
/**
* Creates a new host-to-host intent with the supplied host pair and no
* Creates a new two way host-to-host intent with the supplied host pair and no
* other traffic selection or treatment criteria.
*
* @param appId application identifier
......@@ -53,7 +53,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
this(appId, one, two,
DefaultTrafficSelector.emptySelector(),
DefaultTrafficTreatment.emptyTreatment(),
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
DEFAULT_INTENT_PRIORITY);
}
/**
......@@ -70,7 +71,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
TrafficSelector selector,
TrafficTreatment treatment) {
this(appId, one, two, selector, treatment,
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
DEFAULT_INTENT_PRIORITY);
}
/**
......@@ -82,13 +84,15 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
* @param selector action
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two,
TrafficSelector selector,
TrafficTreatment treatment,
List<Constraint> constraints) {
this(appId, null, one, two, selector, treatment, constraints);
List<Constraint> constraints,
int priority) {
this(appId, null, one, two, selector, treatment, constraints, priority);
}
/**
* Creates a new host-to-host intent with the supplied host pair.
......@@ -100,15 +104,17 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
* @param selector action
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
public TwoWayP2PIntent(ApplicationId appId, Key key,
ConnectPoint one, ConnectPoint two,
TrafficSelector selector,
TrafficTreatment treatment,
List<Constraint> constraints) {
List<Constraint> constraints,
int priority) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
DEFAULT_INTENT_PRIORITY);
priority);
// TODO: consider whether the case one and two are same is allowed
this.one = checkNotNull(one);
......
......@@ -78,7 +78,8 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent>
return new MplsPathIntent(intent.appId(),
intent.selector(), intent.treatment(), path,
intent.ingressLabel(), intent.egressLabel(),
intent.constraints());
intent.constraints(),
intent.priority());
}
......
......@@ -51,11 +51,11 @@ public class TwoWayP2PIntentCompiler
new PointToPointIntent(intent.appId(), intent.key(),
intent.selector(), intent.treatment(),
intent.one(), intent.two(),
intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY),
intent.constraints(), intent.priority()),
new PointToPointIntent(intent.appId(), intent.key(),
intent.selector(), intent.treatment(),
intent.two(), intent.one(),
intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY));
intent.constraints(), intent.priority()));
}
}
......
......@@ -74,7 +74,8 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest {
new DefaultPath(PID, links, hops),
ingressLabel,
egressLabel,
ImmutableList.of());
ImmutableList.of(),
55);
}
/**
......