blob: 6615002eca657bfda795f13d92922e19896911b2 [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
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.meter.MeterKey;
Gamze Abaka1b7816e2019-11-25 06:38:41 +000022import org.opencord.olt.internalapi.AccessDeviceMeterService;
Gamze Abaka33feef52019-02-27 08:16:47 +000023
24import java.util.Set;
25
26/**
27 * Shows information about device-meter mappings that have been programmed in the
28 * data-plane.
29 */
30@Command(scope = "onos", name = "volt-programmed-meters",
31 description = "Shows device-meter mappings programmed in the data-plane")
32public class ShowProgrammedMetersCommand extends AbstractShellCommand {
33
34 @Override
35 protected void execute() {
Gamze Abaka1b7816e2019-11-25 06:38:41 +000036 AccessDeviceMeterService service = AbstractShellCommand.get(AccessDeviceMeterService.class);
Gamze Abaka33feef52019-02-27 08:16:47 +000037 Set<MeterKey> programmedMeters = service.getProgMeters();
38 programmedMeters.forEach(this::display);
39 }
40
41 private void display(MeterKey meterKey) {
42 print("device=%s meter=%s", meterKey.deviceId(), meterKey.meterId());
43 }
44}