Thomas Vachuska
Committed by Gerrit Code Review

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

Change-Id: I828ccdc994a490e17c2806d27aa36460da10f795
......@@ -19,25 +19,25 @@ 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.
*/
@Command(scope = "onos", name = "wipe-out",
description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
public class WipeOutCommand extends ClustersListCommand {
private static final String PLEASE = "please";
@Argument(index = 0, name = "please", description = "Confirmation phrase",
required = false, multiValued = false)
required = false, multiValued = false)
String please = null;
@Override
......@@ -49,16 +49,39 @@ public class WipeOutCommand extends ClustersListCommand {
print("Wiping devices");
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
DeviceService deviceService = get(DeviceService.class);
for (Device device : deviceService.getDevices()) {
deviceAdminService.removeDevice(device.id());
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()) {
hostAdminService.removeHost(host.id());
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");
......@@ -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
......