Committed by
Gerrit Code Review
Adding more aggressive and thorough implementation of wipe-out command.
Change-Id: I828ccdc994a490e17c2806d27aa36460da10f795
Showing
3 changed files
with
39 additions
and
11 deletions
... | @@ -19,25 +19,25 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,25 +19,25 @@ 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. |
32 | */ | 32 | */ |
33 | @Command(scope = "onos", name = "wipe-out", | 33 | @Command(scope = "onos", name = "wipe-out", |
34 | - description = "Wipes-out the entire network information base, i.e. devices, links, hosts") | 34 | + description = "Wipes-out the entire network information base, i.e. devices, links, hosts") |
35 | public class WipeOutCommand extends ClustersListCommand { | 35 | public class WipeOutCommand extends ClustersListCommand { |
36 | 36 | ||
37 | private static final String PLEASE = "please"; | 37 | private static final String PLEASE = "please"; |
38 | 38 | ||
39 | @Argument(index = 0, name = "please", description = "Confirmation phrase", | 39 | @Argument(index = 0, name = "please", description = "Confirmation phrase", |
40 | - required = false, multiValued = false) | 40 | + required = false, multiValued = false) |
41 | String please = null; | 41 | String please = null; |
42 | 42 | ||
43 | @Override | 43 | @Override |
... | @@ -49,16 +49,39 @@ public class WipeOutCommand extends ClustersListCommand { | ... | @@ -49,16 +49,39 @@ 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 | - deviceAdminService.removeDevice(device.id()); | 54 | + for (Device device : deviceAdminService.getDevices()) { |
55 | + deviceAdminService.removeDevice(device.id()); | ||
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 | + } | ||
55 | } | 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 { |
61 | - hostAdminService.removeHost(host.id()); | 79 | + for (Host host : hostAdminService.getHosts()) { |
80 | + hostAdminService.removeHost(host.id()); | ||
81 | + } | ||
82 | + } catch (Exception e) { | ||
83 | + log.warn("Unable to wipe-out hosts", e); | ||
84 | + } | ||
62 | } | 85 | } |
63 | 86 | ||
64 | print("Wiping intents"); | 87 | print("Wiping intents"); |
... | @@ -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 | } | ... | ... |
... | @@ -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 | ... | ... |
-
Please register or login to post a comment