ONOS-5810 provide a way to consume protected links
- Add option to add constraint to use protected link only
Change-Id: Id4684b839b02f3b46583d524289ce238e78d92e1
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
index b2b4b82..f1944ce 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
@@ -25,6 +25,8 @@
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.PointToPointIntent;
+import org.onosproject.net.intent.constraint.ProtectedConstraint;
+
import static org.onosproject.net.intent.constraint.ProtectionConstraint.protection;
import java.util.List;
@@ -46,12 +48,25 @@
required = true, multiValued = false)
String egressDeviceString = null;
+
+ /**
+ * Option to produce protected path.
+ * @deprecated in 1.9.0
+ */
// -p already defined in ConnectivityIntentCommand
+ @Deprecated
@Option(name = "-r", aliases = "--protect",
- description = "Utilize path protection",
+ description = "(deprecated) Utilize path protection",
required = false, multiValued = false)
private boolean backup = false;
+ /**
+ * Option to consume protected path.
+ */
+ @Option(name = "--useProtected",
+ description = "use protected links only")
+ private boolean useProtected = false;
+
@Override
protected void execute() {
IntentService service = get(IntentService.class);
@@ -68,6 +83,10 @@
constraints.add(protection());
}
+ if (useProtected) {
+ constraints.add(ProtectedConstraint.useProtectedLink());
+ }
+
Intent intent = PointToPointIntent.builder()
.appId(appId())
.key(key())