Thomas Vachuska
Committed by Gerrit Code Review

Adding more aggressive and thorough implementation of wipe-out command.

Change-Id: I828ccdc994a490e17c2806d27aa36460da10f795
...@@ -19,13 +19,13 @@ import org.apache.karaf.shell.commands.Argument; ...@@ -19,13 +19,13 @@ import org.apache.karaf.shell.commands.Argument;
19 import org.apache.karaf.shell.commands.Command; 19 import org.apache.karaf.shell.commands.Command;
20 import org.onosproject.net.Device; 20 import org.onosproject.net.Device;
21 import org.onosproject.net.Host; 21 import org.onosproject.net.Host;
22 +import org.onosproject.net.Link;
22 import org.onosproject.net.device.DeviceAdminService; 23 import org.onosproject.net.device.DeviceAdminService;
23 -import org.onosproject.net.device.DeviceService;
24 import org.onosproject.net.host.HostAdminService; 24 import org.onosproject.net.host.HostAdminService;
25 -import org.onosproject.net.host.HostService;
26 import org.onosproject.net.intent.Intent; 25 import org.onosproject.net.intent.Intent;
27 import org.onosproject.net.intent.IntentService; 26 import org.onosproject.net.intent.IntentService;
28 import org.onosproject.net.intent.IntentState; 27 import org.onosproject.net.intent.IntentState;
28 +import org.onosproject.net.link.LinkAdminService;
29 29
30 /** 30 /**
31 * Wipes-out the entire network information base, i.e. devices, links, hosts, intents. 31 * Wipes-out the entire network information base, i.e. devices, links, hosts, intents.
...@@ -49,17 +49,40 @@ public class WipeOutCommand extends ClustersListCommand { ...@@ -49,17 +49,40 @@ public class WipeOutCommand extends ClustersListCommand {
49 49
50 print("Wiping devices"); 50 print("Wiping devices");
51 DeviceAdminService deviceAdminService = get(DeviceAdminService.class); 51 DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
52 - DeviceService deviceService = get(DeviceService.class); 52 + while (deviceAdminService.getDeviceCount() > 0) {
53 - for (Device device : deviceService.getDevices()) { 53 + try {
54 + for (Device device : deviceAdminService.getDevices()) {
54 deviceAdminService.removeDevice(device.id()); 55 deviceAdminService.removeDevice(device.id());
55 } 56 }
57 + } catch (Exception e) {
58 + log.warn("Unable to wipe-out devices", e);
59 + }
60 + }
61 +
62 + print("Wiping links");
63 + LinkAdminService linkAdminService = get(LinkAdminService.class);
64 + while (linkAdminService.getLinkCount() > 0) {
65 + try {
66 + for (Link link : linkAdminService.getLinks()) {
67 + linkAdminService.removeLinks(link.src());
68 + linkAdminService.removeLinks(link.dst());
69 + }
70 + } catch (Exception e) {
71 + log.warn("Unable to wipe-out links", e);
72 + }
73 + }
56 74
57 print("Wiping hosts"); 75 print("Wiping hosts");
58 HostAdminService hostAdminService = get(HostAdminService.class); 76 HostAdminService hostAdminService = get(HostAdminService.class);
59 - HostService hostService = get(HostService.class); 77 + while (hostAdminService.getHostCount() > 0) {
60 - for (Host host : hostService.getHosts()) { 78 + try {
79 + for (Host host : hostAdminService.getHosts()) {
61 hostAdminService.removeHost(host.id()); 80 hostAdminService.removeHost(host.id());
62 } 81 }
82 + } catch (Exception e) {
83 + log.warn("Unable to wipe-out hosts", e);
84 + }
85 + }
63 86
64 print("Wiping intents"); 87 print("Wiping intents");
65 IntentService intentService = get(IntentService.class); 88 IntentService intentService = get(IntentService.class);
...@@ -67,6 +90,7 @@ public class WipeOutCommand extends ClustersListCommand { ...@@ -67,6 +90,7 @@ public class WipeOutCommand extends ClustersListCommand {
67 if (intentService.getIntentState(intent.key()) == IntentState.INSTALLED) { 90 if (intentService.getIntentState(intent.key()) == IntentState.INSTALLED) {
68 intentService.withdraw(intent); 91 intentService.withdraw(intent);
69 } 92 }
93 + intentService.purge(intent);
70 } 94 }
71 } 95 }
72 } 96 }
......
...@@ -44,6 +44,10 @@ expect) ...@@ -44,6 +44,10 @@ expect)
44 " 44 "
45 ;; 45 ;;
46 46
47 +attach)
48 + $mininet -x
49 + ;;
50 +
47 start) 51 start)
48 ssh $remote "rm -f $log; echo logfile flush 1 > ~/.screenrc" 52 ssh $remote "rm -f $log; echo logfile flush 1 > ~/.screenrc"
49 ( 53 (
......
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
16 <scenario name="net-setup" description="Network teardown steps"> 16 <scenario name="net-setup" description="Network teardown steps">
17 <group name="Net-Teardown"> 17 <group name="Net-Teardown">
18 <step name="Stop-Mininet" exec="onos-mininet stop"/> 18 <step name="Stop-Mininet" exec="onos-mininet stop"/>
19 - <step name="Wipe-Out-Data-After" requires="~Stop-Mininet" exec="onos-wipe-out"/> 19 + <XXXstep name="Wipe-Out-Data-After" requires="~Stop-Mininet" exec="onos-wipe-out"/>
20 </group> 20 </group>
21 </scenario> 21 </scenario>
...\ No newline at end of file ...\ No newline at end of file
......