blob: 4d2d5831ea635841e1d2e2d06111316d125debfc [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
Carmelo Casconeca931162019-07-15 18:22:24 -070019import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080021import org.onlab.packet.VlanId;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.ConnectPoint;
alshabib36a4d732016-06-01 16:03:59 -070024import org.opencord.olt.AccessDeviceService;
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080025
Carmelo Casconeca931162019-07-15 18:22:24 -070026import java.util.Map;
27
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080028/**
Saurav Das82b8e6d2018-10-04 15:25:12 -070029 * Shows provisioned (configured) subscribers. The data plane flows for the
30 * subscribers may or may not have been programmed.
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080031 */
Carmelo Casconeca931162019-07-15 18:22:24 -070032@Service
Saurav Das82b8e6d2018-10-04 15:25:12 -070033@Command(scope = "onos", name = "volt-subscribers",
34 description = "Shows pre-provisioned subscribers")
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080035public class ShowSubscribersCommand extends AbstractShellCommand {
36
Amit Ghosh31939522018-08-16 13:28:21 +010037 private static final String FORMAT = "port=%s, svlan=%s, cvlan=%s";
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080038
39 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070040 protected void doExecute() {
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080041 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
42 service.getSubscribers().forEach(this::display);
43 }
44
Amit Ghosh31939522018-08-16 13:28:21 +010045 private void display(Map.Entry<ConnectPoint, Map.Entry<VlanId, VlanId>> subscriber) {
46 print(FORMAT, subscriber.getKey(), subscriber.getValue().getKey(),
47 subscriber.getValue().getValue());
Jonathan Hartfd6c1b32016-03-08 14:09:09 -080048 }
49}