use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.
the class BgpConfigurationManager method addVrf.
// TODO: add LayerType as arg - supports command
public void addVrf(String rd, List<String> irts, List<String> erts, AddressFamily addressFamily) {
Vrfs vrf = bgpUtil.getVrfFromRd(rd);
List<AddressFamiliesVrf> adfList = new ArrayList<>(1);
if (vrf != null) {
adfList = new ArrayList<AddressFamiliesVrf>(vrf.nonnullAddressFamiliesVrf().values());
}
AddressFamiliesVrfBuilder adfBuilder = new AddressFamiliesVrfBuilder();
if (addressFamily.equals(AddressFamily.IPV4)) {
adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
} else if (addressFamily.equals(AddressFamily.IPV6)) {
adfBuilder.setAfi((long) af_afi.AFI_IPV6.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
} else if (addressFamily.equals(AddressFamily.L2VPN)) {
adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_EVPN.getValue());
}
AddressFamiliesVrf adf = adfBuilder.build();
adfList.add(adf);
InstanceIdentifier.InstanceIdentifierBuilder<Vrfs> iib = InstanceIdentifier.builder(Bgp.class).child(VrfsContainer.class).child(Vrfs.class, new VrfsKey(rd));
InstanceIdentifier<Vrfs> iid = iib.build();
Vrfs dto = new VrfsBuilder().setRd(rd).setImportRts(irts).setExportRts(erts).setAddressFamiliesVrf(adfList).build();
List<AddressFamiliesVrf> listAdFamilies = mapNewAdFamily.get(rd);
if (listAdFamilies != null) {
listAdFamilies.add(adf);
} else {
mapNewAdFamily.put(rd, adfList);
}
try {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, iid, dto);
} catch (TransactionCommitFailedException e) {
LOG.error("Error adding VRF to datastore", e);
throw new RuntimeException(e);
}
// enable multipath by default in all VRFs
setMultipaths(rd, BgpConstants.BGP_DEFAULT_MULTIPATH);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.
the class ConfigureBgpCli method addNeighbor.
protected void addNeighbor() {
if (!validateAsNumber(asNumber)) {
printAddNeighborHelp();
return;
}
boolean validIp = validateIp(ip);
if (!validIp) {
session.getConsole().println("invalid neighbor ip");
printAddNeighborHelp();
return;
}
TcpMd5SignaturePasswordType md5secret = null;
if (md5passwordOption != null) {
try {
md5secret = new TcpMd5SignaturePasswordType(md5passwordOption);
} catch (IllegalArgumentException e) {
session.getConsole().println(new StringBuilder("invalid MD5 password: ").append(e.getMessage()).toString());
printAddNeighborHelp();
return;
}
}
if (sourceIp != null) {
validIp = validateIp(sourceIp);
if (!validIp) {
session.getConsole().println("invalid source ip");
printAddNeighborHelp();
return;
}
}
if (ebgpMultihops != null) {
try {
long val = Long.parseLong(ebgpMultihops);
if (val < 1 || val > 255) {
session.getConsole().println("invalid ebgpMultihops number , valid range [1,255] " + ebgpMultihops);
printAddNeighborHelp();
return;
}
} catch (NumberFormatException e) {
session.getConsole().println("invalid ebgpMultihops number, valid range [1-255]" + ebgpMultihops);
printAddNeighborHelp();
return;
}
}
if (addressFamily != null) {
if (!addressFamily.equals("lu") && !addressFamily.equals("vpnv4") && !addressFamily.equals("vpnv6") && !addressFamily.equals("evpn")) {
session.getConsole().println("error: Address family must be lu/evpn/vpnv4/vpnv6 ");
return;
}
int afi;
int safi;
if (addressFamily.equals("vpnv6")) {
afi = 2;
safi = 5;
} else if (addressFamily.equals("evpn")) {
afi = 3;
safi = 6;
} else if (addressFamily.equals("lu")) {
afi = 1;
safi = 4;
} else if (addressFamily.equals("vpnv4")) {
afi = 1;
safi = 5;
} else {
session.getConsole().println("invalid addressFamily valid values lu/evpn/vpnv4/vpnv6");
printAddNeighborHelp();
return;
}
}
if (getAsNumber(ip) != -1) {
session.getConsole().println("neighbor with ip " + ip + " already exists");
return;
}
bgpConfigurationManager.addNeighbor(ip, Long.parseLong(asNumber), md5secret);
if (addressFamily != null) {
bgpConfigurationManager.addAddressFamily(ip, af_afi.AFI_IP.getValue(), af_safi.valueOf(addressFamily).getValue());
}
if (ebgpMultihops != null) {
bgpConfigurationManager.addEbgpMultihop(ip, Integer.parseInt(ebgpMultihops));
}
if (sourceIp != null) {
bgpConfigurationManager.addUpdateSource(ip, sourceIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.
the class FibDSWriter method removeVrfSubFamilyFromDS.
public synchronized void removeVrfSubFamilyFromDS(String rd, AddressFamily addressFamily) {
if (rd == null) {
return;
}
LOG.debug("removeVrfSubFamilyFromDS : addressFamily {} from vrf rd {}", addressFamily, rd);
InstanceIdentifier<VrfTables> id = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
try {
VrfTables vrfTable = singleTxDB.syncRead(LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable != null) {
Map<VrfEntryKey, VrfEntry> keyVrfEntryMap = vrfTable.getVrfEntry();
if (keyVrfEntryMap == null) {
LOG.error("removeVrfSubFamilyFromDS : VrfEntry not found for rd {}", rd);
return;
}
for (VrfEntry vrfEntry : keyVrfEntryMap.values()) {
boolean found = false;
if (vrfEntry.getEncapType() != null) {
if (!vrfEntry.getEncapType().equals(EncapType.Mplsgre) && addressFamily == AddressFamily.L2VPN) {
found = true;
} else if (vrfEntry.getEncapType().equals(EncapType.Mplsgre)) {
if (addressFamily == AddressFamily.IPV4 && FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix())) {
found = true;
} else if (addressFamily == AddressFamily.IPV6 && FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix())) {
found = true;
}
}
}
if (found == false) {
continue;
}
bgpUtil.removeVrfEntry(rd, vrfEntry);
}
}
} catch (ReadFailedException rfe) {
LOG.error("removeVrfSubFamilyFromDS : Internal Error rd {}", rd, rfe);
}
return;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class SimpleBGPTableTypeRegistryProvider method registerBGPTableType.
@Override
public synchronized AbstractRegistration registerBGPTableType(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final Class<? extends AfiSafiType> afiSafiType) {
final BgpTableType tableType = new BgpTableTypeImpl(afi, safi);
final Class<? extends AfiSafiType> prev = this.tableTypes.putIfAbsent(tableType, afiSafiType);
Preconditions.checkState(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
final TablesKey tableKey = new TablesKey(tableType.getAfi(), tableType.getSafi());
this.tableKeys.put(tableKey, afiSafiType);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (SimpleBGPTableTypeRegistryProvider.this) {
SimpleBGPTableTypeRegistryProvider.this.tableTypes.remove(tableType);
SimpleBGPTableTypeRegistryProvider.this.tableKeys.remove(tableKey);
}
}
};
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class MldpP2mpLspParser method serialize.
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp();
final ByteBuf opaqueValues = Unpooled.buffer();
final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily());
if (!serializeOpaqueList(mldpP2mpLsp.getOpaqueValue(), opaqueValues) || addressFamily == 0) {
return NO_TUNNEL_INFORMATION_PRESENT;
}
final IpAddress rootNode = mldpP2mpLsp.getRootNodeAddress();
ByteBufWriteUtil.writeUnsignedByte(P2MP_TYPE, buffer);
ByteBufWriteUtil.writeUnsignedShort(addressFamily, buffer);
ByteBufWriteUtil.writeUnsignedByte(getAdressFamilyLength(rootNode), buffer);
serializeIpAddress(rootNode, buffer);
ByteBufWriteUtil.writeUnsignedShort(opaqueValues.readableBytes(), buffer);
buffer.writeBytes(opaqueValues);
return TunnelType.MLDP_P2MP_LSP.getIntValue();
}
Aggregations