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;
16 @Command(scope = "odl", name = "bgp-vrf",
17 description = "Add or delete BGP VRFs")
18 public class Vrf extends OsgiCommandSupport {
19 private static final String RD = "--rd";
20 private static final String IR = "--import-rts";
21 private static final String ER = "--export-rts";
23 @Argument(name="add|del", description="The desired operation",
24 required=true, multiValued = false)
25 private String action = null;
27 @Option(name=RD, aliases={"-r"},
28 description="Route distinguisher",
29 required=false, multiValued=false)
30 private String rd = null;
32 @Option(name=IR, aliases={"-i"},
33 description="Import route-targets",
34 required=false, multiValued=true)
35 private List<String> irts = null;
37 @Option(name=ER, aliases={"-e"},
38 description="Export route-targets",
39 required=false, multiValued=true)
40 private List<String> erts = null;
42 private Object usage() {
44 "usage: bgp-vrf ["+RD+" rd] [<"+IR+" | "+ER+"> rt1] .. [<"+
45 IR+" | "+ER+"> rtN] <add|del>");
50 protected Object doExecute() throws Exception {
51 if (!Commands.bgpRunning()) {
54 BgpManager bm = Commands.getBgpManager();
57 if (rd == null || irts == null || erts == null) {
58 System.err.println("error: all options needed");
61 // check: rd exists? rd & rt's in format?
62 bm.addVrf(rd, irts, erts);
66 System.err.println("error: "+RD+" needed");
69 if (irts != null || erts != null) {
70 System.err.println("error: some option(s) not needed; ignored");
72 // check: rd exists? in format?