blob: 36e045e8e798a53c0f31a7a72f5927d9b44da86a [file] [log] [blame]
Jonathan Hart5af5f142016-01-28 18:45:27 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Hart5af5f142016-01-28 18:45:27 -08003 *
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
Ray Milkey86ad7bb2018-09-27 12:32:28 -070019import org.apache.karaf.shell.api.action.Command;
Ray Milkey7a2dee52018-09-28 10:58:28 -070020import org.apache.karaf.shell.api.action.lifecycle.Service;
Jonathan Hart5af5f142016-01-28 18:45:27 -080021import org.onosproject.cli.AbstractShellCommand;
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070022import org.onosproject.pim.impl.PimInterface;
23import org.onosproject.pim.impl.PimInterfaceService;
Jonathan Hart5af5f142016-01-28 18:45:27 -080024
25import java.util.Set;
26
27/**
28 * Lists the interfaces where PIM is enabled.
29 */
Ray Milkey7a2dee52018-09-28 10:58:28 -070030@Service
Jonathan Hart5af5f142016-01-28 18:45:27 -080031@Command(scope = "onos", name = "pim-interfaces",
32 description = "Lists the interfaces where PIM is enabled")
33public class PimInterfacesListCommand extends AbstractShellCommand {
34
35 private static final String FORMAT = "interfaceName=%s, holdTime=%s, priority=%s, genId=%s";
Jonathan Hart00cddda2016-02-16 10:30:37 -080036 private static final String ROUTE_FORMAT = " %s";
Jonathan Hart5af5f142016-01-28 18:45:27 -080037
38 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070039 protected void doExecute() {
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070040 PimInterfaceService interfaceService = get(PimInterfaceService.class);
Jonathan Hart5af5f142016-01-28 18:45:27 -080041
Jonathan Hartfbfe2a82016-03-29 11:36:33 -070042 Set<PimInterface> interfaces = interfaceService.getPimInterfaces();
Jonathan Hart5af5f142016-01-28 18:45:27 -080043
Jonathan Hart00cddda2016-02-16 10:30:37 -080044 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 Hart5af5f142016-01-28 18:45:27 -080051 }
52
53}