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;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.Device;
import org.onosproject.net.Host;
import org.onosproject.net.Link;
import org.onosproject.net.device.DeviceAdminService;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.host.HostAdminService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.link.LinkAdminService;
/**
* Wipes-out the entire network information base, i.e. devices, links, hosts, intents.
......@@ -49,17 +49,40 @@ public class WipeOutCommand extends ClustersListCommand {
print("Wiping devices");
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
DeviceService deviceService = get(DeviceService.class);
for (Device device : deviceService.getDevices()) {
while (deviceAdminService.getDeviceCount() > 0) {
try {
for (Device device : deviceAdminService.getDevices()) {
deviceAdminService.removeDevice(device.id());
}
} catch (Exception e) {
log.warn("Unable to wipe-out devices", e);
}
}
print("Wiping links");
LinkAdminService linkAdminService = get(LinkAdminService.class);
while (linkAdminService.getLinkCount() > 0) {
try {
for (Link link : linkAdminService.getLinks()) {
linkAdminService.removeLinks(link.src());
linkAdminService.removeLinks(link.dst());
}
} catch (Exception e) {
log.warn("Unable to wipe-out links", e);
}
}
print("Wiping hosts");
HostAdminService hostAdminService = get(HostAdminService.class);
HostService hostService = get(HostService.class);
for (Host host : hostService.getHosts()) {
while (hostAdminService.getHostCount() > 0) {
try {
for (Host host : hostAdminService.getHosts()) {
hostAdminService.removeHost(host.id());
}
} catch (Exception e) {
log.warn("Unable to wipe-out hosts", e);
}
}
print("Wiping intents");
IntentService intentService = get(IntentService.class);
......@@ -67,6 +90,7 @@ public class WipeOutCommand extends ClustersListCommand {
if (intentService.getIntentState(intent.key()) == IntentState.INSTALLED) {
intentService.withdraw(intent);
}
intentService.purge(intent);
}
}
}
......
......@@ -44,6 +44,10 @@ expect)
"
;;
attach)
$mininet -x
;;
start)
ssh $remote "rm -f $log; echo logfile flush 1 > ~/.screenrc"
(
......
......@@ -16,6 +16,6 @@
<scenario name="net-setup" description="Network teardown steps">
<group name="Net-Teardown">
<step name="Stop-Mininet" exec="onos-mininet stop"/>
<step name="Wipe-Out-Data-After" requires="~Stop-Mininet" exec="onos-wipe-out"/>
<XXXstep name="Wipe-Out-Data-After" requires="~Stop-Mininet" exec="onos-wipe-out"/>
</group>
</scenario>
\ No newline at end of file
......