blob: f0fbca8662a0900a33dd5a5ceb30144b819e4e87 [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
Ray Milkeyd84f89b2018-08-17 14:54:17 -070020import org.apache.karaf.shell.api.action.Command;
21import org.apache.karaf.shell.api.action.lifecycle.Service;
Saurav Dasb5c236e2016-06-07 10:08:06 -070022import org.onlab.osgi.ServiceNotFoundException;
23import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.net.flowobjective.FlowObjectiveService;
25
26/**
27 * Returns a list of FlowObjective next-ids waiting to get created by device-drivers.
Saurav Das1547b3f2017-05-05 17:01:08 -070028 * Also returns the forwarding objectives and next objectives waiting on the pending
29 * next-objectives. These lists are controller instance specific.
Saurav Dasb5c236e2016-06-07 10:08:06 -070030 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070031@Service
Saurav Dasb5c236e2016-06-07 10:08:06 -070032@Command(scope = "onos", name = "obj-pending-nexts",
33 description = "flow-objectives pending next-objectives")
34public class FlowObjectivePendingNextCommand extends AbstractShellCommand {
35
36 private static final String FORMAT_MAPPING = " %s";
37
38 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070039 protected void doExecute() {
Saurav Dasb5c236e2016-06-07 10:08:06 -070040 try {
41 FlowObjectiveService service = get(FlowObjectiveService.class);
Saurav Das1547b3f2017-05-05 17:01:08 -070042 printNexts(service.getPendingFlowObjectives());
Saurav Dasb5c236e2016-06-07 10:08:06 -070043 } catch (ServiceNotFoundException e) {
44 print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
45 }
46 }
47
48 private void printNexts(List<String> pendingNexts) {
49 pendingNexts.forEach(str -> print(FORMAT_MAPPING, str));
50 }
51
52}