Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 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.onosproject.pim.cli; |
| 18 | |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 19 | import org.apache.karaf.shell.api.action.Command; |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
Jonathan Hart | fbfe2a8 | 2016-03-29 11:36:33 -0700 | [diff] [blame] | 22 | import org.onosproject.pim.impl.PimInterface; |
| 23 | import org.onosproject.pim.impl.PimInterfaceService; |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 24 | |
| 25 | import java.util.Set; |
| 26 | |
| 27 | /** |
| 28 | * Lists the interfaces where PIM is enabled. |
| 29 | */ |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 30 | @Service |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 31 | @Command(scope = "onos", name = "pim-interfaces", |
| 32 | description = "Lists the interfaces where PIM is enabled") |
| 33 | public class PimInterfacesListCommand extends AbstractShellCommand { |
| 34 | |
| 35 | private static final String FORMAT = "interfaceName=%s, holdTime=%s, priority=%s, genId=%s"; |
Jonathan Hart | 00cddda | 2016-02-16 10:30:37 -0800 | [diff] [blame] | 36 | private static final String ROUTE_FORMAT = " %s"; |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 37 | |
| 38 | @Override |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 39 | protected void doExecute() { |
Jonathan Hart | fbfe2a8 | 2016-03-29 11:36:33 -0700 | [diff] [blame] | 40 | PimInterfaceService interfaceService = get(PimInterfaceService.class); |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 41 | |
Jonathan Hart | fbfe2a8 | 2016-03-29 11:36:33 -0700 | [diff] [blame] | 42 | Set<PimInterface> interfaces = interfaceService.getPimInterfaces(); |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 43 | |
Jonathan Hart | 00cddda | 2016-02-16 10:30:37 -0800 | [diff] [blame] | 44 | interfaces.forEach(pimIntf -> { |
| 45 | print(FORMAT, pimIntf.getInterface().name(), |
| 46 | pimIntf.getHoldtime(), pimIntf.getPriority(), |
| 47 | pimIntf.getGenerationId()); |
| 48 | |
| 49 | pimIntf.getRoutes().forEach(route -> print(ROUTE_FORMAT, route)); |
| 50 | }); |
Jonathan Hart | 5af5f14 | 2016-01-28 18:45:27 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | } |