Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.cli.net; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Command; |
| 19 | import org.onosproject.cli.AbstractShellCommand; |
| 20 | import org.onosproject.net.packet.PacketRequest; |
| 21 | import org.onosproject.net.packet.PacketService; |
| 22 | |
| 23 | /** |
| 24 | * Lists packet requests. |
| 25 | */ |
| 26 | @Command(scope = "onos", name = "packet-requests", |
| 27 | description = "Lists packet requests") |
| 28 | public class PacketRequestsListCommand extends AbstractShellCommand { |
| 29 | |
Madan Jampani | 52bb485 | 2015-12-11 15:55:44 -0800 | [diff] [blame] | 30 | private static final String FMT = "nodeId=%s appId=%s, priority=%s, criteria=%s"; |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 31 | |
| 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 Jampani | 52bb485 | 2015-12-11 15:55:44 -0800 | [diff] [blame] | 44 | print(FMT, request.nodeId(), request.appId().name(), request.priority(), request.selector().criteria()); |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } |