blob: 711d1fad6fa51dc1be09a488352bd095ae4fdd67 [file] [log] [blame]
Jonathan Hartfd6c1b32016-03-08 14:09:09 -08001/*
Brian O'Connord6a135a2017-08-03 22:46:05 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Hartfd6c1b32016-03-08 14:09:09 -08003 *
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
alshabib36a4d732016-06-01 16:03:59 -070017package org.opencord.olt.cli;
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080018
Saurav Das82b8e6d2018-10-04 15:25:12 -070019import java.util.Map;
20
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080021import org.apache.karaf.shell.commands.Command;
22import org.onlab.packet.VlanId;
23import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.net.ConnectPoint;
alshabib36a4d732016-06-01 16:03:59 -070025import org.opencord.olt.AccessDeviceService;
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080026
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080027/**
Saurav Das82b8e6d2018-10-04 15:25:12 -070028 * Shows provisioned (configured) subscribers. The data plane flows for the
29 * subscribers may or may not have been programmed.
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080030 */
Saurav Das82b8e6d2018-10-04 15:25:12 -070031@Command(scope = "onos", name = "volt-subscribers",
32 description = "Shows pre-provisioned subscribers")
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080033public class ShowSubscribersCommand extends AbstractShellCommand {
34
Amit Ghosh31939522018-08-16 13:28:21 +010035 private static final String FORMAT = "port=%s, svlan=%s, cvlan=%s";
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080036
37 @Override
38 protected void execute() {
39 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
40 service.getSubscribers().forEach(this::display);
41 }
42
Amit Ghosh31939522018-08-16 13:28:21 +010043 private void display(Map.Entry<ConnectPoint, Map.Entry<VlanId, VlanId>> subscriber) {
44 print(FORMAT, subscriber.getKey(), subscriber.getValue().getKey(),
45 subscriber.getValue().getValue());
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080046 }
47}