use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project bgpcep by opendaylight.
the class MACIpAdvRParser method serializeKeyModel.
private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
builder.setEthernetTagId(extractETI(evpn));
builder.setMacAddress(extractMAC(evpn));
builder.setIpAddress(extractIp(evpn));
return builder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project bgpcep by opendaylight.
the class TableTypeActivatorTest method testActivator.
@Test
public void testActivator() {
final TableTypeActivator tableTypeActivator = new TableTypeActivator();
final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(EVPN);
Assert.assertEquals(L2VPNEVPN.class, afiSafiType.get());
final Optional<BgpTableType> tableType = registry.getTableType(L2VPNEVPN.class);
Assert.assertEquals(EVPN, tableType.get());
tableTypeActivator.stopBGPTableTypeRegistryProvider();
tableTypeActivator.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.
the class Cache method doExecute.
@SuppressWarnings("resource")
@Override
protected Object doExecute() {
boolean listVrfs = false;
boolean listNets = false;
PrintStream ps = session.getConsole();
if (action != null) {
return usage();
}
PrintStream fileStream = null;
if (ofile != null) {
try {
fileStream = new PrintStream(ofile);
ps = fileStream;
} catch (FileNotFoundException e) {
session.getConsole().println("error: cannot create file " + ofile + "; exception: " + e);
return null;
}
}
if (list != null) {
for (String item : list) {
switch(item) {
case "vrfs":
listVrfs = true;
break;
case "networks":
listNets = true;
break;
default:
session.getConsole().println("error: unknown value for " + LST + ": " + item);
if (fileStream != null) {
fileStream.close();
}
return null;
}
}
}
// we'd normally read this directly from 'config' but
// legacy behaviour forces to check for a connection
// that's initiated by default at startup without
// writing to config.
String configHost = bgpManager.getConfigHost();
int configPort = bgpManager.getConfigPort();
ps.printf("%nConfiguration Server%n\t%s %s%n\t%s %d%n", HTSTR, configHost, PTSTR, configPort);
Bgp config = bgpManager.getConfig();
if (config == null) {
if (fileStream != null) {
fileStream.close();
}
return null;
}
AsId asId = config.getAsId();
if (asId != null) {
int asNum = asId.getLocalAs().intValue();
IpAddress routerId = asId.getRouterId();
Long spt = asId.getStalepathTime();
Boolean afb = asId.isAnnounceFbit();
String rid = routerId == null ? "<n/a>" : new String(routerId.getValue());
// F-bit is always set to ON (hardcoded), in SDN even though the controller is down
// forwarding state shall be retained.
String bit = "ON";
GracefulRestart gracefulRestart = config.getGracefulRestart();
if (gracefulRestart != null) {
spt = gracefulRestart.getStalepathTime();
}
ps.printf("%nBGP Router%n");
ps.printf("\t%-15s %d%n\t%-15s %s%n\t%-15s %s%n\t%-15s %s%n", ASSTR, asNum, RISTR, rid, SPSTR, spt == null || spt == 0 ? "default" : spt.toString(), FBSTR, bit);
}
Logging logging = config.getLogging();
if (logging != null) {
ps.printf("\t%-15s %s%n\t%-15s %s%n", LFSTR, logging.getFile(), LLSTR, logging.getLevel());
}
List<Neighbors> neighbors = config.getNeighbors();
if (neighbors != null) {
ps.printf("%nNeighbors%n");
for (Neighbors nbr : neighbors) {
ps.printf("\t%s%n\t\t%-16s %d%n", nbr.getAddress().getValue(), ASSTR, nbr.getRemoteAs().intValue());
EbgpMultihop en = nbr.getEbgpMultihop();
if (en != null) {
ps.printf("\t\t%-16s %d%n", EBSTR, en.getNhops().intValue());
}
UpdateSource us = nbr.getUpdateSource();
if (us != null) {
ps.printf("\t\t%-16s %s%n", USSTR, us.getSourceIp().getValue());
}
ps.printf("\t\t%-16s IPv4-Labeled-VPN", AFSTR);
List<AddressFamilies> afs = nbr.getAddressFamilies();
if (afs != null) {
for (AddressFamilies af : afs) {
// Should not print "unknown" in vpnv4 case
if (!(af.getSafi().intValue() == 5 && af.getAfi().intValue() == 1)) {
if (af.getSafi().intValue() == 4 && af.getAfi().intValue() == 1) {
ps.printf(" %s", "IPv4-Labeled-Unicast");
} else if (af.getSafi().intValue() == 5 && af.getAfi().intValue() == 2) {
ps.printf(" %s", "IPv6-Labeled-VPN");
} else if (af.getSafi().intValue() == 6) {
ps.printf(" %s", "Ethernet-VPN");
} else {
ps.printf(" %s", "Unknown");
}
}
}
}
ps.printf("%n");
}
}
if (listVrfs) {
List<Vrfs> vrfs = config.getVrfs();
if (vrfs != null) {
ps.printf("%nVRFs%n");
for (Vrfs vrf : vrfs) {
ps.printf("\t%s%n", vrf.getRd());
ps.printf("\t\t%s ", IRSTR);
for (String rt : vrf.getImportRts()) {
ps.printf("%s ", rt);
}
ps.printf("%n\t\t%s ", ERSTR);
for (String rt : vrf.getExportRts()) {
ps.printf("%s ", rt);
}
for (AddressFamiliesVrf adf : vrf.getAddressFamiliesVrf()) {
ps.printf("%n\t\tafi %d safi %d", adf.getAfi(), adf.getSafi());
}
ps.printf("%n");
}
}
}
if (listNets) {
List<Networks> ln = config.getNetworks();
if (ln != null) {
ps.printf("%nNetworks%n");
for (Networks net : ln) {
String rd = net.getRd();
String pfxlen = net.getPrefixLen();
String nh = net.getNexthop().getValue();
int label = net.getLabel().intValue();
ps.printf("\t%s%n\t\t%-7s %s%n\t\t%-7s %s%n\t\t%-7s %d%n", pfxlen, RDSTR, rd, NHSTR, nh, LBSTR, label);
}
}
}
List<Multipath> mp = config.getMultipath();
List<VrfMaxpath> vrfm = config.getVrfMaxpath();
if (mp != null) {
ps.printf("%nMultipath%n");
for (Multipath multipath : mp) {
int afi = multipath.getAfi().intValue();
int safi = multipath.getSafi().intValue();
Boolean enabled = multipath.isMultipathEnabled();
if (enabled) {
if (afi == 1 && safi == 5) {
ps.printf("\t%-16s %s%n%n", AFSTR, "vpnv4");
} else if (afi == 2 && safi == 5) {
ps.printf("\t%-16s %s%n%n", AFSTR, "vpnv6");
} else if (afi == 3 && safi == 6) {
ps.printf("\t%-16s %s%n%n", AFSTR, "evpn");
} else {
ps.printf("\t%-16s %s%n%n", AFSTR, "Unknown");
}
if (vrfm != null) {
ps.printf("\t%-16s %s%n", RDSTR, MPSTR);
for (VrfMaxpath vrfMaxpath : vrfm) {
String rd = vrfMaxpath.getRd();
int maxpath = vrfMaxpath.getMaxpaths();
ps.printf("\t%-16s %d%n", rd, maxpath);
}
}
}
}
}
if (fileStream != null) {
fileStream.close();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.
the class Neighbor method doExecute.
@Override
protected Object doExecute() {
switch(action) {
case "add":
if (nbrIp == null) {
session.getConsole().println("error: " + IP + " needed");
return null;
}
if (bgpManager.getConfig() == null) {
session.getConsole().println("error: Bgp config is not present");
return null;
}
long asn = 0;
int hops = 0;
if (!Commands.isValid(session.getConsole(), nbrIp, Commands.Validators.IPADDR, IP)) {
return null;
}
if (asNum != null) {
if (!Commands.isValid(session.getConsole(), asNum, Commands.Validators.INT, AS)) {
return null;
} else {
asn = Long.parseLong(asNum);
}
}
TcpMd5SignaturePasswordType md5Secret = null;
if (md5PasswordOption != null) {
try {
md5Secret = new TcpMd5SignaturePasswordType(md5PasswordOption);
} catch (IllegalArgumentException e) {
session.getConsole().println(new StringBuilder("error: invalid MD5 password ").append(e.getMessage()).toString());
return null;
}
}
bgpManager.addNeighbor(nbrIp, asn, md5Secret);
if (multiHops != null) {
if (!Commands.isValid(session.getConsole(), multiHops, Commands.Validators.INT, MH)) {
return null;
} else {
hops = Integer.parseInt(multiHops);
}
bgpManager.addEbgpMultihop(nbrIp, hops);
}
if (srcIp != null) {
if (!Commands.isValid(session.getConsole(), srcIp, Commands.Validators.IPADDR, US)) {
return null;
}
bgpManager.addUpdateSource(nbrIp, srcIp);
}
if (addrFamily != null) {
if (!addrFamily.equals("lu") && !addrFamily.equals("vpnv4") && !addrFamily.equals("vpnv6") && !addrFamily.equals("evpn")) {
session.getConsole().println("error: " + AF + " must be lu/evpn/vpnv4/vpnv6 ");
return null;
}
af_afi afi;
af_safi safi;
if (addrFamily.equals("vpnv6")) {
afi = af_afi.findByValue(2);
safi = af_safi.findByValue(5);
} else if (addrFamily.equals("evpn")) {
afi = af_afi.findByValue(3);
safi = af_safi.findByValue(6);
} else if (addrFamily.equals("lu")) {
afi = af_afi.findByValue(1);
safi = af_safi.findByValue(4);
} else {
// vpnv4
afi = af_afi.findByValue(1);
safi = af_safi.findByValue(5);
}
bgpManager.addAddressFamily(nbrIp, afi, safi);
}
break;
case "del":
if (nbrIp == null) {
session.getConsole().println("error: " + IP + " needed");
return null;
}
if (!Commands.isValid(session.getConsole(), nbrIp, Commands.Validators.IPADDR, IP)) {
return null;
}
if (asNum != null || multiHops != null || srcIp != null || addrFamily != null) {
session.getConsole().println("note: some option(s) not needed; ignored");
}
bgpManager.deleteNeighbor(nbrIp);
break;
default:
return usage();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.
the class VrfEntryListener method removeFibEntries.
// This method is temporary. Eventually Factory design pattern will be used to get
// right VrfEntryhandle and invoke its methods.
private void removeFibEntries(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
if (VrfEntry.EncapType.Vxlan.equals(vrfEntry.getEncapType())) {
LOG.info("EVPN flows to be deleted");
EvpnVrfEntryHandler evpnVrfEntryHandler = new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler, nextHopManager, jobCoordinator, elanManager, fibUtil);
evpnVrfEntryHandler.removeFlows(identifier, vrfEntry, rd);
closeables.add(evpnVrfEntryHandler);
return;
}
RouterInterface routerInt = vrfEntry.getAugmentation(RouterInterface.class);
if (routerInt != null) {
// ping responder for router interfaces
routerInterfaceVrfEntryHandler.removeFlows(identifier, vrfEntry, rd);
return;
}
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
deleteFibEntries(identifier, vrfEntry);
return;
}
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
bgpRouteVrfEntryHandler.removeFlows(identifier, vrfEntry, rd);
return;
}
}
Aggregations