2 * Copyright (c) 2017 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.Argument;
12 import org.apache.karaf.shell.commands.Command;
13 import org.apache.karaf.shell.commands.Option;
14 import org.apache.karaf.shell.console.OsgiCommandSupport;
15 import org.omg.CORBA.Object;
16 import org.opendaylight.netvirt.bgpmanager.BgpManager;
17 import org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi;
18 import org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi;
20 @Command(scope = "odl", name = "multipath", description = "Enable/Disable multipaths")
21 public class Multipath extends OsgiCommandSupport {
23 private static final String AF = "--address-family";
24 private static final String RD = "--rd";
25 private static final String MAXPATH = "--maxpath";
27 @Option(name = RD, aliases = { "-r" },
33 @Option(name = MAXPATH, aliases = { "-n" },
34 description = "max number of paths",
39 @Option(name = AF, aliases = {"-f"},
40 description = "Address family",
41 required = true, multiValued = false)
46 @Argument(name = "enable|disable|setmaxpath",
47 description = "The desired operation",
48 required = true, multiValued = false)
50 String multipathEnable;
53 protected Object doExecute() throws Exception {
55 if (!Commands.bgpRunning(session.getConsole())) {
59 BgpManager bm = Commands.getBgpManager();
64 if (addrFamily != null) {
65 if (!addrFamily.equals("lu")) {
66 session.getConsole().println("error: " + AF + " must be lu");
70 // for WP 3 Qbgp, only IP/MPLS_VPN supported
72 safi = af_safi.SAFI_MPLS_VPN;
75 if (multipathEnable != null) {
77 switch (multipathEnable) {
79 bm.enableMultipath(afi, safi);
82 bm.disableMultipath(afi, safi);
85 if (rd != null && maxpath != null) {
86 bm.multipaths(rd, Integer.parseInt(maxpath));
98 private Object usage() {
99 session.getConsole().println("odl:multipath -f lu <enable|disable> \n"
100 + "odl:multipath -f lu -r <rd> -n <maxpath> setmaxpath");