Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.cli.net; |
| 17 | |
| 18 | import java.util.List; |
| 19 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 20 | import org.apache.karaf.shell.api.action.Command; |
| 21 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 22 | import org.onlab.osgi.ServiceNotFoundException; |
| 23 | import org.onosproject.cli.AbstractShellCommand; |
| 24 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 25 | |
| 26 | /** |
| 27 | * Returns a list of FlowObjective next-ids waiting to get created by device-drivers. |
Saurav Das | 1547b3f | 2017-05-05 17:01:08 -0700 | [diff] [blame] | 28 | * Also returns the forwarding objectives and next objectives waiting on the pending |
| 29 | * next-objectives. These lists are controller instance specific. |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 30 | */ |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 31 | @Service |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 32 | @Command(scope = "onos", name = "obj-pending-nexts", |
| 33 | description = "flow-objectives pending next-objectives") |
| 34 | public class FlowObjectivePendingNextCommand extends AbstractShellCommand { |
| 35 | |
| 36 | private static final String FORMAT_MAPPING = " %s"; |
| 37 | |
| 38 | @Override |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 39 | protected void doExecute() { |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 40 | try { |
| 41 | FlowObjectiveService service = get(FlowObjectiveService.class); |
Saurav Das | 1547b3f | 2017-05-05 17:01:08 -0700 | [diff] [blame] | 42 | printNexts(service.getPendingFlowObjectives()); |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 43 | } 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 | } |