Allow to remove instance ports in pending removal state

Change-Id: I2924be30f57c0d33ec79d522e7144d67b9825bd0
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/PurgeInstancePortsCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/PurgeInstancePortsCommand.java
index b785369..08ccd45 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/PurgeInstancePortsCommand.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/PurgeInstancePortsCommand.java
@@ -23,6 +23,7 @@
 import org.onosproject.openstacknetworking.api.InstancePortAdminService;
 
 import static org.onosproject.openstacknetworking.api.InstancePort.State.INACTIVE;
+import static org.onosproject.openstacknetworking.api.InstancePort.State.REMOVE_PENDING;
 
 /**
  * Purges existing instance ports.
@@ -40,6 +41,11 @@
             required = false, multiValued = false)
     private boolean isInactive = false;
 
+    @Option(name = "-p", aliases = "--pending",
+            description = "Instance ports in pending removal state",
+            required = false, multiValued = false)
+    private boolean isPending = false;
+
     @Argument(index = 0, name = "portIds", description = "Instance Port IDs",
             required = false, multiValued = true)
     private String[] portIds = null;
@@ -48,11 +54,12 @@
     protected void execute() {
         InstancePortAdminService service = get(InstancePortAdminService.class);
 
-        if ((!isAll && !isInactive && portIds == null) ||
-                (isAll && isInactive) ||
-                (isInactive && portIds != null) ||
-                (portIds != null && isAll)) {
-            print("Please specify one of portIds, --all, and --inactive options.");
+        if ((!isAll && !isInactive && !isPending && portIds == null) ||
+                (isAll && isInactive && isPending) ||
+                (isInactive && isPending && portIds != null) ||
+                (portIds != null && isAll && isPending) ||
+                (isAll && isInactive && portIds != null)) {
+            print("Please specify one of portIds, --all or --inactive or --pending options.");
             return;
         }
 
@@ -63,6 +70,10 @@
             portIds = service.instancePorts().stream()
                              .filter(p -> p.state() == INACTIVE)
                              .map(InstancePort::portId).toArray(String[]::new);
+        } else if (isPending) {
+            portIds = service.instancePorts().stream()
+                             .filter(p -> p.state() == REMOVE_PENDING)
+                             .map(InstancePort::portId).toArray(String[]::new);
         }
 
         for (String portId : portIds) {