aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/cli
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/cli')
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java28
-rw-r--r--framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml5
3 files changed, 61 insertions, 14 deletions
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
index fbce9648..713b4b5a 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -26,6 +26,7 @@ import org.onlab.util.Bandwidth;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
+import org.onosproject.net.EncapsulationType;
import org.onosproject.net.Link;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -36,10 +37,10 @@ import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
+import org.onosproject.net.intent.constraint.EncapsulationConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.constraint.LinkTypeConstraint;
import org.onosproject.net.intent.constraint.PartialFailureConstraint;
-import org.onosproject.net.resource.link.BandwidthResource;
import java.util.LinkedList;
import java.util.List;
@@ -117,14 +118,6 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
required = false, multiValued = true)
private List<String> extHdrStringList = null;
- @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
- required = false, multiValued = false)
- private String bandwidthString = null;
-
- @Option(name = "-l", aliases = "--lambda", description = "Lambda",
- required = false, multiValued = false)
- private boolean lambda = false;
-
@Option(name = "-a", aliases = "--appId", description = "Application Id",
required = false, multiValued = false)
private String appId = null;
@@ -133,10 +126,6 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
required = false, multiValued = false)
private String intentKey = null;
- @Option(name = "--partial", description = "Allow partial installation",
- required = false, multiValued = false)
- private boolean partial = false;
-
// Treatments
@Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
@@ -177,6 +166,24 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
required = false, multiValued = false)
private int priority = Intent.DEFAULT_INTENT_PRIORITY;
+ // Constraints
+ @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
+ required = false, multiValued = false)
+ private String bandwidthString = null;
+
+ @Option(name = "-l", aliases = "--lambda", description = "Lambda",
+ required = false, multiValued = false)
+ private boolean lambda = false;
+
+ @Option(name = "--partial", description = "Allow partial installation",
+ required = false, multiValued = false)
+ private boolean partial = false;
+
+ @Option(name = "-e", aliases = "--encapsulation", description = "Encapsulation type",
+ required = false, multiValued = false)
+ private String encapsulationString = null;
+
+
/**
* Constructs a traffic selector based on the command line arguments
* presented to the command.
@@ -365,7 +372,7 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
// Check for a bandwidth specification
if (!isNullOrEmpty(bandwidthString)) {
final Bandwidth bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
- constraints.add(new BandwidthConstraint(new BandwidthResource(bandwidth)));
+ constraints.add(new BandwidthConstraint(bandwidth));
}
// Check for a lambda specification
@@ -374,10 +381,17 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
}
constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL));
+ // Check for partial failure specification
if (partial) {
constraints.add(new PartialFailureConstraint());
}
+ // Check for encapsulation specification
+ if (!isNullOrEmpty(encapsulationString)) {
+ final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
+ constraints.add(new EncapsulationConstraint(encapType));
+ }
+
return constraints;
}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java
new file mode 100644
index 00000000..b14615d4
--- /dev/null
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java
@@ -0,0 +1,28 @@
+package org.onosproject.cli.net;
+
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onosproject.net.EncapsulationType;
+
+import java.util.List;
+import java.util.SortedSet;
+
+/**
+ * Encapsulation type completer.
+ */
+public class EncapTypeCompleter implements Completer {
+
+ @Override
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ // Delegate string completer
+ StringsCompleter delegate = new StringsCompleter();
+ SortedSet<String> strings = delegate.getStrings();
+
+ for (EncapsulationType encapType : EncapsulationType.values()) {
+ strings.add(encapType.toString());
+ }
+
+ // Now let the completer do the work for figuring out what to offer.
+ return delegate.complete(buffer, cursor, candidates);
+ }
+}
diff --git a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 9bd5dd9f..1f350c5b 100644
--- a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -201,6 +201,7 @@
<entry key="--icmp6Code" value-ref="Icmp6CodeCompleter"/>
<entry key="--extHdr" value-ref="ExtHeaderCompleter"/>
<entry key="-a" value-ref="allAppNameCompleter"/>
+ <entry key="-e" value-ref="encapTypeCompleter"/>
</optional-completers>
</command>
<command>
@@ -216,6 +217,7 @@
<entry key="--icmp6Code" value-ref="Icmp6CodeCompleter"/>
<entry key="--extHdr" value-ref="ExtHeaderCompleter"/>
<entry key="-a" value-ref="allAppNameCompleter"/>
+ <entry key="-e" value-ref="encapTypeCompleter"/>
</optional-completers>
</command>
<command>
@@ -252,6 +254,7 @@
<entry key="--icmp6Code" value-ref="Icmp6CodeCompleter"/>
<entry key="--extHdr" value-ref="ExtHeaderCompleter"/>
<entry key="-a" value-ref="allAppNameCompleter"/>
+ <entry key="-e" value-ref="encapTypeCompleter"/>
</optional-completers>
</command>
<command>
@@ -266,6 +269,7 @@
<entry key="--icmp6Code" value-ref="Icmp6CodeCompleter"/>
<entry key="--extHdr" value-ref="ExtHeaderCompleter"/>
<entry key="-a" value-ref="allAppNameCompleter"/>
+ <entry key="-e" value-ref="encapTypeCompleter"/>
</optional-completers>
</command>
<command>
@@ -499,5 +503,6 @@
<bean id="startStopCompleter" class="org.onosproject.cli.StartStopCompleter"/>
<bean id="metricNameCompleter" class="org.onosproject.cli.MetricNameCompleter"/>
<bean id="upDownCompleter" class="org.onosproject.cli.UpDownCompleter"/>
+ <bean id="encapTypeCompleter" class="org.onosproject.cli.net.EncapTypeCompleter"/>
</blueprint>