Adding Encapsulation in VPLS and correcting bugs.

Change-Id: Idc0c1834ae2bbd0fdaf564fd65360cc0f018d18d
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddCommand.java
index ffeb81f..b2c1da5 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddCommand.java
@@ -26,9 +26,9 @@
 /**
  * CLI to create VPLSs.
  */
-@Command(scope = "onos", name = "vpls-add", description = "Create a new VPLS")
+@Command(scope = "onos", name = "vpls-add", description = "Creates a new VPLS")
 public class VplsAddCommand extends AbstractShellCommand {
-    private static final String VPLS_EXIST = "VPLS already exists: %s";
+
     private VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
@@ -38,11 +38,12 @@
 
     @Override
     protected void execute() {
-
-        if (vplsConfigService.getAllVpls().contains(vplsName)) {
-            print(VPLS_EXIST, vplsName);
+        // Check if the VPLS name is already configured
+        if (VplsCommandUtils.vplsExists(vplsName)) {
+            print(VplsCommandUtils.VPLS_ALREADY_EXISTS, vplsName);
             return;
         }
-        vplsConfigService.addVpls(vplsName, new HashSet<>());
+
+        vplsConfigService.addVpls(vplsName, new HashSet<>(), null);
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddIfaceCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddIfaceCommand.java
index 5daaa9e..d6a50ff 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddIfaceCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsAddIfaceCommand.java
@@ -21,19 +21,14 @@
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.vpls.config.VplsConfigurationService;
 
-import java.util.Map;
-
 /**
  * CLI to add an interface to a VPLS.
  */
 @Command(scope = "onos", name = "vpls-add-iface",
-        description = "Add an interface to an existing VPLS")
+        description = "Adds an interface to an existing VPLS")
 public class VplsAddIfaceCommand extends AbstractShellCommand {
 
-    private static final String IFACE_ADD_FAIL = "Interface cannot be added.";
-    private static final String IFACE_EXIST =
-            "Interface %s already associated to network %s.";
-    private VplsConfigurationService vplsConfigService =
+    private static VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
     @Argument(index = 0, name = "vplsName", description = "Name of the VPLS",
@@ -46,24 +41,25 @@
 
     @Override
     protected void execute() {
-        if (!vplsConfigService.getAllVpls().contains(vplsName)) {
-            print(IFACE_ADD_FAIL);
+        // Check if the VPLS exists
+        if (!VplsCommandUtils.vplsExists(vplsName)) {
+            print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
             return;
         }
 
-        if (vplsConfigService.getAllInterfaces()
-                .stream()
-                .anyMatch(e -> e.name().equals(ifaceName))) {
-            print(IFACE_EXIST, ifaceName, vplsConfigService.getVplsNetworks()
-                    .entries()
-                    .stream()
-                    .filter(e->e.getValue().name().equals(ifaceName))
-                    .map(Map.Entry::getKey)
-                    .findFirst()
-                    .get());
+        // Check if the interface exists
+        if (!VplsCommandUtils.ifaceExists(ifaceName)) {
+            print(VplsCommandUtils.IFACE_NOT_FOUND, ifaceName);
             return;
         }
 
-        vplsConfigService.addInterfaceToVpls(vplsName, ifaceName);
+        // Check if the interface is already associated to a VPLS
+        if (VplsCommandUtils.ifaceAlreadyAssociated(ifaceName)) {
+            print(VplsCommandUtils.IFACE_ALREADY_ASSOCIATED,
+                  ifaceName, VplsCommandUtils.vplsNameFromIfaceName(ifaceName));
+            return;
+        }
+
+        vplsConfigService.addIface(vplsName, ifaceName);
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCleanCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCleanCommand.java
index 6507d6b..4156e08 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCleanCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCleanCommand.java
@@ -31,6 +31,6 @@
 
     @Override
     protected void execute() {
-        vplsConfigService.cleanVpls();
+        vplsConfigService.cleanVplsConfig();
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCommandUtils.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCommandUtils.java
new file mode 100644
index 0000000..52c74a4
--- /dev/null
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsCommandUtils.java
@@ -0,0 +1,118 @@
+package org.onosproject.vpls.cli;
+
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
+import org.onosproject.incubator.net.intf.Interface;
+import org.onosproject.incubator.net.intf.InterfaceService;
+import org.onosproject.vpls.config.VplsConfigurationService;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static org.onlab.osgi.DefaultServiceDirectory.getService;
+
+/**
+ * Util class for VPLS Commands.
+ */
+public final class VplsCommandUtils {
+
+    protected static final String VPLS_NAME = "VPLS name %s: ";
+    protected static final String VPLS_DISPLAY = "VPLS name: %s, associated " +
+            "interfaces: %s, encapsulation: %s";
+    protected static final String VPLS_NOT_FOUND = "VPLS %s not found.";
+    protected static final String IFACE_NOT_FOUND = "Interface %s not found.";
+    protected static final String VPLS_ALREADY_EXISTS = "VPLS %s already exists.";
+    protected static final String IFACE_ALREADY_ASSOCIATED =
+            "Interface %s already associated to VPLS %s.";
+    protected static final String IFACE_NOT_ASSOCIATED =
+            "Interface %s is associated to VPLS %s.";
+
+    private static VplsConfigurationService vplsConfigService =
+            getService(VplsConfigurationService.class);
+    private static InterfaceService interfaceService =
+            getService(InterfaceService.class);
+
+    private VplsCommandUtils() {}
+
+    /**
+     * States if a VPLS exists or not.
+     *
+     * @param vplsName the name of the VPLS
+     * @return true if the VPLS exists; false otherwise
+     */
+    protected static boolean vplsExists(String vplsName) {
+        return vplsConfigService.vplsNames().contains(vplsName);
+    }
+
+    /**
+     * States if an interface is defined or not in the system.
+     *
+     * @param ifaceName the name of the interface
+     * @return true if the interface is defined; false otherwise
+     */
+    protected static boolean ifaceExists(String ifaceName) {
+        return interfaceService.getInterfaces()
+                .stream()
+                .anyMatch(iface -> iface.name().equals(ifaceName));
+    }
+
+    /**
+     * States if an interface is already associated or not to a VPLS.
+     *
+     * @param ifaceName the name of the interface
+     * @return true if the interface is already associated to a VPLS; false
+     * otherwise
+     */
+    protected static boolean ifaceAlreadyAssociated(String ifaceName) {
+        return vplsConfigService.allIfaces()
+                .stream()
+                .anyMatch(iface -> iface.name().equals(ifaceName));
+    }
+
+    /**
+     * Returns the name of a VPLS, given the name of an interface associated to
+     * it.
+     *
+     * @param ifaceName the name of the interface
+     * @return the name of the VPLS that has the interface configured; null if
+     * the interface does not exist or is not associated to any VPLS
+     */
+    protected static String vplsNameFromIfaceName(String ifaceName) {
+        String vplsName = null;
+
+        Optional<String> optVplsName = vplsConfigService.ifacesByVplsName()
+                .entries()
+                .stream()
+                .filter(iface -> iface.getValue().name().equals(ifaceName))
+                .map(Map.Entry::getKey)
+                .findFirst();
+
+        if (optVplsName.isPresent()) {
+            vplsName = optVplsName.get();
+        }
+
+        return vplsName;
+    }
+
+    /**
+     * Returns a list of interfaces associated to a VPLS, given a VPLS name.
+     *
+     * @param vplsName the name of the VPLS
+     * @return the set of interfaces associated to the given VPLS; null if the
+     * VPLS is not found
+     */
+    protected static Set<String> ifacesFromVplsName(String vplsName) {
+        if (!vplsExists(vplsName)) {
+            return null;
+        }
+
+        SetMultimap<String, Interface> ifacesByVplsName =
+                vplsConfigService.ifacesByVplsName();
+        Set<String> ifaceNames = Sets.newHashSet();
+
+        ifacesByVplsName.get(vplsName).forEach(iface -> ifaceNames.add(iface.name()));
+
+        return ifaceNames;
+    }
+}
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelCommand.java
index 693ad97..23e77ee 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelCommand.java
@@ -25,11 +25,9 @@
  * CLI to remove VPLSs.
  */
 @Command(scope = "onos", name = "vpls-del",
-        description = "Deletes a VPLS")
+        description = "Deletes an existing VPLS")
 public class VplsDelCommand extends AbstractShellCommand {
 
-    private static final String NETWORK_NOT_FOUND =
-            "VPLS %s not found";
     private VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
@@ -39,9 +37,8 @@
 
     @Override
     protected void execute() {
-
-        if (!vplsConfigService.getAllVpls().contains(vplsName)) {
-            print(NETWORK_NOT_FOUND, vplsName);
+        if (!VplsCommandUtils.vplsExists(vplsName)) {
+            print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
             return;
         }
 
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelIfaceCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelIfaceCommand.java
index 695e48f..adf9ce9 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelIfaceCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsDelIfaceCommand.java
@@ -19,11 +19,8 @@
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.intf.Interface;
 import org.onosproject.vpls.config.VplsConfigurationService;
 
-import java.util.Set;
-
 /**
  * CLI to remove an interface from an existing VPLS.
  */
@@ -31,23 +28,36 @@
         description = "Removes an interface from an existing VPLS")
 public class VplsDelIfaceCommand extends AbstractShellCommand {
 
-    private static final String NO_CONFIGURATION = "Interface %s is not configured";
     private VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
-    @Argument(index = 0, name = "IFACE_NAME", description = "Name of the interface" +
-            " to remove from the VPLS", required = true, multiValued = false)
+    @Argument(index = 0, name = "vplsName", description = "Name of the VPLS",
+            required = true, multiValued = false)
+    private String vplsName = null;
+
+    @Argument(index = 1, name = "ifaceName", description = "Name of the interface" +
+            " to be removed from the VPLS", required = true, multiValued = false)
     private String ifaceName = null;
 
     @Override
     protected void execute() {
-        Set<Interface> ifaces = vplsConfigService.getAllInterfaces();
-
-        if (!ifaces.stream().map(Interface::name).anyMatch(ifaceName::equals)) {
-            print(NO_CONFIGURATION, ifaceName);
+        if (!VplsCommandUtils.vplsExists(vplsName)) {
+            print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
+            return;
         }
 
-        vplsConfigService.removeInterfaceFromVpls(ifaceName);
+        if (!VplsCommandUtils.ifaceExists(ifaceName)) {
+            print(VplsCommandUtils.IFACE_NOT_FOUND, ifaceName);
+            return;
+        }
+
+        if (!VplsCommandUtils.ifaceAlreadyAssociated(ifaceName)) {
+            print(VplsCommandUtils.IFACE_NOT_ASSOCIATED,
+                  ifaceName, VplsCommandUtils.vplsNameFromIfaceName(ifaceName));
+            return;
+        }
+
+        vplsConfigService.removeIface(ifaceName);
     }
 
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsListCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsListCommand.java
index bfbb054..aca247c 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsListCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsListCommand.java
@@ -23,15 +23,15 @@
 /**
  * CLI to list VPLSs.
  */
-@Command(scope = "onos", name = "vpls-list", description = "Lists the existing VPLSs")
+@Command(scope = "onos", name = "vpls-list", description = "List the VPLSs configured")
 public class VplsListCommand extends AbstractShellCommand {
     private VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
     @Override
     protected void execute() {
-        vplsConfigService.getAllVpls().forEach(vpls -> {
-            print("%s", vpls);
+        vplsConfigService.vplsNames().forEach(vpls -> {
+            print(VplsCommandUtils.VPLS_NAME, vpls);
         });
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsSetEncapCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsSetEncapCommand.java
new file mode 100644
index 0000000..ba46ea7
--- /dev/null
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsSetEncapCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.vpls.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.vpls.config.VplsConfigurationService;
+
+/**
+ * CLI to set encapsulation for a VPLS.
+ */
+@Command(scope = "onos", name = "vpls-set-encap",
+        description = "Sets the encapsulation type for a given VPLS. None means" +
+                "no encapsulation has been set")
+public class VplsSetEncapCommand extends AbstractShellCommand {
+
+    private static final String VPLS_NOT_FOUND = "VPLS %s not found.";
+    private VplsConfigurationService vplsConfigService =
+            get(VplsConfigurationService.class);
+
+    @Argument(index = 0, name = "vplsName", description = "Name of the VPLS",
+            required = true, multiValued = false)
+    private String vplsName = null;
+
+    @Argument(index = 1, name = "encapsulation", description = "The encapsulation" +
+            "type. For example, VLAN or MPLS. None for no encapsulation",
+            required = true, multiValued = false)
+    String encap = null;
+
+    @Override
+    protected void execute() {
+        if (!VplsCommandUtils.vplsExists(vplsName)) {
+            print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
+            return;
+        }
+
+        vplsConfigService.setEncap(vplsName, encap);
+    }
+}
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsShowCommand.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsShowCommand.java
index 550d122..9dbeed6 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsShowCommand.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/VplsShowCommand.java
@@ -16,14 +16,13 @@
 
 package org.onosproject.vpls.cli;
 
-import com.google.common.collect.SetMultimap;
-import com.google.common.collect.Sets;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.intf.Interface;
+import org.onosproject.net.EncapsulationType;
 import org.onosproject.vpls.config.VplsConfigurationService;
 
+import java.util.Map;
 import java.util.Set;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
@@ -35,40 +34,36 @@
         description = "Shows the details of an existing VPLS")
 public class VplsShowCommand extends AbstractShellCommand {
 
-    private static final String NAME_FORMAT = "%10s: interface=%s";
-    private static final String NETWORK_NOT_FOUND =
-            "VPLS with name \'%s\' not found";
     private VplsConfigurationService vplsConfigService =
             get(VplsConfigurationService.class);
 
-    @Argument(index = 0, name = "NETWORK_NAME", description = "Name of the VPLS",
+    @Argument(index = 0, name = "vplsName", description = "Name of the VPLS",
             required = false, multiValued = false)
     private String vplsName = null;
 
     @Override
     protected void execute() {
-        Set<String> vplsNames = vplsConfigService.getAllVpls();
-        SetMultimap<String, Interface> vplsNetowrks = vplsConfigService.getVplsNetworks();
-        Set<String> ifaceNames = Sets.newHashSet();
-
+        Set<String> vplsNames = vplsConfigService.vplsNames();
+        Map<String, EncapsulationType> encapByVplsName =
+                vplsConfigService.encapByVplsName();
 
         if (!isNullOrEmpty(vplsName)) {
-
-            if (vplsNames.contains(vplsName)) {
-                vplsNetowrks.get(vplsName).stream()
-                        .map(Interface::name)
-                        .forEach(ifaceNames::add);
-                print(NAME_FORMAT, vplsName, ifaceNames);
+            // A VPLS name is provided. Check first if the VPLS exists
+            if (VplsCommandUtils.vplsExists(vplsName)) {
+                print(VplsCommandUtils.VPLS_DISPLAY,
+                      vplsName,
+                      VplsCommandUtils.ifacesFromVplsName(vplsName).toString(),
+                      encapByVplsName.get(vplsName).toString());
             } else {
-                print(NETWORK_NOT_FOUND, vplsName);
+                print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
             }
         } else {
+            // No VPLS names are provided. Display all VPLSs configured
             vplsNames.forEach(vplsName -> {
-                ifaceNames.clear();
-                vplsNetowrks.get(vplsName).stream()
-                        .map(Interface::name)
-                        .forEach(ifaceNames::add);
-                print(NAME_FORMAT, vplsName, ifaceNames);
+                print(VplsCommandUtils.VPLS_DISPLAY,
+                      vplsName,
+                      VplsCommandUtils.ifacesFromVplsName(vplsName).toString(),
+                      encapByVplsName.get(vplsName).toString());
             });
         }
     }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCommandCompleter.java
similarity index 88%
rename from apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java
rename to apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCommandCompleter.java
index 9534635..a1cdfbb 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCommandCompleter.java
@@ -26,12 +26,12 @@
 /**
  * Completer for "vpls-add-inf" command.
  */
-public class VplsAddIfaceCmdCompleter extends AbstractChoicesCompleter {
+public class VplsAddIfaceCommandCompleter extends AbstractChoicesCompleter {
     @Override
     protected List<String> choices() {
         VplsConfigurationService vplsConfigService =
                 get(VplsConfigurationService.class);
 
-        return Lists.newArrayList(vplsConfigService.getAllVpls());
+        return Lists.newArrayList(vplsConfigService.vplsNames());
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelCommandCompleter.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelCommandCompleter.java
index 9c6c061..d360b2a 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelCommandCompleter.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelCommandCompleter.java
@@ -33,6 +33,6 @@
     protected List<String> choices() {
         VplsConfigurationService vplsConfigService =
                 get(VplsConfigurationService.class);
-        return Lists.newArrayList(vplsConfigService.getAllVpls());
+        return Lists.newArrayList(vplsConfigService.vplsNames());
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelIfaceCommandCompleter.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelIfaceCommandCompleter.java
index 81a1583..794ccfc 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelIfaceCommandCompleter.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsDelIfaceCommandCompleter.java
@@ -35,7 +35,7 @@
     protected List<String> choices() {
         VplsConfigurationService vplsConfigService =
                 get(VplsConfigurationService.class);
-        Set<Interface> ifaces = vplsConfigService.getAllInterfaces();
+        Set<Interface> ifaces = vplsConfigService.allIfaces();
         return ifaces.stream().map(Interface::name).collect(Collectors.toList());
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsSetEncapCommandCompleter.java
similarity index 85%
copy from apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java
copy to apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsSetEncapCommandCompleter.java
index 9534635..409d2a7 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsAddIfaceCmdCompleter.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsSetEncapCommandCompleter.java
@@ -21,17 +21,18 @@
 import org.onosproject.vpls.config.VplsConfigurationService;
 
 import java.util.List;
+
 import static org.onosproject.cli.AbstractShellCommand.get;
 
 /**
- * Completer for "vpls-add-inf" command.
+ * Completer for "vpls-set-encap" command.
  */
-public class VplsAddIfaceCmdCompleter extends AbstractChoicesCompleter {
+public class VplsSetEncapCommandCompleter extends AbstractChoicesCompleter {
     @Override
     protected List<String> choices() {
         VplsConfigurationService vplsConfigService =
                 get(VplsConfigurationService.class);
 
-        return Lists.newArrayList(vplsConfigService.getAllVpls());
+        return Lists.newArrayList(vplsConfigService.vplsNames());
     }
 }
diff --git a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsShowCommandCompleter.java b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsShowCommandCompleter.java
index 75ce663..0f572ea 100644
--- a/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsShowCommandCompleter.java
+++ b/apps/vpls/src/main/java/org/onosproject/vpls/cli/completer/VplsShowCommandCompleter.java
@@ -33,6 +33,6 @@
     protected List<String> choices() {
         VplsConfigurationService vplsConfigService =
                 get(VplsConfigurationService.class);
-        return Lists.newArrayList(vplsConfigService.getAllVpls());
+        return Lists.newArrayList(vplsConfigService.vplsNames());
     }
 }