blob: e3f372bc4d35c4f6eeaf09728a9432cc90917d76 [file] [log] [blame]
Saurav Dasb5c236e2016-06-07 10:08:06 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Saurav Dasb5c236e2016-06-07 10:08:06 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.cli.net;
17
18import java.util.List;
19
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.osgi.ServiceNotFoundException;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.flowobjective.FlowObjectiveService;
24
25/**
26 * Returns a list of FlowObjective next-ids waiting to get created by device-drivers.
Saurav Das1547b3f2017-05-05 17:01:08 -070027 * Also returns the forwarding objectives and next objectives waiting on the pending
28 * next-objectives. These lists are controller instance specific.
Saurav Dasb5c236e2016-06-07 10:08:06 -070029 */
30@Command(scope = "onos", name = "obj-pending-nexts",
31 description = "flow-objectives pending next-objectives")
32public class FlowObjectivePendingNextCommand extends AbstractShellCommand {
33
34 private static final String FORMAT_MAPPING = " %s";
35
36 @Override
37 protected void execute() {
38 try {
39 FlowObjectiveService service = get(FlowObjectiveService.class);
Saurav Das1547b3f2017-05-05 17:01:08 -070040 printNexts(service.getPendingFlowObjectives());
Saurav Dasb5c236e2016-06-07 10:08:06 -070041 } catch (ServiceNotFoundException e) {
42 print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
43 }
44 }
45
46 private void printNexts(List<String> pendingNexts) {
47 pendingNexts.forEach(str -> print(FORMAT_MAPPING, str));
48 }
49
50}