Use marker in ProtectedTransportIntentCompiler
- for ONOS-5827
Example:
onos> intent-details
Key: 0x9 ID: 0x9
Request: INSTALL_REQ Current: INSTALLED
intent: ProtectedTransportIntent{id=0x9, key=0x9, appId=3-org.onosproject.cli, priority=100, treatment={immediate=[NOACTION], transition=None, meter=None, cleared=false, metadata=null}, one=of:000000000000000d, two=of:000000000000000e}
installable: FlowRuleIntent 0x10
resources: protection1, fwd
links: of:000000000000000d/7 -> of:000000000000000a/3, of:000000000000000a/4 -> of:000000000000000e/3
installable: FlowRuleIntent 0x11
resources: protection1, rev
links: of:000000000000000e/3 -> of:000000000000000a/4, of:000000000000000a/3 -> of:000000000000000d/7
installable: FlowRuleIntent 0x12
resources: protection2, fwd
links: of:000000000000000d/2 -> of:0000000000000005/6, of:0000000000000005/9 -> of:000000000000000e/2
installable: FlowRuleIntent 0x13
resources: protection2, rev
links: of:000000000000000e/2 -> of:0000000000000005/9, of:0000000000000005/6 -> of:000000000000000d/2
installable: ProtectionEndpointIntent 0xa
resources:
links:
installable: ProtectionEndpointIntent 0xb
resources:
links:
Change-Id: I7d2411346a11c2550490c3b77353feb5e6067b1d
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
index 52c6dee..94d1138 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ProtectedTransportIntentCompiler.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Lists.transform;
import static java.util.stream.Stream.concat;
+import static org.onosproject.net.MarkerResource.marker;
import static org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription.buildDescription;
import static org.slf4j.LoggerFactory.getLogger;
@@ -76,6 +77,17 @@
public class ProtectedTransportIntentCompiler
extends ConnectivityIntentCompiler<ProtectedTransportIntent> {
+ /**
+ * Marker value for forward path.
+ */
+ private static final String FWD = "fwd";
+
+ /**
+ * Marker value for reverse path.
+ */
+ private static final String REV = "rev";
+
+
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -232,10 +244,13 @@
// Build transit intent for primary/secondary path
+ Collection<NetworkResource> resources1 = ImmutableList.of(marker("protection1"));
+ Collection<NetworkResource> resources2 = ImmutableList.of(marker("protection2"));
+
ImmutableList<Intent> result = ImmutableList.<Intent>builder()
// LinkCollection for primary and backup paths
- .addAll(createTransitIntent(intent, primary, primaryVlan))
- .addAll(createTransitIntent(intent, secondary, secondaryVlan))
+ .addAll(createTransitIntent(intent, primary, primaryVlan, resources1))
+ .addAll(createTransitIntent(intent, secondary, secondaryVlan, resources2))
.add(oneIntent)
.add(twoIntent)
.build();
@@ -249,16 +264,29 @@
* @param intent parent IntentId
* @param path whole path
* @param vid VlanId to use as tunnel labels
+ * @param resources to be passed down to generated Intents
* @return List on transit Intents, if any is required.
*/
- List<LinkCollectionIntent> createTransitIntent(Intent intent, Path path, VlanId vid) {
+ List<LinkCollectionIntent> createTransitIntent(Intent intent,
+ Path path,
+ VlanId vid,
+ Collection<NetworkResource> resources) {
if (path.links().size() <= 1) {
// There's no need for transit Intents
return ImmutableList.of();
}
- return ImmutableList.of(createSubTransitIntent(intent, path, vid),
- createSubTransitIntent(intent, reverse(path), vid));
+ Collection<NetworkResource> fwd = ImmutableList.<NetworkResource>builder()
+ .addAll(resources)
+ .add(marker(FWD))
+ .build();
+ Collection<NetworkResource> rev = ImmutableList.<NetworkResource>builder()
+ .addAll(resources)
+ .add(marker(REV))
+ .build();
+
+ return ImmutableList.of(createSubTransitIntent(intent, path, vid, fwd),
+ createSubTransitIntent(intent, reverse(path), vid, rev));
}
/**
@@ -300,9 +328,13 @@
* @param intent parent IntentId
* @param path whole path
* @param vid VlanId to use as tunnel labels
- * @return List on transit Intents, if any is required.
+ * @param resources to be passed down to generated Intents
+ * @return List of transit Intents, if any is required.
*/
- LinkCollectionIntent createSubTransitIntent(Intent intent, Path path, VlanId vid) {
+ LinkCollectionIntent createSubTransitIntent(Intent intent,
+ Path path,
+ VlanId vid,
+ Collection<NetworkResource> resources) {
checkArgument(path.links().size() > 1);
// transit ingress/egress
@@ -319,6 +351,7 @@
// VLAN tunnel
//.selector(DefaultTrafficSelector.builder().matchVlanId(vid).build())
//.treatment(intent.treatment())
+ .resources(resources)
.links(ImmutableSet.copyOf(path.links()))
.filteredIngressPoints(ImmutableSet.of(vlanPort(one, vid)))
.filteredEgressPoints(ImmutableSet.of(vlanPort(two, vid)))