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.commands;
11 import org.apache.karaf.shell.commands.*;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.netvirt.bgpmanager.BgpManager;
15 @Command(scope = "odl", name = "bgp-misc",
16 description = "Add or delete miscellaneous BGP config options")
17 public class Misc extends OsgiCommandSupport {
18 private static final String LF = "--log-file";
19 private static final String LL = "--log-level";
20 private static final String SP = "--stalepath-time";
22 @Argument(name="add|del", description="The desired operation",
23 required=true, multiValued = false)
24 private String action = null;
26 @Option(name=LF, aliases={"-f"},
27 description="Log file name",
28 required=false, multiValued=false)
29 private String file = null;
31 @Option(name=LL, aliases={"-l"},
32 description="Log level", required=false,
34 private String level = null;
36 @Option(name=SP, aliases={"-s"},
37 description="Stale-path time", required=false,
39 private String spt = null;
41 private Object usage() {
43 "usage: bgp-misc [<"+LF+" name> <"+LL+" level>] ["
44 +SP+" stale-path-time] <add | del>");
48 private boolean isValidLevel(String level) {
66 protected Object doExecute() throws Exception {
67 if (!Commands.bgpRunning()) {
70 if (spt == null && file == null && level == null) {
73 if (file != null ^ level != null) {
76 if (level != null && !isValidLevel(level)) {
77 System.err.println("error: invalid value for "+LL);
80 BgpManager bm = Commands.getBgpManager();
83 if (spt != null && Commands.isValid(spt, Commands.INT, SP)) {
84 int s = Integer.valueOf(spt);
87 if (file != null && level != null)
88 bm.setQbgpLog(file, level);
92 bm.delGracefulRestart();
94 if (file != null && level != null) {