Fix completers for CFM app CLI

Change-Id: Ib558d5fa26b8b99f0529cabac1848f74ca99004f
diff --git a/apps/cfm/nbi/BUILD b/apps/cfm/nbi/BUILD
index c28e664..d86f380 100644
--- a/apps/cfm/nbi/BUILD
+++ b/apps/cfm/nbi/BUILD
@@ -13,6 +13,10 @@
     api_title = "L2 Monitoring CFM",
     api_version = "1.0",
     exclude_tests = ["org/onosproject/cfm/impl/CfmResourceTest"],
+    karaf_command_packages = [
+        "org.onosproject.cfm.cli",
+        "org.onosproject.cfm.cli.completer",
+    ],
     test_deps = TEST_DEPS,
     web_context = "/onos/cfm",
     deps = COMPILE_DEPS,
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaAddCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaAddCommand.java
index 911510e..3f16c77 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaAddCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaAddCommand.java
@@ -17,9 +17,14 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onlab.packet.VlanId;
+import org.onosproject.cfm.cli.completer.CfmMaCcmIntervalCompleter;
+import org.onosproject.cfm.cli.completer.CfmMaNameTypeCompleter;
+import org.onosproject.cfm.cli.completer.CfmMdNameCompleter;
 import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.cli.PlaceholderCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.Component;
 import org.onosproject.incubator.net.l2monitoring.cfm.DefaultComponent;
 import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation;
@@ -40,22 +45,26 @@
     @Argument(name = "name",
             description = "Maintenance Domain name and type (in brackets)",
             required = true)
+    @Completion(CfmMdNameCompleter.class)
     private String mdName = null;
 
     @Argument(index = 1, name = "name-type",
-            description = "Maintenance Assocation name type",
+            description = "Maintenance Association name type",
             required = true)
+    @Completion(CfmMaNameTypeCompleter.class)
     private String nameType = null;
 
     @Argument(index = 2, name = "name",
             description = "Maintenance Assocation name. Restrictions apply depending " +
                     "on name-type",
             required = true)
+    @Completion(PlaceholderCompleter.class)
     private String name = null;
 
     @Argument(index = 3, name = "ccm-interval",
             description = "CCM Interval values from list",
             required = true)
+    @Completion(CfmMaCcmIntervalCompleter.class)
     private String ccmInterval = null;
 
     @Argument(index = 4, name = "numeric-id",
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaDeleteCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaDeleteCommand.java
index 31cdcb4..6e0943e 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaDeleteCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMaDeleteCommand.java
@@ -17,7 +17,9 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmMaNameCompleter;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
 import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
@@ -37,6 +39,7 @@
             description = "Maintenance Domain name and type (in brackets) " +
                     "and the Maintenance Association name and type (in brackets)",
             required = true)
+    @Completion(CfmMaNameCompleter.class)
     private String name = null;
 
     @Override
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdAddCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdAddCommand.java
index 2b5a2bf..5c7cc91 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdAddCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdAddCommand.java
@@ -17,8 +17,12 @@
 
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmMdLevelCompleter;
+import org.onosproject.cfm.cli.completer.CfmMdNameTypeCompleter;
 import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.cli.PlaceholderCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain;
 import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain;
 import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
@@ -36,21 +40,25 @@
     @Argument(name = "name-type",
             description = "Maintenance Domain name type",
             required = true)
+    @Completion(CfmMdNameTypeCompleter.class)
     private String nameType = null;
 
     @Argument(index = 1, name = "name",
             description = "Maintenance Domain name. Restrictions apply depending " +
                     "on name-type. Leave empty if name type is none",
             required = true)
+    @Completion(PlaceholderCompleter.class)
     private String name = null;
 
     @Argument(index = 2, name = "level",
             description = "Maintenance Domain level LEVEL0-LEVEL7",
             required = true)
+    @Completion(CfmMdLevelCompleter.class)
     private String level = null;
 
     @Argument(index = 3, name = "numeric-id",
             description = "An optional numeric id for Maintenance Domain [1-65535]")
+    @Completion(PlaceholderCompleter.class)
     private Short numericId = null;
 
     @Override
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdDeleteCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdDeleteCommand.java
index 7cd07a1..3b48d41 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdDeleteCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdDeleteCommand.java
@@ -17,7 +17,9 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmMdNameCompleter;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
@@ -34,6 +36,7 @@
     @Argument(name = "name",
             description = "Maintenance Domain name and type (in brackets)",
             required = true)
+    @Completion(CfmMdNameCompleter.class)
     private String name = null;
 
     @Override
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
index 09bd807..be97f28 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
@@ -17,7 +17,9 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmMdNameCompleter;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation;
 import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain;
@@ -35,6 +37,7 @@
 public class CfmMdListMdCommand extends AbstractShellCommand {
     @Argument(name = "name",
             description = "Maintenance Domain name and type (in brackets)")
+    @Completion(CfmMdNameCompleter.class)
     private String name = null;
 
     @Override
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java
index f7c130f..23eed3e 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java
@@ -17,7 +17,9 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmMepIdCompleter;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.incubator.net.l2monitoring.cfm.MepEntry;
 import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
@@ -43,6 +45,7 @@
     private final Logger log = getLogger(getClass());
     @Argument(name = "md",
             description = "Maintenance Domain name and type (in brackets) - will use all MDs if not specified")
+    @Completion(CfmMepIdCompleter.class)
     private String mdStr = null;
     @Argument(index = 1, name = "ma",
             description = "Maintenance Association name and type (in brackets) - requires MD")
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java
index ca60a1c..bdff1e8 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java
@@ -17,7 +17,9 @@
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cfm.cli.completer.CfmDeviceIdCompleter;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.incubator.net.l2monitoring.cfm.Mep;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
@@ -34,6 +36,7 @@
     @Argument(name = "device",
             description = "Device Id",
             required = true)
+    @Completion(CfmDeviceIdCompleter.class)
     private String deviceStr = null;
 
     @Override
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompMhfCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompMhfCompleter.java
index 499b84d..2d5019b 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompMhfCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompMhfCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.Component;
 
@@ -24,6 +25,7 @@
 /**
  * CLI completer for Component MEP Half Function creation.
  */
+@Service
 public class CfmCompMhfCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompTagTypeCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompTagTypeCompleter.java
index d919780..b0c8dd3 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompTagTypeCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmCompTagTypeCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.Component;
 
@@ -24,6 +25,7 @@
 /**
  * CLI completer for Component TagType creation.
  */
+@Service
 public class CfmCompTagTypeCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaCcmIntervalCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaCcmIntervalCompleter.java
index 6599ed3..9a47323 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaCcmIntervalCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaCcmIntervalCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation;
 
@@ -24,6 +25,7 @@
 /**
  * CLI completer for Ccm Interval creation.
  */
+@Service
 public class CfmMaCcmIntervalCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaNameCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaNameCompleter.java
index 1463804..e1f6a6d 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaNameCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMaNameCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService;
 
@@ -26,6 +27,7 @@
 /**
  * CLI completer for MA Name creation.
  */
+@Service
 public class CfmMaNameCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdLevelCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdLevelCompleter.java
index 374e549..a006850 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdLevelCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdLevelCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain;
 
@@ -24,6 +25,7 @@
 /**
  * CLI completer for MD Level creation.
  */
+@Service
 public class CfmMdLevelCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdNameCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdNameCompleter.java
index 7a336e7..7badb1b 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdNameCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMdNameCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import static org.onosproject.cli.AbstractShellCommand.get;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService;
@@ -25,6 +26,7 @@
 /**
  * CLI completer for MD Name creation.
  */
+@Service
 public class CfmMdNameCompleter extends AbstractChoicesCompleter {
     @Override
     public List<String> choices() {
diff --git a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java
index a26a460..23aa324 100644
--- a/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java
+++ b/apps/cfm/nbi/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cfm.cli.completer;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.onosproject.cli.AbstractChoicesCompleter;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
 import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService;
@@ -30,6 +31,7 @@
 /**
  * CLI completer for Mep Id creation.
  */
+@Service
 public class CfmMepIdCompleter extends AbstractChoicesCompleter {
     private final Logger log = getLogger(getClass());
 
diff --git a/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java b/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java
index 537aa28..30ef054 100644
--- a/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java
+++ b/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.cli;
 
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.shell.api.console.CommandLine;
 import org.apache.karaf.shell.api.console.Session;
 import org.apache.karaf.shell.support.completers.StringsCompleter;
@@ -27,6 +28,7 @@
  * A completer that can be used as a placeholder for arguments that don't
  * need/want completers.
  */
+@Service
 public class PlaceholderCompleter extends AbstractCompleter {
 
     @Override