tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Command; |
| 4 | import org.onlab.onos.net.Device; |
| 5 | import org.onlab.onos.net.Host; |
| 6 | import org.onlab.onos.net.device.DeviceAdminService; |
| 7 | import org.onlab.onos.net.device.DeviceService; |
| 8 | import org.onlab.onos.net.host.HostAdminService; |
| 9 | import org.onlab.onos.net.host.HostService; |
| 10 | |
| 11 | /** |
| 12 | * Wipes-out the entire network information base, i.e. devices, links, hosts. |
| 13 | */ |
| 14 | @Command(scope = "onos", name = "wipe-out", |
| 15 | description = "Wipes-out the entire network information base, i.e. devices, links, hosts") |
| 16 | public class WipeOutCommand extends ClustersListCommand { |
| 17 | |
| 18 | @Override |
| 19 | protected Object doExecute() throws Exception { |
| 20 | DeviceAdminService deviceAdminService = get(DeviceAdminService.class); |
| 21 | DeviceService deviceService = get(DeviceService.class); |
| 22 | for (Device device : deviceService.getDevices()) { |
| 23 | deviceAdminService.removeDevice(device.id()); |
| 24 | } |
| 25 | |
| 26 | HostAdminService hostAdminService = get(HostAdminService.class); |
| 27 | HostService hostService = get(HostService.class); |
| 28 | for (Host host : hostService.getHosts()) { |
| 29 | hostAdminService.removeHost(host.id()); |
| 30 | } |
| 31 | return null; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | } |