blob: dd85b5bc1c3a3f30f581ed6c1c931333aed5ee7b [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
Ray Milkeyd84f89b2018-08-17 14:54:17 -070021import org.apache.karaf.shell.api.action.Command;
22import org.apache.karaf.shell.api.action.lifecycle.Service;
Saurav Das24431192016-03-07 19:13:00 -080023import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.net.flowobjective.FlowObjectiveService;
25
26/**
27 * Returns a mapping of FlowObjective next-ids to the groups that get created
Saurav Dasb5c236e2016-06-07 10:08:06 -070028 * by a device driver. These mappings are controller instance specific.
Saurav Das24431192016-03-07 19:13:00 -080029 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070030@Service
Saurav Dasb5c236e2016-06-07 10:08:06 -070031@Command(scope = "onos", name = "obj-next-ids",
32 description = "flow-objectives next-ids to group-ids mapping")
Saurav Das24431192016-03-07 19:13:00 -080033public class FlowObjectiveNextListCommand extends AbstractShellCommand {
34
Saurav Dasb5c236e2016-06-07 10:08:06 -070035 private static final String FORMAT_MAPPING = " %s";
36
Saurav Das24431192016-03-07 19:13:00 -080037 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070038 protected void doExecute() {
Saurav Dasb5c236e2016-06-07 10:08:06 -070039 try {
40 FlowObjectiveService service = get(FlowObjectiveService.class);
41 printNexts(service.getNextMappings());
42 } catch (ServiceNotFoundException e) {
43 print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
44 }
Saurav Das24431192016-03-07 19:13:00 -080045 }
46
47 private void printNexts(List<String> nextGroupMappings) {
48 nextGroupMappings.forEach(str -> print(FORMAT_MAPPING, str));
49 }
50}