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.bgpmanager.commands;
11 import org.apache.karaf.shell.commands.*;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.bgpmanager.BgpManager;
15 @Command(scope = "odl", name = "bgp-rtr",
16 description = "Add or delete BGP router instance")
17 public class Router extends OsgiCommandSupport {
18 private static final String AS = "--as-number";
19 private static final String RID = "--router-id";
20 private static final String SP = "--stale-path-time";
21 private static final String FB = "--f-bit";
23 @Argument(name="add|del", description="The desired operation",
24 required=true, multiValued = false)
25 private String action = null;
27 @Option(name=AS, aliases={"-a"},
28 description="AS number",
29 required=false, multiValued=false)
30 private String asNum = null;
32 @Option(name=RID, aliases={"-r"},
33 description="Router ID",
34 required=false, multiValued=false)
35 private String rid = null;
37 @Option(name=SP, aliases={"-s"},
38 description="Stale-path time",
39 required=false, multiValued=false)
40 private String spt = null;
42 @Option(name=FB, aliases={"-f"},
44 required=false, multiValued=false)
45 private String fbit = null;
47 private Object usage() {
49 "usage: bgp-rtr ["+AS+" as-number] ["+RID+" router-id] ["
50 +SP+" stale-path-time] ["+FB+" on|off] <add | del>");
55 protected Object doExecute() throws Exception {
56 if (!Commands.bgpRunning()) {
59 BgpManager bm = Commands.getBgpManager();
62 // check: rtr already running?
67 System.err.println("error: "+AS+" is needed");
70 if (!Commands.isValid(asNum, Commands.INT, AS)) {
73 asn = Integer.valueOf(asNum);
75 !Commands.isValid(rid, Commands.IPADDR, RID)) {
79 if (!Commands.isValid(spt, Commands.INT, SP)) {
82 s = Integer.valueOf(spt);
94 System.err.println("error: "+FB+" must be on or off");
98 bm.startBgp(asn, rid, s, fb);
101 // check: nothing to stop?
102 if (asNum != null || rid != null || spt != null ||
104 System.err.println("note: option(s) not needed; ignored");