blob: bbf90e3fedef5a8ddd15faa1959ea9aa3ad3533c [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor7cbbbb72016-04-09 02:13:23 -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 */
Saurav Das24431192016-03-07 19:13:00 -080016package org.onosproject.cli.net;
17
18import java.util.List;
Saurav Dasb5c236e2016-06-07 10:08:06 -070019import org.onlab.osgi.ServiceNotFoundException;
Saurav Das24431192016-03-07 19:13:00 -080020
Saurav Das24431192016-03-07 19:13:00 -080021import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.flowobjective.FlowObjectiveService;
24
25/**
26 * Returns a mapping of FlowObjective next-ids to the groups that get created
Saurav Dasb5c236e2016-06-07 10:08:06 -070027 * by a device driver. These mappings are controller instance specific.
Saurav Das24431192016-03-07 19:13:00 -080028 */
Saurav Dasb5c236e2016-06-07 10:08:06 -070029@Command(scope = "onos", name = "obj-next-ids",
30 description = "flow-objectives next-ids to group-ids mapping")
Saurav Das24431192016-03-07 19:13:00 -080031public class FlowObjectiveNextListCommand extends AbstractShellCommand {
32
Saurav Dasb5c236e2016-06-07 10:08:06 -070033 private static final String FORMAT_MAPPING = " %s";
34
Saurav Das24431192016-03-07 19:13:00 -080035 @Override
36 protected void execute() {
Saurav Dasb5c236e2016-06-07 10:08:06 -070037 try {
38 FlowObjectiveService service = get(FlowObjectiveService.class);
39 printNexts(service.getNextMappings());
40 } catch (ServiceNotFoundException e) {
41 print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
42 }
Saurav Das24431192016-03-07 19:13:00 -080043 }
44
45 private void printNexts(List<String> nextGroupMappings) {
46 nextGroupMappings.forEach(str -> print(FORMAT_MAPPING, str));
47 }
48}