Inherit Intent Key on compilation
- Added Intent#key() method description
- Inherit key field from parent Intent during Intent
compilation process
- Added assertion to existing unit tests
Change-Id: Iff85c5ec448b3f378957b7a20af865ad96cc3216
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
index 427d56d..dad8e3b 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
@@ -122,6 +122,7 @@
.matchEthSrc(src.mac()).matchEthDst(dst.mac()).build();
return PathIntent.builder()
.appId(intent.appId())
+ .key(intent.key())
.selector(selector)
.treatment(intent.treatment())
.path(path)
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 d93764b..969372d 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
@@ -123,7 +123,7 @@
labels)
);
}
- return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources()));
+ return Collections.singletonList(new FlowRuleIntent(appId, intent.key(), rules, intent.resources()));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
index 0a15097..6a0081f 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
@@ -119,7 +119,7 @@
});
}
return Collections.singletonList(
- new FlowObjectiveIntent(appId, devices, objectives, intent.resources()));
+ new FlowObjectiveIntent(appId, intent.key(), devices, objectives, intent.resources()));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
index 9c4f535..9c84853 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
@@ -94,7 +94,10 @@
Map<LinkKey, MplsLabel> labels = assignMplsLabel(intent);
List<FlowRule> rules = generateRules(intent, labels);
- return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources()));
+ return Collections.singletonList(new FlowRuleIntent(appId,
+ intent.key(),
+ rules,
+ intent.resources()));
}
@Activate
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index f9b236f..cac5d68 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -119,6 +119,7 @@
Intent result = LinkCollectionIntent.builder()
.appId(intent.appId())
+ .key(intent.key())
.treatment(intent.treatment())
.selector(intent.selector())
.links(Sets.newHashSet(links.values()))
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 f719a00..a2c26dd 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
@@ -83,7 +83,12 @@
List<DeviceId> devices = new LinkedList<>();
compile(this, intent, rules, devices);
- return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources(), intent.type()));
+
+ return ImmutableList.of(new FlowRuleIntent(appId,
+ intent.key(),
+ rules,
+ intent.resources(),
+ intent.type()));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
index 3f0fc19..521d6fc 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
@@ -89,7 +89,11 @@
List<DeviceId> devices = new LinkedList<>();
compile(this, intent, objectives, devices);
- return ImmutableList.of(new FlowObjectiveIntent(appId, devices, objectives, intent.resources()));
+ return ImmutableList.of(new FlowObjectiveIntent(appId,
+ intent.key(),
+ devices,
+ objectives,
+ intent.resources()));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
index 02b8865..a6fac6f 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
@@ -256,6 +256,7 @@
createFailoverTreatmentGroup(path.links(), path.backup().links(), intent);
FlowRuleIntent frIntent = new FlowRuleIntent(intent.appId(),
+ intent.key(),
createFailoverFlowRules(intent),
asList(ingressPoint.deviceId()),
PathIntent.ProtectionType.FAILOVER);
@@ -312,6 +313,7 @@
PathIntent.ProtectionType type) {
return PathIntent.builder()
.appId(intent.appId())
+ .key(intent.key())
.selector(intent.selector())
.treatment(intent.treatment())
.path(path)