Add keys to intents
- use Key class rather than String for intent keys
- add CLI option to specify a string key
- add key field to constructors for connectivity intents
- translate id into a key if no key is specified
Change-Id: I69ffbad93bc3daddf06a67cb0cffa2130e781b37
diff --git a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
index d0633e6..a8a28e2 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -28,6 +28,7 @@
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.constraint.LinkTypeConstraint;
@@ -81,6 +82,10 @@
required = false, multiValued = false)
private boolean lambda = false;
+ @Option(name = "-k", aliases = "--key", description = "Intent Key",
+ required = false, multiValued = false)
+ private String intentKey = null;
+
// Treatments
@Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
@@ -180,4 +185,19 @@
return constraints;
}
+
+ /**
+ * Creates a key for an intent based on command line arguments. If a key
+ * has been specified, it is returned. If no key is specified, null
+ * is returned.
+ *
+ * @return intent key if specified, null otherwise
+ */
+ protected Key key() {
+ Key key = null;
+ if (intentKey != null) {
+ key = Key.of(intentKey, appId());
+ }
+ return key;
+ }
}