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; |
Brian O'Connor | 958d381 | 2014-10-03 19:46:23 -0700 | [diff] [blame^] | 10 | import org.onlab.onos.net.intent.Intent; |
| 11 | import org.onlab.onos.net.intent.IntentService; |
| 12 | import org.onlab.onos.net.intent.IntentState; |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * Wipes-out the entire network information base, i.e. devices, links, hosts. |
| 16 | */ |
| 17 | @Command(scope = "onos", name = "wipe-out", |
| 18 | description = "Wipes-out the entire network information base, i.e. devices, links, hosts") |
| 19 | public class WipeOutCommand extends ClustersListCommand { |
| 20 | |
| 21 | @Override |
tom | 0872a17 | 2014-09-23 11:24:26 -0700 | [diff] [blame] | 22 | protected void execute() { |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 23 | DeviceAdminService deviceAdminService = get(DeviceAdminService.class); |
| 24 | DeviceService deviceService = get(DeviceService.class); |
| 25 | for (Device device : deviceService.getDevices()) { |
| 26 | deviceAdminService.removeDevice(device.id()); |
| 27 | } |
| 28 | |
| 29 | HostAdminService hostAdminService = get(HostAdminService.class); |
| 30 | HostService hostService = get(HostService.class); |
| 31 | for (Host host : hostService.getHosts()) { |
| 32 | hostAdminService.removeHost(host.id()); |
| 33 | } |
Brian O'Connor | 958d381 | 2014-10-03 19:46:23 -0700 | [diff] [blame^] | 34 | |
| 35 | IntentService intentService = get(IntentService.class); |
| 36 | for (Intent intent : intentService.getIntents()) { |
| 37 | if (intentService.getIntentState(intent.getId()) == IntentState.INSTALLED) { |
| 38 | intentService.withdraw(intent); |
| 39 | } |
| 40 | } |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 41 | } |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 42 | } |