ONOS-1058 - Add application Id to intent withdraw command
Change-Id: I6f660f2e115e4acc9d3c7d1ab2e2115caaf1822f
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
index 3b05b7e..de6984f 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
@@ -18,6 +18,8 @@
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.Key;
@@ -25,28 +27,44 @@
import java.math.BigInteger;
/**
- * Removes host-to-host connectivity intent.
+ * Removes an intent.
*/
@Command(scope = "onos", name = "remove-intent",
description = "Removes the specified intent")
public class IntentRemoveCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "id", description = "Intent ID",
+ @Argument(index = 0, name = "app",
+ description = "Application ID",
+ required = true, multiValued = false)
+ String applicationIdString = null;
+
+ @Argument(index = 1, name = "id",
+ description = "Intent ID",
required = true, multiValued = false)
String id = null;
@Override
protected void execute() {
- IntentService service = get(IntentService.class);
+ IntentService intentService = get(IntentService.class);
+ CoreService coreService = get(CoreService.class);
+
+ ApplicationId appId = appId();
+ if (applicationIdString != null) {
+ appId = coreService.getAppId(applicationIdString);
+ if (appId == null) {
+ print("Cannot find application Id %s", applicationIdString);
+ return;
+ }
+ }
if (id.startsWith("0x")) {
id = id.replaceFirst("0x", "");
}
- Key key = Key.of(new BigInteger(id, 16).longValue(), appId());
- Intent intent = service.getIntent(key);
+ Key key = Key.of(new BigInteger(id, 16).longValue(), appId);
+ Intent intent = intentService.getIntent(key);
if (intent != null) {
- service.withdraw(intent);
+ intentService.withdraw(intent);
}
}
}