Adding Encapsulation in VPLS and correcting bugs.
Change-Id: Idc0c1834ae2bbd0fdaf564fd65360cc0f018d18d
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);
}
}