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 { ...@@ -231,12 +231,14 @@ public class BandwidthCalendarResource extends BaseResource {
231 HostId srcPoint = HostId.hostId(src); 231 HostId srcPoint = HostId.hostId(src);
232 HostId dstPoint = HostId.hostId(dst); 232 HostId dstPoint = HostId.hostId(dst);
233 return new HostToHostIntent(appId(), key, srcPoint, dstPoint, 233 return new HostToHostIntent(appId(), key, srcPoint, dstPoint,
234 - selector, treatment, constraints); 234 + selector, treatment, constraints,
235 + Intent.DEFAULT_INTENT_PRIORITY);
235 } else { 236 } else {
236 ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort)); 237 ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort));
237 ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort)); 238 ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort));
238 return new TwoWayP2PIntent(appId(), key, srcPoint, dstPoint, 239 return new TwoWayP2PIntent(appId(), key, srcPoint, dstPoint,
239 - selector, treatment, constraints); 240 + selector, treatment, constraints,
241 + Intent.DEFAULT_INTENT_PRIORITY);
240 } 242 }
241 } 243 }
242 244
......
...@@ -214,7 +214,8 @@ public class DemoInstaller implements DemoAPI { ...@@ -214,7 +214,8 @@ public class DemoInstaller implements DemoAPI {
214 for (Host dst : hosts) { 214 for (Host dst : hosts) {
215 HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(), 215 HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(),
216 selector, treatment, 216 selector, treatment,
217 - constraint); 217 + constraint,
218 + Intent.DEFAULT_INTENT_PRIORITY);
218 existingIntents.add(intent); 219 existingIntents.add(intent);
219 intentService.submit(intent); 220 intentService.submit(intent);
220 } 221 }
...@@ -414,7 +415,8 @@ public class DemoInstaller implements DemoAPI { ...@@ -414,7 +415,8 @@ public class DemoInstaller implements DemoAPI {
414 this.src = src; 415 this.src = src;
415 this.dst = dst; 416 this.dst = dst;
416 this.intent = new HostToHostIntent(appId, src.id(), dst.id(), 417 this.intent = new HostToHostIntent(appId, src.id(), dst.id(),
417 - selector, treatment, constraint); 418 + selector, treatment, constraint,
419 + Intent.DEFAULT_INTENT_PRIORITY);
418 } 420 }
419 421
420 public HostToHostIntent h2hIntent() { 422 public HostToHostIntent h2hIntent() {
......
...@@ -57,7 +57,7 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { ...@@ -57,7 +57,7 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand {
57 HostToHostIntent intent = new HostToHostIntent(appId(), key(), 57 HostToHostIntent intent = new HostToHostIntent(appId(), key(),
58 oneId, twoId, 58 oneId, twoId,
59 selector, treatment, 59 selector, treatment,
60 - constraints); 60 + constraints, priority());
61 service.submit(intent); 61 service.submit(intent);
62 print("Host to Host intent submitted:\n%s", intent.toString()); 62 print("Host to Host intent submitted:\n%s", intent.toString());
63 } 63 }
......
1 package org.onosproject.cli.net; 1 package org.onosproject.cli.net;
2 2
3 -import static org.onosproject.net.DeviceId.deviceId;
4 -import static org.onosproject.net.PortNumber.portNumber;
5 -
6 import java.util.List; 3 import java.util.List;
7 import java.util.Optional; 4 import java.util.Optional;
8 5
9 import org.apache.karaf.shell.commands.Argument; 6 import org.apache.karaf.shell.commands.Argument;
10 import org.apache.karaf.shell.commands.Command; 7 import org.apache.karaf.shell.commands.Command;
11 import org.apache.karaf.shell.commands.Option; 8 import org.apache.karaf.shell.commands.Option;
12 -
13 import org.onlab.packet.MplsLabel; 9 import org.onlab.packet.MplsLabel;
14 import org.onosproject.net.ConnectPoint; 10 import org.onosproject.net.ConnectPoint;
15 import org.onosproject.net.DeviceId; 11 import org.onosproject.net.DeviceId;
...@@ -20,6 +16,9 @@ import org.onosproject.net.intent.Constraint; ...@@ -20,6 +16,9 @@ import org.onosproject.net.intent.Constraint;
20 import org.onosproject.net.intent.IntentService; 16 import org.onosproject.net.intent.IntentService;
21 import org.onosproject.net.intent.MplsIntent; 17 import org.onosproject.net.intent.MplsIntent;
22 18
19 +import static org.onosproject.net.DeviceId.deviceId;
20 +import static org.onosproject.net.PortNumber.portNumber;
21 +
23 @Command(scope = "onos", name = "add-mpls-intent", description = "Installs mpls connectivity intent") 22 @Command(scope = "onos", name = "add-mpls-intent", description = "Installs mpls connectivity intent")
24 public class AddMplsIntent extends ConnectivityIntentCommand { 23 public class AddMplsIntent extends ConnectivityIntentCommand {
25 24
...@@ -78,7 +77,8 @@ public class AddMplsIntent extends ConnectivityIntentCommand { ...@@ -78,7 +77,8 @@ public class AddMplsIntent extends ConnectivityIntentCommand {
78 77
79 MplsIntent intent = new MplsIntent(appId(), selector, treatment, 78 MplsIntent intent = new MplsIntent(appId(), selector, treatment,
80 ingress, ingressLabel, egress, 79 ingress, ingressLabel, egress,
81 - egressLabel, constraints); 80 + egressLabel, constraints,
81 + priority());
82 service.submit(intent); 82 service.submit(intent);
83 } 83 }
84 84
......
...@@ -52,7 +52,8 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -52,7 +52,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
52 this(appId, one, two, 52 this(appId, one, two,
53 DefaultTrafficSelector.emptySelector(), 53 DefaultTrafficSelector.emptySelector(),
54 DefaultTrafficTreatment.emptyTreatment(), 54 DefaultTrafficTreatment.emptyTreatment(),
55 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 55 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
56 + DEFAULT_INTENT_PRIORITY);
56 } 57 }
57 58
58 /** 59 /**
...@@ -69,7 +70,8 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -69,7 +70,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
69 TrafficSelector selector, 70 TrafficSelector selector,
70 TrafficTreatment treatment) { 71 TrafficTreatment treatment) {
71 this(appId, one, two, selector, treatment, 72 this(appId, one, two, selector, treatment,
72 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 73 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
74 + DEFAULT_INTENT_PRIORITY);
73 } 75 }
74 76
75 /** 77 /**
...@@ -81,13 +83,15 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -81,13 +83,15 @@ public final class HostToHostIntent extends ConnectivityIntent {
81 * @param selector action 83 * @param selector action
82 * @param treatment ingress port 84 * @param treatment ingress port
83 * @param constraints optional prioritized list of path selection constraints 85 * @param constraints optional prioritized list of path selection constraints
86 + * @param priority priority to use for flows generated by this intent
84 * @throws NullPointerException if {@code one} or {@code two} is null. 87 * @throws NullPointerException if {@code one} or {@code two} is null.
85 */ 88 */
86 public HostToHostIntent(ApplicationId appId, HostId one, HostId two, 89 public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
87 TrafficSelector selector, 90 TrafficSelector selector,
88 TrafficTreatment treatment, 91 TrafficTreatment treatment,
89 - List<Constraint> constraints) { 92 + List<Constraint> constraints,
90 - this(appId, null, one, two, selector, treatment, constraints); 93 + int priority) {
94 + this(appId, null, one, two, selector, treatment, constraints, priority);
91 } 95 }
92 /** 96 /**
93 * Creates a new host-to-host intent with the supplied host pair. 97 * Creates a new host-to-host intent with the supplied host pair.
...@@ -99,15 +103,17 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -99,15 +103,17 @@ public final class HostToHostIntent extends ConnectivityIntent {
99 * @param selector action 103 * @param selector action
100 * @param treatment ingress port 104 * @param treatment ingress port
101 * @param constraints optional prioritized list of path selection constraints 105 * @param constraints optional prioritized list of path selection constraints
106 + * @param priority priority to use for flows generated by this intent
102 * @throws NullPointerException if {@code one} or {@code two} is null. 107 * @throws NullPointerException if {@code one} or {@code two} is null.
103 */ 108 */
104 public HostToHostIntent(ApplicationId appId, Key key, 109 public HostToHostIntent(ApplicationId appId, Key key,
105 HostId one, HostId two, 110 HostId one, HostId two,
106 TrafficSelector selector, 111 TrafficSelector selector,
107 TrafficTreatment treatment, 112 TrafficTreatment treatment,
108 - List<Constraint> constraints) { 113 + List<Constraint> constraints,
109 - super(appId, key, Collections.emptyList(), selector, treatment, constraints, 114 + int priority) {
110 - DEFAULT_INTENT_PRIORITY); 115 + super(appId, key, Collections.emptyList(), selector, treatment,
116 + constraints, priority);
111 117
112 // TODO: consider whether the case one and two are same is allowed 118 // TODO: consider whether the case one and two are same is allowed
113 this.one = checkNotNull(one); 119 this.one = checkNotNull(one);
......
...@@ -49,7 +49,8 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -49,7 +49,8 @@ public final class MplsIntent extends ConnectivityIntent {
49 ConnectPoint egressPoint, 49 ConnectPoint egressPoint,
50 Optional<MplsLabel> egressLabel) { 50 Optional<MplsLabel> egressLabel) {
51 this(appId, selector, treatment, ingressPoint, ingressLabel, egressPoint, egressLabel, 51 this(appId, selector, treatment, ingressPoint, ingressLabel, egressPoint, egressLabel,
52 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 52 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
53 + DEFAULT_INTENT_PRIORITY);
53 } 54 }
54 55
55 /** 56 /**
...@@ -64,6 +65,7 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -64,6 +65,7 @@ public final class MplsIntent extends ConnectivityIntent {
64 * @param egressPoint egress port 65 * @param egressPoint egress port
65 * @param egressLabel egress MPLS label 66 * @param egressLabel egress MPLS label
66 * @param constraints optional list of constraints 67 * @param constraints optional list of constraints
68 + * @param priority priority to use for flows generated by this intent
67 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. 69 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
68 */ 70 */
69 public MplsIntent(ApplicationId appId, TrafficSelector selector, 71 public MplsIntent(ApplicationId appId, TrafficSelector selector,
...@@ -72,10 +74,11 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -72,10 +74,11 @@ public final class MplsIntent extends ConnectivityIntent {
72 Optional<MplsLabel> ingressLabel, 74 Optional<MplsLabel> ingressLabel,
73 ConnectPoint egressPoint, 75 ConnectPoint egressPoint,
74 Optional<MplsLabel> egressLabel, 76 Optional<MplsLabel> egressLabel,
75 - List<Constraint> constraints) { 77 + List<Constraint> constraints,
78 + int priority) {
76 79
77 super(appId, Collections.emptyList(), selector, treatment, constraints, 80 super(appId, Collections.emptyList(), selector, treatment, constraints,
78 - DEFAULT_INTENT_PRIORITY); 81 + priority);
79 82
80 checkNotNull(ingressPoint); 83 checkNotNull(ingressPoint);
81 checkNotNull(egressPoint); 84 checkNotNull(egressPoint);
...@@ -99,7 +102,6 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -99,7 +102,6 @@ public final class MplsIntent extends ConnectivityIntent {
99 this.ingressLabel = null; 102 this.ingressLabel = null;
100 this.egressPoint = null; 103 this.egressPoint = null;
101 this.egressLabel = null; 104 this.egressLabel = null;
102 -
103 } 105 }
104 106
105 /** 107 /**
......
...@@ -39,7 +39,7 @@ public final class MplsPathIntent extends PathIntent { ...@@ -39,7 +39,7 @@ public final class MplsPathIntent extends PathIntent {
39 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, 39 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
40 Optional<MplsLabel> egressLabel) { 40 Optional<MplsLabel> egressLabel) {
41 this(appId, selector, treatment, path, ingressLabel, egressLabel, 41 this(appId, selector, treatment, path, ingressLabel, egressLabel,
42 - Collections.emptyList()); 42 + Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
43 43
44 } 44 }
45 45
...@@ -54,13 +54,15 @@ public final class MplsPathIntent extends PathIntent { ...@@ -54,13 +54,15 @@ public final class MplsPathIntent extends PathIntent {
54 * @param ingressLabel MPLS egress label 54 * @param ingressLabel MPLS egress label
55 * @param egressLabel MPLS ingress label 55 * @param egressLabel MPLS ingress label
56 * @param constraints optional list of constraints 56 * @param constraints optional list of constraints
57 + * @param priority priority to use for flows generated by this intent
57 * @throws NullPointerException {@code path} is null 58 * @throws NullPointerException {@code path} is null
58 */ 59 */
59 public MplsPathIntent(ApplicationId appId, TrafficSelector selector, 60 public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
60 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, 61 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
61 - Optional<MplsLabel> egressLabel, List<Constraint> constraints) { 62 + Optional<MplsLabel> egressLabel, List<Constraint> constraints,
63 + int priority) {
62 super(appId, selector, treatment, path, constraints, 64 super(appId, selector, treatment, path, constraints,
63 - DEFAULT_INTENT_PRIORITY); 65 + priority);
64 66
65 checkNotNull(ingressLabel); 67 checkNotNull(ingressLabel);
66 checkNotNull(egressLabel); 68 checkNotNull(egressLabel);
......
...@@ -41,7 +41,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -41,7 +41,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
41 private final ConnectPoint two; 41 private final ConnectPoint two;
42 42
43 /** 43 /**
44 - * Creates a new host-to-host intent with the supplied host pair and no 44 + * Creates a new two way host-to-host intent with the supplied host pair and no
45 * other traffic selection or treatment criteria. 45 * other traffic selection or treatment criteria.
46 * 46 *
47 * @param appId application identifier 47 * @param appId application identifier
...@@ -53,7 +53,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -53,7 +53,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
53 this(appId, one, two, 53 this(appId, one, two,
54 DefaultTrafficSelector.emptySelector(), 54 DefaultTrafficSelector.emptySelector(),
55 DefaultTrafficTreatment.emptyTreatment(), 55 DefaultTrafficTreatment.emptyTreatment(),
56 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 56 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
57 + DEFAULT_INTENT_PRIORITY);
57 } 58 }
58 59
59 /** 60 /**
...@@ -70,7 +71,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -70,7 +71,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
70 TrafficSelector selector, 71 TrafficSelector selector,
71 TrafficTreatment treatment) { 72 TrafficTreatment treatment) {
72 this(appId, one, two, selector, treatment, 73 this(appId, one, two, selector, treatment,
73 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 74 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
75 + DEFAULT_INTENT_PRIORITY);
74 } 76 }
75 77
76 /** 78 /**
...@@ -82,13 +84,15 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -82,13 +84,15 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
82 * @param selector action 84 * @param selector action
83 * @param treatment ingress port 85 * @param treatment ingress port
84 * @param constraints optional prioritized list of path selection constraints 86 * @param constraints optional prioritized list of path selection constraints
87 + * @param priority priority to use for flows generated by this intent
85 * @throws NullPointerException if {@code one} or {@code two} is null. 88 * @throws NullPointerException if {@code one} or {@code two} is null.
86 */ 89 */
87 public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two, 90 public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two,
88 TrafficSelector selector, 91 TrafficSelector selector,
89 TrafficTreatment treatment, 92 TrafficTreatment treatment,
90 - List<Constraint> constraints) { 93 + List<Constraint> constraints,
91 - this(appId, null, one, two, selector, treatment, constraints); 94 + int priority) {
95 + this(appId, null, one, two, selector, treatment, constraints, priority);
92 } 96 }
93 /** 97 /**
94 * Creates a new host-to-host intent with the supplied host pair. 98 * Creates a new host-to-host intent with the supplied host pair.
...@@ -100,15 +104,17 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -100,15 +104,17 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
100 * @param selector action 104 * @param selector action
101 * @param treatment ingress port 105 * @param treatment ingress port
102 * @param constraints optional prioritized list of path selection constraints 106 * @param constraints optional prioritized list of path selection constraints
107 + * @param priority priority to use for flows generated by this intent
103 * @throws NullPointerException if {@code one} or {@code two} is null. 108 * @throws NullPointerException if {@code one} or {@code two} is null.
104 */ 109 */
105 public TwoWayP2PIntent(ApplicationId appId, Key key, 110 public TwoWayP2PIntent(ApplicationId appId, Key key,
106 ConnectPoint one, ConnectPoint two, 111 ConnectPoint one, ConnectPoint two,
107 TrafficSelector selector, 112 TrafficSelector selector,
108 TrafficTreatment treatment, 113 TrafficTreatment treatment,
109 - List<Constraint> constraints) { 114 + List<Constraint> constraints,
115 + int priority) {
110 super(appId, key, Collections.emptyList(), selector, treatment, constraints, 116 super(appId, key, Collections.emptyList(), selector, treatment, constraints,
111 - DEFAULT_INTENT_PRIORITY); 117 + priority);
112 118
113 // TODO: consider whether the case one and two are same is allowed 119 // TODO: consider whether the case one and two are same is allowed
114 this.one = checkNotNull(one); 120 this.one = checkNotNull(one);
......
...@@ -78,7 +78,8 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> ...@@ -78,7 +78,8 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent>
78 return new MplsPathIntent(intent.appId(), 78 return new MplsPathIntent(intent.appId(),
79 intent.selector(), intent.treatment(), path, 79 intent.selector(), intent.treatment(), path,
80 intent.ingressLabel(), intent.egressLabel(), 80 intent.ingressLabel(), intent.egressLabel(),
81 - intent.constraints()); 81 + intent.constraints(),
82 + intent.priority());
82 } 83 }
83 84
84 85
......
...@@ -51,11 +51,11 @@ public class TwoWayP2PIntentCompiler ...@@ -51,11 +51,11 @@ public class TwoWayP2PIntentCompiler
51 new PointToPointIntent(intent.appId(), intent.key(), 51 new PointToPointIntent(intent.appId(), intent.key(),
52 intent.selector(), intent.treatment(), 52 intent.selector(), intent.treatment(),
53 intent.one(), intent.two(), 53 intent.one(), intent.two(),
54 - intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY), 54 + intent.constraints(), intent.priority()),
55 new PointToPointIntent(intent.appId(), intent.key(), 55 new PointToPointIntent(intent.appId(), intent.key(),
56 intent.selector(), intent.treatment(), 56 intent.selector(), intent.treatment(),
57 intent.two(), intent.one(), 57 intent.two(), intent.one(),
58 - intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY)); 58 + intent.constraints(), intent.priority()));
59 59
60 } 60 }
61 } 61 }
......
...@@ -74,7 +74,8 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest { ...@@ -74,7 +74,8 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest {
74 new DefaultPath(PID, links, hops), 74 new DefaultPath(PID, links, hops),
75 ingressLabel, 75 ingressLabel,
76 egressLabel, 76 egressLabel,
77 - ImmutableList.of()); 77 + ImmutableList.of(),
78 + 55);
78 } 79 }
79 80
80 /** 81 /**
......