use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class VpnInterfaceManager method updateVpnInterfaceOnTepDelete.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateVpnInterfaceOnTepDelete(VpnInterfaceOpDataEntry vpnInterface, StateTunnelList stateTunnelList, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
String prefix = null;
long label = 0;
boolean isNextHopRemoveReqd = false;
String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
String vpnName = vpnInterface.getVpnInstanceName();
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
String primaryRd = VpnUtil.getVpnRd(dataBroker, vpnName);
if (adjList != null) {
List<Adjacency> value = new ArrayList<>();
LOG.info("updateVpnInterfaceOnTepDelete: AdjacencyList for interface {} on dpn {} vpn {} is {}", vpnInterface.getName(), vpnInterface.getDpnId(), vpnInterface.getVpnInstanceName(), adjList);
for (Adjacency adj : adjList) {
List<String> nhList = new ArrayList<>();
String rd = adj.getVrfId();
rd = rd != null ? rd : vpnName;
prefix = adj.getIpAddress();
List<String> nextHopList = adj.getNextHopIpList();
label = adj.getLabel();
if (nextHopList != null && !nextHopList.isEmpty()) {
isNextHopRemoveReqd = true;
}
// Secondary adj nexthop will continue to point to primary adj IP address.
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
} else {
Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
if (!vrfEntryOptional.isPresent()) {
continue;
}
nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
if (nhList.contains(srcTepIp)) {
nhList.remove(srcTepIp);
isNextHopRemoveReqd = true;
}
value.add(adj);
}
if (isNextHopRemoveReqd) {
updateLabelMapper(label, nhList);
LOG.info("updateVpnInterfaceOnTepDelete: Updated label mapper : label {} dpn {} prefix {}" + " nexthoplist {} vpn {} vpnid {} rd {} interface {}", label, srcDpnId, prefix, nhList, vpnName, vpnId, rd, vpnInterface.getName());
// Update the VRF entry with removed nextHop
fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, false, writeConfigTxn);
// Get the list of VPN's importing this route(prefix) .
// Then update the VRF entry with nhList
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, false, writeConfigTxn);
LOG.info("updateVpnInterfaceOnTepDelete: Exported route with rd {} prefix {} nhList {}" + " label {} interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName, vpn.getVpnInstanceName(), vpnRd);
}
}
// Withdraw prefix from BGP only for external vpn.
try {
if (!rd.equalsIgnoreCase(vpnName)) {
bgpManager.withdrawPrefix(rd, prefix);
}
LOG.info("updateVpnInterfaceOnTepDelete: Withdrawn rd {} prefix {} nhList {} label {}" + " for interface {} on dpn {} vpn {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName);
} catch (Exception ex) {
LOG.error("updateVpnInterfaceOnTepDelete: Exception when withdrawing prefix {} nh {} label {}" + " on rd {} for interface {} on dpn {} vpn {}", prefix, nhList, label, rd, vpnInterface.getName(), srcDpnId, vpnName, ex);
}
}
}
AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
VpnInterfaceOpDataEntry opInterface = new VpnInterfaceOpDataEntryBuilder(vpnInterface).setKey(new VpnInterfaceOpDataEntryKey(vpnInterface.getName(), vpnName)).addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, WriteTransaction.CREATE_MISSING_PARENTS);
LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}", vpnInterface.getName(), srcDpnId, vpnName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class AclServiceUtils method getFlowForAllowedAddresses.
public static Map<String, List<MatchInfoBase>> getFlowForAllowedAddresses(List<AllowedAddressPairs> syncAllowedAddresses, Map<String, List<MatchInfoBase>> flowMatchesMap, boolean isSourceIpMacMatch) {
if (flowMatchesMap == null) {
return null;
}
Map<String, List<MatchInfoBase>> updatedFlowMatchesMap = new HashMap<>();
MatchInfoBase ipv4Match = MatchEthernetType.IPV4;
MatchInfoBase ipv6Match = MatchEthernetType.IPV6;
for (Entry<String, List<MatchInfoBase>> entry : flowMatchesMap.entrySet()) {
String flowName = entry.getKey();
List<MatchInfoBase> flows = entry.getValue();
// iterate over allow address pair and update match type
for (AllowedAddressPairs aap : syncAllowedAddresses) {
List<MatchInfoBase> matchInfoBaseList;
String flowId;
if (flows.contains(ipv4Match) && isIPv4Address(aap) && isNotIpv4AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv4_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
} else if (flows.contains(ipv6Match) && !isIPv4Address(aap) && isNotIpv6AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv6_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
}
}
}
return updatedFlowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method addPrefix.
public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, long lbl, long l3vni, long l2vni, String gatewayMac) {
for (String nh : nhList) {
Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
Long label = lbl;
InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(BgpConstants.DEFAULT_ETH_TAG);
buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
update(iid, networksBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method multipaths.
public void multipaths(String rd, int maxpath) {
InstanceIdentifier.InstanceIdentifierBuilder<VrfMaxpath> iib = InstanceIdentifier.builder(Bgp.class).child(VrfMaxpath.class, new VrfMaxpathKey(rd));
VrfMaxpath dto = new VrfMaxpathBuilder().setRd(rd).setMaxpaths(maxpath).build();
update(iib.build(), dto);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class ExternalRoutersListener method changeLocalVpnIdToBgpVpnId.
/**
* router association to vpn.
*
* @param routerName - Name of router
* @param routerId - router id
* @param bgpVpnName BGP VPN name
*/
public void changeLocalVpnIdToBgpVpnId(String routerName, long routerId, String bgpVpnName, WriteTransaction writeFlowInvTx, ProviderTypes extNwProvType) {
LOG.debug("changeLocalVpnIdToBgpVpnId : Router associated to BGP VPN");
if (chkExtRtrAndSnatEnbl(new Uuid(routerName))) {
long bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnName);
LOG.debug("changeLocalVpnIdToBgpVpnId : BGP VPN ID value {} ", bgpVpnId);
if (bgpVpnId != NatConstants.INVALID_ID) {
LOG.debug("changeLocalVpnIdToBgpVpnId : Populate the router-id-name container with the " + "mapping BGP VPN-ID {} -> BGP VPN-NAME {}", bgpVpnId, bgpVpnName);
RouterIds rtrs = new RouterIdsBuilder().setKey(new RouterIdsKey(bgpVpnId)).setRouterId(bgpVpnId).setRouterName(bgpVpnName).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getRoutersIdentifier(bgpVpnId), rtrs);
// Get the allocated Primary NAPT Switch for this router
LOG.debug("changeLocalVpnIdToBgpVpnId : Router ID value {} ", routerId);
LOG.debug("changeLocalVpnIdToBgpVpnId : Update the Router ID {} to the BGP VPN ID {} ", routerId, bgpVpnId);
addOrDelDefaultFibRouteForSnatWithBgpVpn(routerName, routerId, bgpVpnId, true, writeFlowInvTx);
// Get the group ID
BigInteger primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
createGroupId(getGroupIdKey(routerName));
installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, true, writeFlowInvTx, extNwProvType);
}
}
}
Aggregations