Fixing FlowRule priority in intent compilers
Change-Id: I13998e88d2a116017e87c019f4829101db6c6b6b
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
index cd7200a..76c5736 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
@@ -24,7 +24,6 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
@@ -123,9 +122,14 @@
treatment = defaultTreatment;
}
- DefaultFlowRule rule = new DefaultFlowRule(deviceId, selector, treatment, 123, appId,
- new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 0, true, null);
-
+ FlowRule rule = DefaultFlowRule.builder()
+ .forDevice(deviceId)
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .withPriority(intent.priority())
+ .fromApp(appId)
+ .makePermanent()
+ .build();
rules.add(rule);
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index 62e526f..926b8e1 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -188,13 +188,13 @@
// Create optical circuit intent
List<FlowRule> rules = new LinkedList<>();
- rules.add(connectPorts(src, connIntent.getSrc()));
- rules.add(connectPorts(connIntent.getDst(), dst));
+ rules.add(connectPorts(src, connIntent.getSrc(), intent.priority()));
+ rules.add(connectPorts(connIntent.getDst(), dst, intent.priority()));
// Create flow rules for reverse path
if (intent.isBidirectional()) {
- rules.add(connectPorts(connIntent.getSrc(), src));
- rules.add(connectPorts(dst, connIntent.getDst()));
+ rules.add(connectPorts(connIntent.getSrc(), src, intent.priority()));
+ rules.add(connectPorts(dst, connIntent.getDst(), intent.priority()));
}
circuitIntent = new FlowRuleIntent(appId, rules, intent.resources());
@@ -348,7 +348,7 @@
* @param dst destination port
* @return flow rules
*/
- private FlowRule connectPorts(ConnectPoint src, ConnectPoint dst) {
+ private FlowRule connectPorts(ConnectPoint src, ConnectPoint dst, int priority) {
checkArgument(src.deviceId().equals(dst.deviceId()));
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
@@ -363,7 +363,7 @@
.forDevice(src.deviceId())
.withSelector(selectorBuilder.build())
.withTreatment(treatmentBuilder.build())
- .withPriority(100)
+ .withPriority(priority)
.fromApp(appId)
.makePermanent()
.build();
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
index 4cc93bb..61a2ac7 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java
@@ -111,7 +111,7 @@
.forDevice(current.deviceId())
.withSelector(selectorBuilder.build())
.withTreatment(treatmentBuilder.build())
- .withPriority(100)
+ .withPriority(intent.priority())
.fromApp(appId)
.makePermanent()
.build();
@@ -132,7 +132,7 @@
.forDevice(intent.dst().deviceId())
.withSelector(selectorBuilder.build())
.withTreatment(treatmentLast.build())
- .withPriority(100)
+ .withPriority(intent.priority())
.fromApp(appId)
.makePermanent()
.build();
@@ -163,7 +163,7 @@
.forDevice(current.deviceId())
.withSelector(selectorBuilder.build())
.withTreatment(treatmentBuilder.build())
- .withPriority(100)
+ .withPriority(intent.priority())
.fromApp(appId)
.makePermanent()
.build();
@@ -184,7 +184,7 @@
.forDevice(intent.src().deviceId())
.withSelector(selectorBuilder.build())
.withTreatment(treatmentLast.build())
- .withPriority(100)
+ .withPriority(intent.priority())
.fromApp(appId)
.makePermanent()
.build();
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
index 90e3981..7add217 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
@@ -76,7 +76,9 @@
for (int i = 0; i < links.size() - 1; i++) {
ConnectPoint ingress = links.get(i).dst();
ConnectPoint egress = links.get(i + 1).src();
- FlowRule rule = createFlowRule(intent.selector(), intent.treatment(), ingress, egress, isLast(links, i));
+ FlowRule rule = createFlowRule(intent.selector(), intent.treatment(),
+ ingress, egress, intent.priority(),
+ isLast(links, i));
rules.add(rule);
}
@@ -84,7 +86,8 @@
}
private FlowRule createFlowRule(TrafficSelector originalSelector, TrafficTreatment originalTreatment,
- ConnectPoint ingress, ConnectPoint egress, boolean last) {
+ ConnectPoint ingress, ConnectPoint egress,
+ int priority, boolean last) {
TrafficSelector selector = DefaultTrafficSelector.builder(originalSelector)
.matchInPort(ingress.port())
.build();
@@ -101,7 +104,7 @@
.forDevice(ingress.deviceId())
.withSelector(selector)
.withTreatment(treatment)
- .withPriority(123)
+ .withPriority(priority)
.fromApp(appId)
.makePermanent()
.build();