Brian O'Connor | 7cbbbb7 | 2016-04-09 02:13:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | */ |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 16 | package org.onosproject.cli.net; |
| 17 | |
| 18 | import java.util.List; |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 19 | import org.onlab.osgi.ServiceNotFoundException; |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 20 | |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 21 | import org.apache.karaf.shell.commands.Command; |
| 22 | import org.onosproject.cli.AbstractShellCommand; |
| 23 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 24 | |
| 25 | /** |
| 26 | * Returns a mapping of FlowObjective next-ids to the groups that get created |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 27 | * by a device driver. These mappings are controller instance specific. |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 28 | */ |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 29 | @Command(scope = "onos", name = "obj-next-ids", |
| 30 | description = "flow-objectives next-ids to group-ids mapping") |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 31 | public class FlowObjectiveNextListCommand extends AbstractShellCommand { |
| 32 | |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 33 | private static final String FORMAT_MAPPING = " %s"; |
| 34 | |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 35 | @Override |
| 36 | protected void execute() { |
Saurav Das | b5c236e | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 37 | try { |
| 38 | FlowObjectiveService service = get(FlowObjectiveService.class); |
| 39 | printNexts(service.getNextMappings()); |
| 40 | } catch (ServiceNotFoundException e) { |
| 41 | print(FORMAT_MAPPING, "FlowObjectiveService unavailable"); |
| 42 | } |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | private void printNexts(List<String> nextGroupMappings) { |
| 46 | nextGroupMappings.forEach(str -> print(FORMAT_MAPPING, str)); |
| 47 | } |
| 48 | } |