2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netvirt.bgpmanager;
11 import java.io.PrintStream;
12 import java.util.Date;
13 import org.apache.karaf.shell.commands.Command;
14 import org.apache.karaf.shell.commands.Option;
15 import org.apache.karaf.shell.console.OsgiCommandSupport;
16 import org.apache.thrift.transport.TTransport;
17 import org.opendaylight.netvirt.bgpmanager.commands.Cache;
20 @Command(scope = "odl", name = "display-bgp-config", description = "")
21 public class DisplayBgpConfigCli extends OsgiCommandSupport {
23 @Option(name = "--debug", description = "print debug time stamps",
24 required = false, multiValued = false)
25 Boolean debug = false;
27 private final BgpManager bgpManager;
29 public DisplayBgpConfigCli(BgpManager bgpManager) {
30 this.bgpManager = bgpManager;
34 protected Object doExecute() {
35 PrintStream ps = session.getConsole();
38 ps.printf("%nis ODL Connected to Q-BGP: %s%n", bgpManager.isBgpConnected() ? "TRUE" : "FALSE");
39 final TTransport transport = bgpManager.getBgpConfigurationManager().getTransport();
40 if (transport != null) {
41 ps.printf("%nODL BGP Router transport is open: %s%n",
42 transport.isOpen() ? "TRUE" : "FALSE");
44 ps.printf("%nODL BGP Router transport is NULL%n");
46 //last ODL connection attempted TS
47 ps.printf("Last ODL connection attempt TS: %s%n", new Date(bgpManager.getConnectTS()));
48 //last successful connected TS
49 ps.printf("Last Successful connection TS: %s%n", new Date(bgpManager.getLastConnectedTS()));
50 //last ODL started BGP due to configuration trigger TS
51 ps.printf("Last ODL started BGP at: %s%n", new Date(bgpManager.getStartTS()));
52 //last Quagga attempted to RESTART the connection
53 ps.printf("Last Quagga BGP, sent reSync at: %s%n", new Date(bgpManager.getQbgprestartTS()));
55 //stale cleanup start - end TS
56 ps.printf("Time taken to create stale fib : %s ms%n",
57 bgpManager.getStaleEndTime() - bgpManager.getStaleStartTime());
59 //Config replay start - end TS
60 ps.printf("Time taken to create replay configuration : %s ms%n",
61 bgpManager.getCfgReplayEndTime() - bgpManager.getCfgReplayStartTime());
64 ps.printf("Time taken for Stale FIB cleanup : %s ms%n", bgpManager.getStaleCleanupTime());
66 ps.printf("Total stale entries created %d %n", bgpManager.getBgpConfigurationManager()
67 .getTotalStaledCount());
68 ps.printf("Total stale entries cleared %d %n", bgpManager.getBgpConfigurationManager().getTotalCleared());
70 Cache cache = new Cache(bgpManager);
71 return cache.show(session);