Jonathan Hart | fd6c1b3 | 2016-03-08 14:09:09 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | d6a135a | 2017-08-03 22:46:05 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Jonathan Hart | fd6c1b3 | 2016-03-08 14:09:09 -0800 | [diff] [blame] | 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 | |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 17 | package org.opencord.olt.cli; |
Jonathan Hart | fd6c1b3 | 2016-03-08 14:09:09 -0800 | [diff] [blame] | 18 | |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onlab.packet.VlanId; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.net.ConnectPoint; |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 23 | import org.opencord.olt.AccessDeviceService; |
Jonathan Hart | fd6c1b3 | 2016-03-08 14:09:09 -0800 | [diff] [blame] | 24 | |
| 25 | import java.util.Map; |
| 26 | |
| 27 | /** |
| 28 | * Shows provisioned subscribers. |
| 29 | */ |
| 30 | @Command(scope = "onos", name = "subscribers", |
| 31 | description = "Shows provisioned subscribers") |
| 32 | public class ShowSubscribersCommand extends AbstractShellCommand { |
| 33 | |
| 34 | private static final String FORMAT = "port=%s, cvlan=%s"; |
| 35 | |
| 36 | @Override |
| 37 | protected void execute() { |
| 38 | AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class); |
| 39 | service.getSubscribers().forEach(this::display); |
| 40 | } |
| 41 | |
| 42 | private void display(Map.Entry<ConnectPoint, VlanId> subscriber) { |
| 43 | print(FORMAT, subscriber.getKey(), subscriber.getValue()); |
| 44 | } |
| 45 | } |