blob: ee9423b0b7dd5df730b4180926b8ea76913b5569 [file] [log] [blame]
Thomas Vachuska7f171b22015-08-21 12:49:08 -07001/*
2 * Copyright 2015 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 */
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
Madan Jampani52bb4852015-12-11 15:55:44 -080030 private static final String FMT = "nodeId=%s appId=%s, priority=%s, criteria=%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) {
Madan Jampani52bb4852015-12-11 15:55:44 -080044 print(FMT, request.nodeId(), request.appId().name(), request.priority(), request.selector().criteria());
Thomas Vachuska7f171b22015-08-21 12:49:08 -070045 }
46
47}