blob: eb1b47dbe3f6b18d5748ef6f4b21bc62778543c2 [file] [log] [blame]
Gamze Abaka33feef52019-02-27 08:16:47 +00001/*
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;
Gamze Abaka33feef52019-02-27 08:16:47 +000021import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.net.meter.MeterKey;
Andrea Campanellacbbb7952019-11-25 06:38:41 +000023import org.opencord.olt.internalapi.AccessDeviceMeterService;
Gamze Abaka33feef52019-02-27 08:16:47 +000024
Andrea Campanellacbbb7952019-11-25 06:38:41 +000025import java.util.Collection;
Gamze Abaka33feef52019-02-27 08:16:47 +000026import java.util.Map;
27
Carmelo Casconeca931162019-07-15 18:22:24 -070028@Service
Gamze Abaka33feef52019-02-27 08:16:47 +000029@Command(scope = "onos", name = "volt-bpmeter-mappings",
30 description = "Shows information about bandwidthProfile-meterKey (device / meter) mappings")
31public class ShowBpMeterMappingsCommand extends AbstractShellCommand {
32
33 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070034 protected void doExecute() {
Andrea Campanellacbbb7952019-11-25 06:38:41 +000035 AccessDeviceMeterService service = AbstractShellCommand.get(AccessDeviceMeterService.class);
36 Map<String, Collection<MeterKey>> bpMeterMappings = service.getBpMeterMappings();
Gamze Abaka33feef52019-02-27 08:16:47 +000037 bpMeterMappings.forEach(this::display);
38 }
39
Andrea Campanellacbbb7952019-11-25 06:38:41 +000040 private void display(String bpInfo, Collection<MeterKey> meterKeyList) {
Gamze Abaka33feef52019-02-27 08:16:47 +000041 meterKeyList.forEach(meterKey ->
42 print("bpInfo=%s deviceId=%s meterId=%s",
43 bpInfo, meterKey.deviceId(), meterKey.meterId()));
44
45 }
46}