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
10 package org.opendaylight.netvirt.bgpmanager.commands;
12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import java.io.PrintStream;
14 import org.apache.felix.service.command.CommandSession;
15 import org.apache.karaf.shell.commands.Command;
16 import org.apache.karaf.shell.console.OsgiCommandSupport;
17 import org.opendaylight.netvirt.bgpmanager.BgpUtil;
18 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebfd.rev190219.BfdConfig;
19 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.DcgwTepList;
23 @Command(scope = "odl", name = "bfd-cache",
24 description = "Text dump of BFD config cache")
25 @SuppressFBWarnings("DM_DEFAULT_ENCODING")
26 public class BfdCache extends OsgiCommandSupport {
27 private static final String MINRX = "min-rx";
28 private static final String MINTX = "min-tx";
29 private static final String DMULT = "detect-mult";
30 private static final String MLHOP = "multi-hop";
31 private static final String DCGWIP = "dcgw-ip";
32 private static final String TEPIP = "tep-ip";
34 private final BgpUtil bgpUtil;
36 public BfdCache(BgpUtil bgpUtil) {
37 this.bgpUtil = bgpUtil;
40 /*private Object usage() {
41 session.getConsole().println("usage: bfd-cache ");
45 public Object show(CommandSession session) throws Exception {
46 this.session = session;
50 public Object show() throws Exception {
54 @SuppressWarnings("resource")
56 protected Object doExecute() throws Exception {
58 PrintStream ps = session.getConsole();
59 BfdConfig bfdConfig = bgpUtil.getBfdConfig();
60 if (bfdConfig != null) {
61 boolean bfdEnabled = bfdConfig.isBfdEnabled();
62 ps.printf("%nbfd-enabled %s%n", bfdEnabled ? "yes" : "no");
63 int minrx = bfdConfig.getMinRx().intValue();
64 int mintx = bfdConfig.getMinTx().intValue();
65 int detectmult = bfdConfig.getDetectMult().intValue();
66 boolean multihop = bfdConfig.isMultihop();
67 ps.printf("%n\t%-15s %d%n\t%-15s %d%n\t%-15s %d%n\t%-15s %s%n",
68 MINRX, minrx, MINTX, mintx, DMULT, detectmult, MLHOP, multihop ? "yes" : "no");
70 ps.printf("%nbfd-enabled %s%n", "no");
73 DcgwTepList dcgwTepList = bgpUtil.getDcgwTepConfig();
74 if (dcgwTepList != null) {
75 dcgwTepList.getDcgwTep().values().forEach(dcgwTep -> {
76 ps.printf("%n%n%-15s %s", DCGWIP, dcgwTep.getDcGwIp());
77 dcgwTep.getTepIps().forEach(tep -> {
78 ps.printf("%n\t%-15s %s", TEPIP, tep);