blob: 413272bc727454b3399918c6ac87c8302b0364a5 [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;
Andrea Campanellacbbb7952019-11-25 06:38:41 +000024import org.opencord.sadis.UniTagInformation;
Saurav Das82b8e6d2018-10-04 15:25:12 -070025
Carmelo Casconeca931162019-07-15 18:22:24 -070026import java.util.Map;
Andrea Campanellacbbb7952019-11-25 06:38:41 +000027import java.util.Set;
Carmelo Casconeca931162019-07-15 18:22:24 -070028
Saurav Das82b8e6d2018-10-04 15:25:12 -070029/**
30 * Shows subscriber information for those subscriber which have been programmed
31 * in the data-plane.
32 */
Carmelo Casconeca931162019-07-15 18:22:24 -070033@Service
Saurav Das82b8e6d2018-10-04 15:25:12 -070034@Command(scope = "onos", name = "volt-programmed-subscribers",
35 description = "Shows subscribers programmed in the dataplane")
36public class ShowProgrammedSubscribersCommand extends AbstractShellCommand {
37
38 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070039 protected void doExecute() {
Saurav Das82b8e6d2018-10-04 15:25:12 -070040 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
Andrea Campanellacbbb7952019-11-25 06:38:41 +000041 Map<ConnectPoint, Set<UniTagInformation>> info = service.getProgSubs();
Saurav Das82b8e6d2018-10-04 15:25:12 -070042 info.forEach(this::display);
43 }
44
Andrea Campanellacbbb7952019-11-25 06:38:41 +000045 private void display(ConnectPoint cp, Set<UniTagInformation> uniTagInformation) {
46 uniTagInformation.forEach(uniTag ->
47 print("location=%s tagInformation=%s", cp, uniTag));
Saurav Das82b8e6d2018-10-04 15:25:12 -070048 }
49}