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/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
index 31d4337..3312587 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
@@ -40,6 +40,37 @@
/**
* Creates a new point-to-point intent with the supplied ingress/egress
+ * ports and constraints.
+ *
+ * @param appId application identifier
+ * @param key key of the intent
+ * @param selector traffic selector
+ * @param treatment treatment
+ * @param ingressPoint ingress port
+ * @param egressPoint egress port
+ * @param constraints optional list of constraints
+ * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
+ */
+ public PointToPointIntent(ApplicationId appId,
+ Key key,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ ConnectPoint ingressPoint,
+ ConnectPoint egressPoint,
+ List<Constraint> constraints) {
+ super(appId, key, Collections.emptyList(), selector, treatment, constraints);
+
+ checkNotNull(ingressPoint);
+ checkNotNull(egressPoint);
+ checkArgument(!ingressPoint.equals(egressPoint),
+ "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);
+
+ this.ingressPoint = ingressPoint;
+ this.egressPoint = egressPoint;
+ }
+
+ /**
+ * Creates a new point-to-point intent with the supplied ingress/egress
* ports and with built-in link type constraint to avoid optical links.
*
* @param appId application identifier
@@ -53,7 +84,7 @@
TrafficTreatment treatment,
ConnectPoint ingressPoint,
ConnectPoint egressPoint) {
- this(appId, selector, treatment, ingressPoint, egressPoint,
+ this(appId, null, selector, treatment, ingressPoint, egressPoint,
ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
}
@@ -74,7 +105,7 @@
ConnectPoint ingressPoint,
ConnectPoint egressPoint,
List<Constraint> constraints) {
- super(appId, Collections.emptyList(), selector, treatment, constraints);
+ super(appId, null, Collections.emptyList(), selector, treatment, constraints);
checkNotNull(ingressPoint);
checkNotNull(egressPoint);