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-connect",
16 description = "Add or delete client connection to BGP Config Server")
17 public class Connect extends OsgiCommandSupport {
18 private static final String HOST = "--host";
19 private static final String PORT = "--port";
21 @Argument(name="add|del", description="The desired operation",
22 required=true, multiValued = false)
25 @Option(name=HOST, aliases={"-h"},
26 description="IP address of the server",
27 required=false, multiValued=false)
30 @Option(name=PORT, aliases={"-p"},
31 description="Thrift port", required=false,
35 private Object usage() {
37 "usage: bgp-connect ["+HOST+" h] ["+PORT+" p] <add | del>");
42 protected Object doExecute() throws Exception {
43 if (!Commands.bgpRunning()) {
46 BgpManager bm = Commands.getBgpManager();
49 if (host == null || port == null) {
50 System.err.println("error: "+HOST+" and "+PORT+" needed");
53 if (!Commands.isValid(host, Commands.IPADDR, HOST)
54 || !Commands.isValid(port, Commands.INT, PORT)) {
57 // check: already connected?
58 bm.startConfig(host, Integer.valueOf(port));
61 if (host != null || port != null) {
62 System.err.println("note: option(s) not needed; ignored");
64 // check: nothing to stop?