blob: 130e81e071ca96d3acce5758f246f17b3a61f021 [file] [log] [blame]
Jonathan Hart5af5f142016-01-28 18:45:27 -08001/*
2 * Copyright 2016 Open Networking Laboratory
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.onosproject.pim.cli;
18
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070021import org.onosproject.pim.impl.PimInterface;
22import org.onosproject.pim.impl.PimInterfaceService;
Jonathan Hart5af5f142016-01-28 18:45:27 -080023
24import java.util.Set;
25
26/**
27 * Lists the interfaces where PIM is enabled.
28 */
29@Command(scope = "onos", name = "pim-interfaces",
30 description = "Lists the interfaces where PIM is enabled")
31public class PimInterfacesListCommand extends AbstractShellCommand {
32
33 private static final String FORMAT = "interfaceName=%s, holdTime=%s, priority=%s, genId=%s";
Jonathan Hart00cddda2016-02-16 10:30:37 -080034 private static final String ROUTE_FORMAT = " %s";
Jonathan Hart5af5f142016-01-28 18:45:27 -080035
36 @Override
37 protected void execute() {
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070038 PimInterfaceService interfaceService = get(PimInterfaceService.class);
Jonathan Hart5af5f142016-01-28 18:45:27 -080039
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070040 Set<PimInterface> interfaces = interfaceService.getPimInterfaces();
Jonathan Hart5af5f142016-01-28 18:45:27 -080041
Jonathan Hart00cddda2016-02-16 10:30:37 -080042 interfaces.forEach(pimIntf -> {
43 print(FORMAT, pimIntf.getInterface().name(),
44 pimIntf.getHoldtime(), pimIntf.getPriority(),
45 pimIntf.getGenerationId());
46
47 pimIntf.getRoutes().forEach(route -> print(ROUTE_FORMAT, route));
48 });
Jonathan Hart5af5f142016-01-28 18:45:27 -080049 }
50
51}