blob: 1840c0dd5eca75cee055243ccf9610b932f1cda0 [file] [log] [blame]
Brian O'Connora4cab072014-10-03 18:46:39 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onlab.onos.cli.AbstractShellCommand;
6import org.onlab.onos.net.intent.Intent;
7import org.onlab.onos.net.intent.IntentId;
8import org.onlab.onos.net.intent.IntentService;
9
10/**
11 * Removes host-to-host connectivity intent.
12 */
13@Command(scope = "onos", name = "remove-host-intent",
14 description = "Removes host-to-host connectivity intent")
15public class RemoveHostToHostIntentCommand extends AbstractShellCommand {
16
17 @Argument(index = 0, name = "id", description = "Intent ID",
18 required = true, multiValued = false)
19 String id = null;
20
21 @Override
22 protected void execute() {
23 IntentService service = get(IntentService.class);
24
25 int radix = id.startsWith("0x") ? 16 : 10;
26 if (radix == 16) {
27 id = id.replaceFirst("0x", "");
28 }
29 IntentId intentId = new IntentId(Long.parseLong(id, radix));
30
31
32 Intent intent = service.getIntent(intentId);
33 if (intent != null) {
34 service.withdraw(intent);
35 }
36 }
37}