Merged master fixed conflict.
Change-Id: I1260048f4cc90c422ce6033d506c25ec38d6cc3a
diff --git a/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java b/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
index 61ea43d..0e28795 100644
--- a/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
@@ -21,6 +21,8 @@
import org.onosproject.net.Host;
import org.onosproject.net.Link;
import org.onosproject.net.device.DeviceAdminService;
+import org.onosproject.net.flow.FlowRuleService;
+import org.onosproject.net.group.GroupService;
import org.onosproject.net.host.HostAdminService;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
@@ -28,6 +30,11 @@
import org.onosproject.net.link.LinkAdminService;
import org.onosproject.net.region.RegionAdminService;
import org.onosproject.ui.UiTopoLayoutService;
+import java.util.EnumSet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import static org.onosproject.net.intent.IntentState.FAILED;
+import static org.onosproject.net.intent.IntentState.WITHDRAWN;
/**
* Wipes-out the entire network information base, i.e. devices, links, hosts, intents.
@@ -37,7 +44,7 @@
public class WipeOutCommand extends ClustersListCommand {
private static final String PLEASE = "please";
-
+ private static final EnumSet<IntentState> CAN_PURGE = EnumSet.of(WITHDRAWN, FAILED);
@Argument(index = 0, name = "please", description = "Confirmation phrase",
required = false, multiValued = false)
String please = null;
@@ -51,6 +58,8 @@
wipeOutIntents();
wipeOutHosts();
+ wipeOutFlows();
+ wipeOutGroups();
wipeOutDevices();
wipeOutLinks();
@@ -61,11 +70,38 @@
private void wipeOutIntents() {
print("Wiping intents");
IntentService intentService = get(IntentService.class);
+ final CountDownLatch withdrawLatch;
+ withdrawLatch = new CountDownLatch(1);
for (Intent intent : intentService.getIntents()) {
if (intentService.getIntentState(intent.key()) != IntentState.WITHDRAWN) {
intentService.withdraw(intent);
+ try { // wait for withdraw event
+ withdrawLatch.await(5, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ print("Timed out waiting for intent {} withdraw");
+ }
}
- intentService.purge(intent);
+ if (CAN_PURGE.contains(intentService.getIntentState(intent.key()))) {
+ intentService.purge(intent);
+ }
+ }
+ }
+
+ private void wipeOutFlows() {
+ print("Wiping Flows");
+ FlowRuleService flowRuleService = get(FlowRuleService.class);
+ DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
+ for (Device device : deviceAdminService.getDevices()) {
+ flowRuleService.purgeFlowRules(device.id());
+ }
+ }
+
+ private void wipeOutGroups() {
+ print("Wiping groups");
+ GroupService groupService = get(GroupService.class);
+ DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
+ for (Device device : deviceAdminService.getDevices()) {
+ groupService.purgeGroupEntries(device.id());
}
}