Gamze Abaka | 33feef5 | 2019-02-27 08:16:47 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.opencord.olt.cli; |
| 18 | |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Gamze Abaka | 33feef5 | 2019-02-27 08:16:47 +0000 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.net.meter.MeterKey; |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 23 | import org.opencord.olt.internalapi.AccessDeviceMeterService; |
Gamze Abaka | 33feef5 | 2019-02-27 08:16:47 +0000 | [diff] [blame] | 24 | |
| 25 | import java.util.Set; |
| 26 | |
| 27 | /** |
| 28 | * Shows information about device-meter mappings that have been programmed in the |
| 29 | * data-plane. |
| 30 | */ |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 31 | @Service |
Gamze Abaka | 33feef5 | 2019-02-27 08:16:47 +0000 | [diff] [blame] | 32 | @Command(scope = "onos", name = "volt-programmed-meters", |
| 33 | description = "Shows device-meter mappings programmed in the data-plane") |
| 34 | public class ShowProgrammedMetersCommand extends AbstractShellCommand { |
| 35 | |
| 36 | @Override |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 37 | protected void doExecute() { |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 38 | AccessDeviceMeterService service = AbstractShellCommand.get(AccessDeviceMeterService.class); |
Gamze Abaka | 33feef5 | 2019-02-27 08:16:47 +0000 | [diff] [blame] | 39 | Set<MeterKey> programmedMeters = service.getProgMeters(); |
| 40 | programmedMeters.forEach(this::display); |
| 41 | } |
| 42 | |
| 43 | private void display(MeterKey meterKey) { |
| 44 | print("device=%s meter=%s", meterKey.deviceId(), meterKey.meterId()); |
| 45 | } |
| 46 | } |