use of org.onlab.util.StringFilter in project onos by opennetworkinglab.
the class VirtualFlowsListCommand method doExecute.
@Override
protected void doExecute() {
CoreService coreService = get(CoreService.class);
VirtualNetworkService vnetservice = get(VirtualNetworkService.class);
DeviceService deviceService = vnetservice.get(NetworkId.networkId(networkId), DeviceService.class);
FlowRuleService service = vnetservice.get(NetworkId.networkId(networkId), FlowRuleService.class);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
compilePredicate();
SortedMap<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service);
if (outputJson()) {
print("%s", json(flows.keySet(), flows));
} else {
flows.forEach((device, flow) -> printFlows(device, flow, coreService));
}
}
use of org.onlab.util.StringFilter in project onos by opennetworkinglab.
the class FlowsListCommand method doExecute.
@Override
protected void doExecute() {
CoreService coreService = get(CoreService.class);
DeviceService deviceService = get(DeviceService.class);
FlowRuleService service = get(FlowRuleService.class);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
compilePredicate();
if (countOnly && !suppressCoreOutput && filter.isEmpty() && remove == null) {
if (state == null && uri == null) {
deviceService.getDevices().forEach(device -> printCount(device, service));
} else if (uri == null) {
deviceService.getDevices().forEach(device -> printCount(device, FlowEntryState.valueOf(state.toUpperCase()), service));
} else {
Device device = deviceService.getDevice(DeviceId.deviceId(uri));
if (device != null) {
printCount(device, FlowEntryState.valueOf(state.toUpperCase()), service);
}
}
return;
}
SortedMap<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service, coreService);
// Remove flows
if (remove != null) {
flows.values().forEach(flowList -> {
if (!remove.isEmpty()) {
filter.add(remove);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
}
if (!filter.isEmpty() || (remove != null && !remove.isEmpty())) {
flowList = filterFlows(flowList);
this.removeFlowsInteractive(flowList, service, coreService);
}
});
return;
}
// Show flows
if (outputJson()) {
print("%s", json(flows.keySet(), flows));
} else {
flows.forEach((device, flow) -> printFlows(device, flow, coreService));
}
}
use of org.onlab.util.StringFilter in project onos by opennetworkinglab.
the class IntentsListCommand method doExecute.
@Override
protected void doExecute() {
service = get(IntentService.class);
workPartitionService = get(WorkPartitionService.class);
if (workPartitionService == null) {
return;
}
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
Iterable<Intent> intents;
if (pending) {
intents = service.getPending();
} else {
intents = service.getIntents();
}
// Remove intents
if (remove != null && !remove.isEmpty()) {
filter.add(remove);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
IntentRemoveCommand intentRemoveCmd = new IntentRemoveCommand();
if (!remove.isEmpty()) {
intentRemoveCmd.purgeIntentsInteractive(filterIntents(service));
}
return;
}
// Show detailed intents
if (!intentIds.isEmpty()) {
IntentDetailsCommand intentDetailsCmd = new IntentDetailsCommand();
intentDetailsCmd.detailIntents(intentIds);
return;
}
// Show brief intents
if (intentsSummary || miniSummary) {
Map<String, IntentSummary> summarized = summarize(intents);
if (outputJson()) {
ObjectNode summaries = mapper().createObjectNode();
summarized.forEach((n, s) -> summaries.set(uncapitalize(n), s.json(mapper())));
print("%s", summaries);
} else if (miniSummary) {
StringBuilder builder = new StringBuilder();
builder.append(summarized.remove("All").miniSummary());
summarized.values().forEach(s -> builder.append(s.miniSummary()));
print("%s", builder.toString());
} else {
StringBuilder builder = new StringBuilder();
builder.append(SUMMARY_TITLES);
builder.append('\n').append(SEPARATOR);
builder.append(summarized.remove("All").summary());
summarized.values().forEach(s -> builder.append(s.summary()));
print("%s", builder.toString());
}
return;
}
// JSON or default output
if (outputJson()) {
print("%s", json(intents));
} else {
for (Intent intent : intents) {
IntentState state = service.getIntentState(intent.key());
StringBuilder intentFormat = fullFormat(intent, state);
StringBuilder detailsIntentFormat = detailsFormat(intent, state);
String formatted = intentFormat.append(detailsIntentFormat).toString();
if (contentFilter.filter(formatted)) {
print("%s\n", formatted);
}
}
}
}
Aggregations