use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class ExternalRoutersListener method removeNaptFibExternalOutputFlows.
protected void removeNaptFibExternalOutputFlows(long routerId, BigInteger dpnId, Uuid networkId, @Nonnull Collection<String> externalIps, WriteTransaction writeFlowInvTx) {
long extVpnId = NatConstants.INVALID_ID;
if (networkId != null) {
Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
if (vpnUuid != null) {
extVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
} else {
LOG.debug("removeNaptFibExternalOutputFlows : vpnUuid is null");
}
} else {
LOG.debug("removeNaptFibExternalOutputFlows : networkId is null");
extVpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
}
if (extVpnId == NatConstants.INVALID_ID) {
LOG.warn("removeNaptFibExternalOutputFlows : extVpnId not found for routerId {}", routerId);
extVpnId = routerId;
}
for (String ip : externalIps) {
String extIp = removeMaskFromIp(ip);
String naptFlowRef = getFlowRefNaptPreFib(dpnId, NwConstants.NAPT_PFIB_TABLE, extVpnId);
LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in table {} for the active switch" + " with the DPN ID {} and router ID {} and IP {} flowRef {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId, extIp, naptFlowRef);
FlowEntity natPfibVpnFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, naptFlowRef);
mdsalManager.removeFlowToTx(natPfibVpnFlowEntity, writeFlowInvTx);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class ExternalRoutersListener method advToBgpAndInstallFibAndTsFlows.
public void advToBgpAndInstallFibAndTsFlows(final BigInteger dpnId, final short tableId, final String vpnName, final long routerId, final String routerName, final String externalIp, final Uuid extNetworkId, final Routers router, final WriteTransaction writeFlowInvTx) {
LOG.debug("advToBgpAndInstallFibAndTsFlows : entry for DPN ID {}, tableId {}, vpnname {} " + "and externalIp {}", dpnId, tableId, vpnName, externalIp);
String nextHopIp = NatUtil.getEndpointIpAddressForDPN(dataBroker, dpnId);
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
if (rd == null || rd.isEmpty()) {
LOG.error("advToBgpAndInstallFibAndTsFlows : Unable to get RD for VPN Name {}", vpnName);
return;
}
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, extNetworkId);
if (extNwProvType == null) {
LOG.error("advToBgpAndInstallFibAndTsFlows : External Network Provider Type missing");
return;
}
if (extNwProvType == ProviderTypes.VXLAN) {
WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
evpnSnatFlowProgrammer.evpnAdvToBgpAndInstallFibAndTsFlows(dpnId, tableId, externalIp, vpnName, rd, nextHopIp, writeTx, routerId, routerName, writeFlowInvTx);
return;
}
// Generate VPN label for the external IP
GenerateVpnLabelInput labelInput = new GenerateVpnLabelInputBuilder().setVpnName(vpnName).setIpPrefix(externalIp).build();
Future<RpcResult<GenerateVpnLabelOutput>> labelFuture = vpnService.generateVpnLabel(labelInput);
// On successful generation of the VPN label, advertise the route to the BGP and install the FIB routes.
ListenableFuture<RpcResult<Void>> future = Futures.transformAsync(JdkFutureAdapters.listenInPoolThread(labelFuture), (AsyncFunction<RpcResult<GenerateVpnLabelOutput>, RpcResult<Void>>) result -> {
if (result.isSuccessful()) {
LOG.debug("advToBgpAndInstallFibAndTsFlows : inside apply with result success");
GenerateVpnLabelOutput output = result.getResult();
final long label = output.getLabel();
int externalIpInDsFlag = 0;
List<IpMap> dbIpMaps = NaptManager.getIpMapList(dataBroker, routerId);
if (dbIpMaps != null) {
for (IpMap dbIpMap : dbIpMaps) {
String dbExternalIp = dbIpMap.getExternalIp();
if (dbExternalIp.contains(externalIp)) {
String dbInternalIp = dbIpMap.getInternalIp();
IpMapKey dbIpMapKey = dbIpMap.getKey();
LOG.debug("advToBgpAndInstallFibAndTsFlows : Setting label {} for internalIp {} " + "and externalIp {}", label, dbInternalIp, externalIp);
IpMap newIpm = new IpMapBuilder().setKey(dbIpMapKey).setInternalIp(dbInternalIp).setExternalIp(dbExternalIp).setLabel(label).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, naptManager.getIpMapIdentifier(routerId, dbInternalIp), newIpm);
externalIpInDsFlag++;
}
}
if (externalIpInDsFlag <= 0) {
LOG.debug("advToBgpAndInstallFibAndTsFlows : External Ip {} not found in DS, " + "Failed to update label {} for routerId {} in DS", externalIp, label, routerId);
String errMsg = String.format("Failed to update label %s due to external Ip %s not" + " found in DS for router %s", label, externalIp, routerId);
return Futures.immediateFailedFuture(new Exception(errMsg));
}
} else {
LOG.error("advToBgpAndInstallFibAndTsFlows : Failed to write label {} for externalIp {} for" + " routerId {} in DS", label, externalIp, routerId);
}
long l3vni = 0;
if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
l3vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, l3vni).longValue();
}
Routers extRouter = router != null ? router : NatUtil.getRoutersFromConfigDS(dataBroker, routerName);
Uuid externalSubnetId = NatUtil.getExternalSubnetForRouterExternalIp(externalIp, extRouter);
NatUtil.addPrefixToBGP(dataBroker, bgpManager, fibManager, vpnName, rd, externalSubnetId, externalIp, nextHopIp, extRouter.getNetworkId().getValue(), null, label, l3vni, RouteOrigin.STATIC, dpnId);
List<Instruction> tunnelTableCustomInstructions = new ArrayList<>();
tunnelTableCustomInstructions.add(new InstructionGotoTable(tableId).buildInstruction(0));
makeTunnelTableEntry(dpnId, label, l3vni, tunnelTableCustomInstructions, writeFlowInvTx, extNwProvType);
makeLFibTableEntry(dpnId, label, tableId, writeFlowInvTx);
List<Instruction> fibTableCustomInstructions = createFibTableCustomInstructions(tableId, routerName, externalIp);
if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
NatUtil.makePreDnatToSnatTableEntry(mdsalManager, dpnId, NwConstants.INBOUND_NAPT_TABLE, writeFlowInvTx);
}
String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(dataBroker, externalSubnetId);
String externalVpn = vpnName;
if (externalSubnet.isPresent()) {
externalVpn = externalSubnetId.getValue();
}
CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(externalVpn).setSourceDpid(dpnId).setIpAddress(fibExternalIp).setServiceId(label).setIpAddressSource(CreateFibEntryInput.IpAddressSource.ExternalFixedIP).setInstruction(fibTableCustomInstructions).build();
Future<RpcResult<Void>> future1 = fibService.createFibEntry(input);
return JdkFutureAdapters.listenInPoolThread(future1);
} else {
LOG.error("advToBgpAndInstallFibAndTsFlows : inside apply with result failed");
String errMsg = String.format("Could not retrieve the label for prefix %s in VPN %s, %s", externalIp, vpnName, result.getErrors());
return Futures.immediateFailedFuture(new RuntimeException(errMsg));
}
}, MoreExecutors.directExecutor());
Futures.addCallback(future, new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("advToBgpAndInstallFibAndTsFlows : Error in generate label or fib install process", error);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("advToBgpAndInstallFibAndTsFlows : Successfully installed custom FIB routes for prefix {}", externalIp);
} else {
LOG.error("advToBgpAndInstallFibAndTsFlows : Error in rpc call to create custom Fib entries " + "for prefix {} in DPN {}, {}", externalIp, dpnId, result.getErrors());
}
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method handleTepDelForAllRtrs.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private boolean handleTepDelForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp, String destTepIp, WriteTransaction writeFlowInvTx) {
LOG.trace("handleTepDelForAllRtrs : TEP DEL ----- for EXTERNAL/HWVTEP ITM Tunnel,TYPE {},State is UP b/w SRC IP" + " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
// When tunnel EP is deleted on a DPN , VPN gets two deletion event.
// One for a DPN on which tunnel EP was deleted and another for other-end DPN.
// Handle only the DPN on which it was deleted , ignore other event.
// DPN on which TEP is deleted , endpoint IP will be null.
String endpointIpForDPN = null;
try {
endpointIpForDPN = NatUtil.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
} catch (Exception e) {
/* this dpn does not have the VTEP */
LOG.error("handleTepDelForAllRtrs : DPN {} does not have the VTEP", srcDpnId);
endpointIpForDPN = null;
}
if (endpointIpForDPN != null) {
LOG.trace("handleTepDelForAllRtrs : Ignore TEP DELETE event received for DPN {} VTEP IP {} since its " + "the other end DPN w.r.t the delted TEP", srcDpnId, srcTepIp);
return false;
}
List<RoutersList> routersList = null;
InstanceIdentifier<DpnRoutersList> dpnRoutersListId = NatUtil.getDpnRoutersId(srcDpnId);
Optional<DpnRoutersList> optionalRouterDpnList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListId);
if (optionalRouterDpnList.isPresent()) {
routersList = optionalRouterDpnList.get().getRoutersList();
} else {
LOG.warn("handleTepDelForAllRtrs : RouterDpnList is empty for DPN {}.Hence ignoring TEP DEL event " + "for the ITM TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
if (routersList == null) {
LOG.error("handleTepDelForAllRtrs : DPN {} does not have the Routers presence", srcDpnId);
return false;
}
for (RoutersList router : routersList) {
String routerName = router.getRouter();
LOG.debug("handleTepDelForAllRtrs : TEP DEL : DNAT -> Withdrawing routes for router {} ", routerName);
long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("handleTepDelForAllRtrs :Invalid ROUTER-ID {} returned for routerName {}", routerId, routerName);
return false;
}
Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
if (extNwProvType == null) {
return false;
}
hndlTepDelForDnatInEachRtr(router, routerId, srcDpnId, extNwProvType);
LOG.debug("handleTepDelForAllRtrs : TEP DEL : SNAT -> Withdrawing and Advertising routes for router {} ", router.getRouter());
hndlTepDelForSnatInEachRtr(router, routerId, srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName, extNwProvType, writeFlowInvTx);
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method hndlTepAddForAllRtrs.
private boolean hndlTepAddForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp, String destTepIp, WriteTransaction writeFlowInvTx) {
LOG.trace("hndlTepAddForAllRtrs: TEP ADD ----- for EXTERNAL/HWVTEP ITM Tunnel, TYPE {} ,State is UP b/w SRC IP" + " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
InstanceIdentifier<DpnRoutersList> dpnRoutersListId = NatUtil.getDpnRoutersId(srcDpnId);
Optional<DpnRoutersList> optionalRouterDpnList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListId);
if (!optionalRouterDpnList.isPresent()) {
LOG.info("hndlTepAddForAllRtrs : RouterDpnList model is empty for DPN {}. Hence ignoring TEP add event " + "for the ITM TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
List<RoutersList> routersList = optionalRouterDpnList.get().getRoutersList();
if (routersList == null) {
LOG.debug("hndlTepAddForAllRtrs : Ignoring TEP add for the DPN {} since no routers are associated" + " for the DPN having the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and" + "TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
String nextHopIp = NatUtil.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
for (RoutersList router : routersList) {
String routerName = router.getRouter();
long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddForAllRtrs :Invalid ROUTER-ID {} returned for routerName {}", routerId, routerName);
return false;
}
LOG.debug("hndlTepAddForAllRtrs : TEP ADD : DNAT -> Advertising routes for router {} ", routerName);
Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
if (extNwProvType == null) {
return false;
}
hndlTepAddForDnatInEachRtr(router, routerId, nextHopIp, srcDpnId, extNwProvType, writeFlowInvTx);
LOG.debug("hndlTepAddForAllRtrs : TEP ADD : SNAT -> Advertising routes for router {} ", routerName);
hndlTepAddForSnatInEachRtr(router, routerId, srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName, nextHopIp, extNwProvType, writeFlowInvTx);
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method hndlTepAddOnNaptSwitch.
private boolean hndlTepAddOnNaptSwitch(BigInteger srcDpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, long routerId, Optional<Routers> routerData, String nextHopIp, Uuid vpnName, ProviderTypes extNwProvType, WriteTransaction writeFlowInvTx) {
if (!routerData.isPresent()) {
LOG.warn("hndlTepAddOnNaptSwitch: routerData is not present");
return false;
}
Routers router = routerData.get();
String routerName = router.getRouterName();
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Processing TEP add for the DPN {} having the router {} since " + "its THE NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} " + "and TUNNEL NAME {} ", srcDpnId, routerName, tunnelType, srcTepIp, destTepIp, tunnelName);
Uuid networkId = router.getNetworkId();
if (networkId == null) {
LOG.warn("hndlTepAddOnNaptSwitch : SNAT -> Ignoring TEP add since the router {} is not associated to the " + "external network", routerName);
return false;
}
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Router {} is associated with Ext nw {}", routerId, networkId);
Long vpnId;
if (vpnName == null) {
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Internal VPN associated to router {}", routerId);
vpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
if (vpnId == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddOnNaptSwitch : Invalid External VPN-ID returned for routerName {}", routerName);
return false;
}
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved External VPN-ID {} for router {}", vpnId, routerId);
} else {
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Private BGP VPN associated to router {}", routerId);
vpnId = NatUtil.getVpnId(dataBroker, vpnName.getValue());
if (vpnId == null || vpnId == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddOnNaptSwitch : Invalid vpnId returned for routerName {}", routerName);
return false;
}
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerId);
}
/*1) Withdraw the old route to the external IP from the BGP which was having the
next hop as the old TEP IP.
2) Advertise to the BGP about the new route to the external IP having the
new TEP IP as the next hop.
3) Populate a new FIB entry with the next hop IP as the new TEP IP using the
FIB manager.
*/
// Withdraw the old route to the external IP from the BGP which was having the
// next hop as the old TEP IP.
final String externalVpnName = NatUtil.getAssociatedVPN(dataBroker, networkId);
if (externalVpnName == null) {
LOG.error("hndlTepAddOnNaptSwitch : SNAT -> No VPN associated with ext nw {} in router {}", networkId, routerId);
return false;
}
Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
LOG.debug("hndlTepAddOnNaptSwitch : Clearing the FIB entries but not the BGP routes");
for (String externalIp : externalIps) {
String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
LOG.debug("hndlTepAddOnNaptSwitch : Removing Fib entry rd {} prefix {}", rd, externalIp);
fibManager.removeFibEntry(rd, externalIp, null);
}
/*
Advertise to the BGP about the new route to the external IP having the
new TEP IP as the next hop.
Populate a new FIB entry with the next hop IP as the new TEP IP using the
FIB manager.
*/
String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
if (extNwProvType == null) {
return false;
}
String gwMacAddress = null;
long l3Vni = 0;
if (extNwProvType == ProviderTypes.VXLAN) {
// Get the External Gateway MAC Address which is Router gateway MAC address for SNAT
gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
if (gwMacAddress != null) {
LOG.debug("hndlTepAddOnNaptSwitch : External Gateway MAC address {} found for External Router ID {}", gwMacAddress, routerId);
} else {
LOG.error("hndlTepAddOnNaptSwitch : No External Gateway MAC address found for External Router ID {}", routerId);
return false;
}
// get l3Vni value for external VPN
l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
LOG.debug("hndlTepAddOnNaptSwitch : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue to installing " + "NAT flows", vpnName, rd);
l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, routerId).longValue();
}
}
for (final String externalIp : externalIps) {
long serviceId = 0;
String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
if (extNwProvType == ProviderTypes.VXLAN) {
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
NatEvpnUtil.addRoutesForVxLanProvType(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalIp, nextHopIp, l3Vni, tunnelName, gwMacAddress, writeFlowInvTx, RouteOrigin.STATIC, srcDpnId);
serviceId = l3Vni;
} else {
Long label = externalRouterListner.checkExternalIpLabel(routerId, externalIp);
if (label == null || label == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddOnNaptSwitch : SNAT->Unable to advertise to the DC GW " + "since label is invalid");
return false;
}
LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
long l3vni = 0;
if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
l3vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, l3vni).longValue();
}
Uuid externalSubnetId = NatUtil.getExternalSubnetForRouterExternalIp(externalIp, router);
NatUtil.addPrefixToBGP(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalSubnetId, fibExternalIp, nextHopIp, networkId.getValue(), null, /* mac-address */
label, l3vni, RouteOrigin.STATIC, srcDpnId);
serviceId = label;
}
LOG.debug("hndlTepAddOnNaptSwitch: SNAT -> Install custom FIB routes " + "(Table 21 -> Push MPLS label to Tunnel port");
List<Instruction> customInstructions = new ArrayList<>();
int customInstructionIndex = 0;
long externalSubnetVpnId = NatUtil.getExternalSubnetVpnIdForRouterExternalIp(dataBroker, externalIp, router);
if (externalSubnetVpnId != NatConstants.INVALID_ID) {
LOG.debug("hndlTepAddOnNaptSwitch : Will install custom FIB router with external subnet VPN ID {}", externalSubnetVpnId);
BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(externalSubnetVpnId);
customInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID).buildInstruction(customInstructionIndex));
customInstructionIndex++;
}
customInstructions.add(new InstructionGotoTable(NwConstants.INBOUND_NAPT_TABLE).buildInstruction(customInstructionIndex));
CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(externalVpnName).setSourceDpid(srcDpnId).setInstruction(customInstructions).setIpAddress(fibExternalIp).setServiceId(serviceId).setInstruction(customInstructions).build();
Future<RpcResult<Void>> future = fibRpcService.createFibEntry(input);
ListenableFuture<RpcResult<Void>> listenableFuture = JdkFutureAdapters.listenInPoolThread(future);
Futures.addCallback(listenableFuture, new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("hndlTepAddOnNaptSwitch : SNAT->Error in generate label or fib install process", error);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("hndlTepAddOnNaptSwitch : SNAT -> Successfully installed custom FIB routes " + "for prefix {}", externalIp);
} else {
LOG.error("hndlTepAddOnNaptSwitch : SNAT -> Error in rpc call to create custom Fib entries " + "for prefix {} in DPN {}, {}", externalIp, srcDpnId, result.getErrors());
}
}
}, MoreExecutors.directExecutor());
}
return true;
}
Aggregations