Enhanced flow list command to be more parsable and to use sorted devices list.
Fixed NPE.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
index 21acb18..902b27b 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
@@ -47,7 +47,7 @@
DeviceService deviceService = get(DeviceService.class);
FlowRuleService service = get(FlowRuleService.class);
Map<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service);
- for (Device d : flows.keySet()) {
+ for (Device d : getSortedDevices(deviceService)) {
printFlows(d, flows.get(d));
}
}
@@ -58,14 +58,15 @@
* @param service device service
* @return sorted device list
*/
- protected Map<Device, List<FlowEntry>> getSortedFlows(DeviceService deviceService, FlowRuleService service) {
+ protected Map<Device, List<FlowEntry>> getSortedFlows(DeviceService deviceService,
+ FlowRuleService service) {
Map<Device, List<FlowEntry>> flows = Maps.newHashMap();
List<FlowEntry> rules;
FlowEntryState s = null;
if (state != null && !state.equals("any")) {
s = FlowEntryState.valueOf(state.toUpperCase());
}
- Iterable<Device> devices = uri == null ? getSortedDevices(deviceService) :
+ Iterable<Device> devices = uri == null ? deviceService.getDevices() :
Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri)));
for (Device d : devices) {
if (s == null) {
@@ -90,18 +91,16 @@
* @param flows the set of flows for that device.
*/
protected void printFlows(Device d, List<FlowEntry> flows) {
- print("Device: " + d.id());
- if (flows == null | flows.isEmpty()) {
- print(" %s", "No flows.");
- return;
+ boolean empty = flows == null || flows.isEmpty();
+ print("deviceId=%s, flowRuleCount=%d", d.id(), empty ? 0 : flows.size());
+ if (!empty) {
+ for (FlowEntry f : flows) {
+ print(FMT, Long.toHexString(f.id().value()), f.state(), f.bytes(),
+ f.packets(), f.life(), f.priority());
+ print(SFMT, f.selector().criteria());
+ print(TFMT, f.treatment().instructions());
+ }
}
- for (FlowEntry f : flows) {
- print(FMT, Long.toHexString(f.id().value()), f.state(), f.bytes(),
- f.packets(), f.life(), f.priority());
- print(SFMT, f.selector().criteria());
- print(TFMT, f.treatment().instructions());
- }
-
}
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
index 820668e..d84c367 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
@@ -113,7 +113,7 @@
@Override
public void run() {
if (event.reasons() == null) {
- delegate.triggerCompile(null, true);
+ delegate.triggerCompile(new HashSet<IntentId>(), true);
} else {
Set<IntentId> toBeRecompiled = new HashSet<>();