blob: 5a398b807d6d81101e612dabc5b37c6e83762afb [file] [log] [blame]
Jonathan Hart6b045582016-02-03 10:00:08 -08001/*
Jonathan Hartf4bd0482017-01-27 15:11:18 -08002 * Copyright 2017-present Open Networking Laboratory
Jonathan Hart6b045582016-02-03 10:00:08 -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.routing.fpm.cli;
18
19import org.apache.karaf.shell.commands.Command;
20import org.onlab.util.Tools;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.routing.fpm.FpmInfoService;
23
Jonathan Hart6b045582016-02-03 10:00:08 -080024/**
25 * Displays the current FPM connections.
26 */
27@Command(scope = "onos", name = "fpm-connections",
28 description = "Displays the current FPM connections")
29public class FpmConnectionsList extends AbstractShellCommand {
30
31 private static final String FORMAT = "%s:%s connected since %s";
32
33 @Override
34 protected void execute() {
Jonathan Hartf4bd0482017-01-27 15:11:18 -080035 FpmInfoService fpmInfo = AbstractShellCommand.get(FpmInfoService.class);
Jonathan Hart6b045582016-02-03 10:00:08 -080036
Jonathan Hartb10f1e72017-05-02 16:36:26 -070037 fpmInfo.peers().forEach((peer, timestamp) -> {
38 print(FORMAT, peer.address(), peer.port(), Tools.timeAgo(timestamp));
Jonathan Hart6b045582016-02-03 10:00:08 -080039 });
40 }
41}