blob: 22acb5780338bcfcd773792d7d22c19e303c709f [file] [log] [blame]
Saurav Das82b8e6d2018-10-04 15:25:12 -07001/*
2 * Copyright 2016-present Open Networking Foundation
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
17package org.opencord.olt.cli;
18
Carmelo Casconeca931162019-07-15 18:22:24 -070019import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
Saurav Das82b8e6d2018-10-04 15:25:12 -070021import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.net.ConnectPoint;
23import org.opencord.olt.AccessDeviceService;
24import org.opencord.sadis.SubscriberAndDeviceInformation;
25
Carmelo Casconeca931162019-07-15 18:22:24 -070026import java.util.Map;
27
Saurav Das82b8e6d2018-10-04 15:25:12 -070028/**
29 * Shows subscriber information for those subscriber which have been programmed
30 * in the data-plane.
31 */
Carmelo Casconeca931162019-07-15 18:22:24 -070032@Service
Saurav Das82b8e6d2018-10-04 15:25:12 -070033@Command(scope = "onos", name = "volt-programmed-subscribers",
34 description = "Shows subscribers programmed in the dataplane")
35public class ShowProgrammedSubscribersCommand extends AbstractShellCommand {
36
37 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070038 protected void doExecute() {
Saurav Das82b8e6d2018-10-04 15:25:12 -070039 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
40 Map<ConnectPoint, SubscriberAndDeviceInformation> info = service.getProgSubs();
41 info.forEach(this::display);
42 }
43
44 private void display(ConnectPoint cp, SubscriberAndDeviceInformation sub) {
45 print("location=%s subscriber=%s", cp, sub);
46 }
47}