blob: 924400a535894f4f4c21db70fba1535815308080 [file] [log] [blame]
Jonathan Hartc4f681c2016-09-09 07:14:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Hartc4f681c2016-09-09 07:14:25 -07003 *
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.cli.net;
18
Ray Milkeyd84f89b2018-08-17 14:54:17 -070019import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
Jonathan Hartc4f681c2016-09-09 07:14:25 -070021import org.onosproject.cli.AbstractShellCommand;
Ray Milkeyfacf2862017-08-03 11:58:29 -070022import org.onosproject.net.intf.Interface;
Ray Milkeyb65d7842017-08-03 16:28:24 -070023import org.onosproject.net.neighbour.NeighbourResolutionService;
Jonathan Hartc4f681c2016-09-09 07:14:25 -070024
25/**
26 * Lists neighbour message handlers.
27 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070028@Service
Jonathan Hartc4f681c2016-09-09 07:14:25 -070029@Command(scope = "onos", name = "neighbour-handlers",
30 description = "Lists neighbour message handlers")
31public class NeighbourHandlersListCommand extends AbstractShellCommand {
32
33 private static final String FORMAT = "%20s: interface=%s, class=%s";
34
35 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070036 protected void doExecute() {
Jonathan Hartc4f681c2016-09-09 07:14:25 -070037 NeighbourResolutionService service = get(NeighbourResolutionService.class);
38
39 service.getHandlerRegistrations().forEach((cp, list) -> {
40 list.forEach(hr -> print(FORMAT, cp, intfToName(hr.intf()),
41 hr.handler().getClass().getCanonicalName()));
42 });
43 }
44
45 private String intfToName(Interface intf) {
46 return (intf == null) ? "(None)" : intf.name();
47 }
48}