WIP: Refactoring the Intent REST API.
NOTE: All changes are Work-in-Progress, and they are in the process
of being actively updated and refactored.
* The new implementation is in onos/core/intent/runtime/web
The old implementation in the onos/core/datagrid/web is kept until
the refactoring is completed.
* The new REST API base path is /wm/onos/intent
* The initial set of (new) APIs is the following:
- /wm/onos/intent/high
GET all high-level intent
POST (create) a collection of high-level intents
DELETE all intents
- /wm/onos/intent/high/{intent-id}
GET a high-level intent object
DELETE a high-level intent object
- /wm/onos/intent/low
GET all low-level intents
- /wm/onos/intent/low/{intent-id}
GET a low-level intent object
- /wm/onos/intent/path/switch/{src-dpid}/shortest-path/{dst-dpid}
GET a Shortest Path between two Switch DPIDs
* The Application-Level Intent object is specified in class
onos/api/intent/ApplicationIntent.java
TODO (list incomplete):
- Return the appropriate REST codes and return values for each REST operation
- Add the appropriate Java APIs so each REST call would make a single
Java call.
- If necessary, rename API class ApplicationIntent to something more
appropriate, and use it in the Java API.
- Re-think/refactor the ApplicationIntent so it becomes a more solid base for
all (high-level) intents.
- The corresponding Java APIs for each REST call should be synchronous
(for some definition of the expected operation outcome).
- Implement intent/intents Java API delete operation that requires a
single call instead of two calls (delete and purge)
- Refactor the High and Low Level intents, such that they don't use
inheritance from a common base class.
- Cleanup the return Intent objects representation in JSON. E.g.,
the Dpid JSON should be just "dpid": <value> instead of
"dpid": {
"value": <value>
}
Change-Id: Ia994a2026f57a1f176c5321c1952325e3b986097
diff --git a/src/main/java/net/onrc/onos/api/intent/ApplicationIntent.java b/src/main/java/net/onrc/onos/api/intent/ApplicationIntent.java
new file mode 100644
index 0000000..113e6cd
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/intent/ApplicationIntent.java
@@ -0,0 +1,216 @@
+package net.onrc.onos.api.intent;
+
+/**
+ * An object used by the application to specify an intent.
+ */
+public class ApplicationIntent {
+ private String intentId; // The Intent ID
+ private String intentType; // The Intent type
+
+ // If true, don't update the path when topology changes
+ private boolean isStaticPath;
+
+ private String srcSwitchDpid; // Flow Path Source Switch DPID
+ private int srcSwitchPort; // Flow Path Source Switch Port
+ private String dstSwitchDpid; // Flow Path Destination Switch DPID
+ private int dstSwitchPort; // Flow Path Destination Switch Port
+ private double bandwidth; // Bandwidth for Constrained Shortest Path
+
+ // Matching Fields
+ private String matchSrcMac; // Matching source MAC address
+ private String matchDstMac; // Matching destination MAC address
+
+ /**
+ * Gets the Intent ID.
+ *
+ * @return the Intent ID.
+ */
+ public String intentId() {
+ return this.intentId;
+ }
+
+ /**
+ * Sets the Intent ID.
+ *
+ * @param intentId the Intent ID to set.
+ */
+ public void setIntentId(String intentId) {
+ this.intentId = intentId;
+ }
+
+ /**
+ * Gets the Intent type.
+ *
+ * Currently, the following strings are recognized:
+ * - "SHORTEST_PATH"
+ * - "CONSTRAINED_SHORTEST_PATH"
+ *
+ * @return the Intent type.
+ */
+ public String intentType() {
+ return this.intentType;
+ }
+
+ /**
+ * Sets the Intent type.
+ *
+ * Currently, the following strings are recognized:
+ * - "SHORTEST_PATH"
+ * - "CONSTRAINED_SHORTEST_PATH"
+ *
+ * @param intentType the Intent type to set.
+ */
+ public void setIntentType(String intentType) {
+ this.intentType = intentType;
+ }
+
+ /**
+ * Gets the "staticPath" flag for the intent.
+ *
+ * A path for an intent is defined as "static" if it shouldn't be updated
+ * when the topology changes.
+ *
+ * @return true if the intent path is static, otherwise false.
+ */
+ public boolean isStaticPath() {
+ return this.isStaticPath;
+ }
+
+ /**
+ * Sets the "staticPath" flag for the intent.
+ *
+ * A path for an intent is defined as "static" if it shouldn't be updated
+ * when the topology changes.
+ *
+ * @param staticPath true if the intent path is static, otherwise false.
+ */
+ public void setStaticPath(boolean staticPath) {
+ this.isStaticPath = staticPath;
+ }
+
+ /**
+ * Gets the Source Switch DPID.
+ *
+ * @return the Source Switch DPID.
+ */
+ public String srcSwitchDpid() {
+ return this.srcSwitchDpid;
+ }
+
+ /**
+ * Sets the Source Switch DPID.
+ *
+ * @param srcSwitchDpid the Source Switch DPID to set.
+ */
+ public void setSrcSwitchDpid(String srcSwitchDpid) {
+ this.srcSwitchDpid = srcSwitchDpid;
+ }
+
+ /**
+ * Gets the Source Switch Port.
+ *
+ * @return the Source Switch Port.
+ */
+ public int srcSwitchPort() {
+ return this.srcSwitchPort;
+ }
+
+ /**
+ * Sets the Source Switch Port.
+ *
+ * @param srcSwitchPort the Source Switch Port to set.
+ */
+ public void setSrcSwitchPort(int srcSwitchPort) {
+ this.srcSwitchPort = srcSwitchPort;
+ }
+
+ /**
+ * Gets the Destination Switch DPID.
+ *
+ * @return the Destination Switch DPID.
+ */
+ public String dstSwitchDpid() {
+ return this.dstSwitchDpid;
+ }
+
+ /**
+ * Sets the Destination Switch DPID.
+ *
+ * @param dstSwitchDpid the Destination Switch DPID to set.
+ */
+ public void setDstSwitchDpid(String dstSwitchDpid) {
+ this.dstSwitchDpid = dstSwitchDpid;
+ }
+
+ /**
+ * Gets the Destination Switch Port.
+ *
+ * @return the Destination Switch Port.
+ */
+ public int dstSwitchPort() {
+ return this.dstSwitchPort;
+ }
+
+ /**
+ * Sets the Destination Switch Port.
+ *
+ * @param dstSwitchPort the Destination Switch Port to set.
+ */
+ public void setDstSwitchPort(int dstSwitchPort) {
+ this.dstSwitchPort = dstSwitchPort;
+ }
+
+ /**
+ * Gets the bandwidth for Constrained Shortest Path.
+ *
+ * @return the bandwidth for Constrained Shortest Path.
+ */
+ public double bandwidth() {
+ return this.bandwidth;
+ }
+
+ /**
+ * Sets the bandwidth for Constrained Shortest Path.
+ *
+ * @param bandwidth the bandwidth for Constrained Shortest Path
+ */
+ public void setBandwidth(double bandwidth) {
+ this.bandwidth = bandwidth;
+ }
+
+ /**
+ * Gets the matching source MAC address.
+ *
+ * @return the matching source MAC address.
+ */
+ public String matchSrcMac() {
+ return this.matchSrcMac;
+ }
+
+ /**
+ * Sets the matching source MAC address.
+ *
+ * @param matchSrcMac the matching source MAC address to set.
+ */
+ public void setMatchSrcMac(String matchSrcMac) {
+ this.matchSrcMac = matchSrcMac;
+ }
+
+ /**
+ * Gets the matching destination MAC address.
+ *
+ * @return the matching destination MAC address.
+ */
+ public String matchDstMac() {
+ return this.matchDstMac;
+ }
+
+ /**
+ * Sets the matching destination MAC address.
+ *
+ * @param matchDstMac the matching destination MAC address to set.
+ */
+ public void setMatchDstMac(String matchDstMac) {
+ this.matchDstMac = matchDstMac;
+ }
+}