blob: 1755f821e6b48fb7e8224f497ac7ef7f85050062 [file] [log] [blame]
Thomas Vachuska7f171b22015-08-21 12:49:08 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska7f171b22015-08-21 12:49:08 -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 org.apache.karaf.shell.commands.Command;
19import org.onosproject.cli.AbstractShellCommand;
20import org.onosproject.net.packet.PacketRequest;
21import org.onosproject.net.packet.PacketService;
22
23/**
24 * Lists packet requests.
25 */
26@Command(scope = "onos", name = "packet-requests",
27 description = "Lists packet requests")
28public class PacketRequestsListCommand extends AbstractShellCommand {
29
Charles Chan874900e2016-12-09 16:55:39 -080030 private static final String FMT = "nodeId=%s appId=%s, priority=%s, criteria=%s copy=%s";
Thomas Vachuska7f171b22015-08-21 12:49:08 -070031
32 @Override
33 protected void execute() {
34 PacketService service = get(PacketService.class);
35 if (outputJson()) {
36 // TODO: implement this
37 print("Not implemented.");
38 } else {
39 service.getRequests().forEach(this::print);
40 }
41 }
42
43 private void print(PacketRequest request) {
Charles Chan874900e2016-12-09 16:55:39 -080044 print(FMT, request.nodeId(), request.appId().name(), request.priority(),
45 request.selector().criteria(), request.copy());
Thomas Vachuska7f171b22015-08-21 12:49:08 -070046 }
47
48}