Code Review
/
netvirt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Revert "bgpmanager VPNv6 shell command update"
[netvirt.git]
/
vpnservice
/
bgpmanager
/
bgpmanager-impl
/
src
/
main
/
java
/
org
/
opendaylight
/
netvirt
/
bgpmanager
/
commands
/
Network.java
diff --git
a/vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/commands/Network.java
b/vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/commands/Network.java
index 95f117cec2e641ca1e116f07db06ca281922724e..a2269dc42f16c8e5949853feae65cdf910ae12e6 100644
(file)
--- a/
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/commands/Network.java
+++ b/
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/commands/Network.java
@@
-8,6
+8,7
@@
package org.opendaylight.netvirt.bgpmanager.commands;
package org.opendaylight.netvirt.bgpmanager.commands;
+import java.util.List;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
@@
-15,13
+16,12
@@
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.opendaylight.netvirt.bgpmanager.BgpManager;
import org.opendaylight.netvirt.bgpmanager.thrift.gen.qbgpConstants;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.netvirt.bgpmanager.BgpManager;
import org.opendaylight.netvirt.bgpmanager.thrift.gen.qbgpConstants;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
@Command(scope = "odl", name = "bgp-network",
@Command(scope = "odl", name = "bgp-network",
-
description = "Add or delete BGP static routes")
+ description = "Add or delete BGP static routes")
public class Network extends OsgiCommandSupport {
private static final String RD = "--rd";
private static final String PFX = "--prefix";
public class Network extends OsgiCommandSupport {
private static final String RD = "--rd";
private static final String PFX = "--prefix";
@@
-29,83
+29,84
@@
public class Network extends OsgiCommandSupport {
private static final String LB = "--label";
static final Logger LOGGER = LoggerFactory.getLogger(Network.class);
private static final String LB = "--label";
static final Logger LOGGER = LoggerFactory.getLogger(Network.class);
- @Argument(name
="add|del", description=
"The desired operation",
-
required=
true, multiValued = false)
+ @Argument(name
= "add|del", description =
"The desired operation",
+
required =
true, multiValued = false)
private String action = null;
private String action = null;
- @Option(name
=RD, aliases=
{"-r"},
- description
=
"Route distinguisher",
- required
=false, multiValued=
false)
+ @Option(name
= RD, aliases =
{"-r"},
+ description
=
"Route distinguisher",
+ required
= false, multiValued =
false)
private String rd = null;
private String rd = null;
- @Option(name
=PFX, aliases=
{"-p"},
- description
=
"prefix/length",
- required
=false, multiValued=
false)
+ @Option(name
= PFX, aliases =
{"-p"},
+ description
=
"prefix/length",
+ required
= false, multiValued =
false)
private String pfx = null;
private String pfx = null;
- @Option(name
=NH, aliases=
{"-n"},
- description
=
"Nexthop",
- required
=false, multiValued=
true)
+ @Option(name
= NH, aliases =
{"-n"},
+ description
=
"Nexthop",
+ required
= false, multiValued =
true)
private List<String> nh = null;
private List<String> nh = null;
- @Option(name
=LB, aliases=
{"-l"},
- description
=
"Label",
- required
=false, multiValued=
false)
+ @Option(name
= LB, aliases =
{"-l"},
+ description
=
"Label",
+ required
= false, multiValued =
false)
private String lbl = null;
private RouteOrigin staticOrigin = RouteOrigin.STATIC;
private Object usage() {
private String lbl = null;
private RouteOrigin staticOrigin = RouteOrigin.STATIC;
private Object usage() {
-
System.err
.println(
-
"usage: bgp-network ["+RD+" rd] ["+PFX+
" prefix/len] ["
-
+NH+" nexthop] ["+LB+
" label] <add|del>");
+
session.getConsole()
.println(
+
"usage: bgp-network [" + RD + " rd] [" + PFX +
" prefix/len] ["
+
+ NH + " nexthop] [" + LB +
" label] <add|del>");
return null;
}
@Override
protected Object doExecute() throws Exception {
return null;
}
@Override
protected Object doExecute() throws Exception {
- if (!Commands.bgpRunning()) {
+ if (!Commands.bgpRunning(
session.getConsole()
)) {
return null;
}
BgpManager bm = Commands.getBgpManager();
switch (action) {
case "add":
int label = qbgpConstants.LBL_EXPLICIT_NULL;
return null;
}
BgpManager bm = Commands.getBgpManager();
switch (action) {
case "add":
int label = qbgpConstants.LBL_EXPLICIT_NULL;
- if (pfx == null
) {
-
System.err.println("error: "+PFX+
" is needed");
+ if (pfx == null) {
+
session.getConsole().println("error: " + PFX +
" is needed");
return null;
}
if (nh == null) {
return null;
}
if (nh == null) {
-
System.err.println("error: "+NH+
" is needed");
+
session.getConsole().println("error: " + NH +
" is needed");
return null;
}
//TODO: syntactic validation of prefix
for (String nextHop : nh) {
return null;
}
//TODO: syntactic validation of prefix
for (String nextHop : nh) {
- if (!Commands.isValid(
nextHop, Command
s.IPADDR, NH)) {
+ if (!Commands.isValid(
session.getConsole(), nextHop, Commands.Validator
s.IPADDR, NH)) {
return null;
}
}
if (lbl != null) {
return null;
}
}
if (lbl != null) {
- if (!Commands.isValid(
lbl, Command
s.INT, LB)) {
+ if (!Commands.isValid(
session.getConsole(), lbl, Commands.Validator
s.INT, LB)) {
return null;
} else {
label = Integer.valueOf(lbl);
}
} else if (rd == null) {
return null;
} else {
label = Integer.valueOf(lbl);
}
} else if (rd == null) {
-
System.err.println("error: "+RD+
" is needed");
+
session.getConsole().println("error: " + RD +
" is needed");
return null;
}
LOGGER.info("ADD: Adding Fib entry rd {} prefix {} nexthop {} label {}", rd, pfx, nh, label);
return null;
}
LOGGER.info("ADD: Adding Fib entry rd {} prefix {} nexthop {} label {}", rd, pfx, nh, label);
- bm.addPrefix(rd, pfx, nh, label, staticOrigin);
+ bm.addPrefix(rd, null /*maAddress*/, pfx, nh,
+ VrfEntry.EncapType.Mplsgre, label, 0 /*l3vni*/, null /*gatewayMacAddress*/, staticOrigin);
LOGGER.info("ADD: Added Fib entry rd {} prefix {} nexthop {} label {}", rd, pfx, nh, label);
break;
case "del":
if (pfx == null) {
LOGGER.info("ADD: Added Fib entry rd {} prefix {} nexthop {} label {}", rd, pfx, nh, label);
break;
case "del":
if (pfx == null) {
-
System.err.println("error: "+PFX+
" is needed");
+
session.getConsole().println("error: " + PFX +
" is needed");
return null;
}
if (nh != null || lbl != null) {
return null;
}
if (nh != null || lbl != null) {
-
System.err
.println("note: some option(s) not needed; ignored");
+
session.getConsole()
.println("note: some option(s) not needed; ignored");
}
LOGGER.info("REMOVE: Removing Fib entry rd {} prefix {}", rd, pfx);
bm.deletePrefix(rd, pfx);
}
LOGGER.info("REMOVE: Removing Fib entry rd {} prefix {}", rd, pfx);
bm.deletePrefix(rd, pfx);