Add priority to remaining intent types

Change-Id: I77a7c2fbdb0f6b6a9d3c08cf190ab8cf4968668d
diff --git a/apps/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java b/apps/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
index ac02290..cbd4d1b 100644
--- a/apps/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
+++ b/apps/calendar/src/main/java/org/onosproject/calendar/BandwidthCalendarResource.java
@@ -231,12 +231,14 @@
             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);
         }
     }
 
diff --git a/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
index 7407258..3478754 100644
--- a/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
+++ b/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
@@ -214,7 +214,8 @@
                 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 @@
                 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() {
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
index 4fcf131..a4a3a7c 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
@@ -57,7 +57,7 @@
         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());
     }
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java b/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
index 577743a..7de49c9 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
@@ -1,15 +1,11 @@
 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.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 @@
 
         MplsIntent intent = new MplsIntent(appId(), selector, treatment,
                                            ingress, ingressLabel, egress,
-                                           egressLabel, constraints);
+                                           egressLabel, constraints,
+                                           priority());
         service.submit(intent);
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
index d9a1feb..9b00512 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
@@ -52,7 +52,8 @@
         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 @@
                             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 @@
      * @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 @@
      * @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);
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
index d7f8535..524b231 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
@@ -49,7 +49,8 @@
                               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 @@
      * @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 @@
                               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 @@
         this.ingressLabel = null;
         this.egressPoint = null;
         this.egressLabel = null;
-
     }
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
index 2102dba..83e9218 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
@@ -39,7 +39,7 @@
             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 @@
      * @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);
diff --git a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
index 118e137..ee95255 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
@@ -41,7 +41,7 @@
     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 @@
         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 @@
                            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 @@
      * @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 @@
      * @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);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
index 89fd331..948dbd6 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
@@ -78,7 +78,8 @@
         return new MplsPathIntent(intent.appId(),
                               intent.selector(), intent.treatment(), path,
                               intent.ingressLabel(), intent.egressLabel(),
-                              intent.constraints());
+                              intent.constraints(),
+                              intent.priority());
     }
 
 
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
index af603d5..a879236 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
@@ -51,11 +51,11 @@
                 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()));
 
     }
 }
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
index a0e635f..8001eed 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
@@ -74,7 +74,8 @@
                 new DefaultPath(PID, links, hops),
                 ingressLabel,
                 egressLabel,
-                ImmutableList.of());
+                ImmutableList.of(),
+                55);
     }
 
     /**