use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.
the class ItmManagerRpcService method getInternalOrExternalInterfaceName.
@Override
public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(GetInternalOrExternalInterfaceNameInput input) {
RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = RpcResultBuilder.failed();
BigInteger srcDpn = input.getSourceDpid();
IpAddress dstIp = input.getDestinationIp();
InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(dstIp.getValue()), srcDpn.toString(), input.getTunnelType()));
Optional<ExternalTunnel> optExtTunnel = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
if (optExtTunnel != null && optExtTunnel.isPresent()) {
ExternalTunnel extTunnel = optExtTunnel.get();
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName());
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
// Look for external tunnels if not look for internal tunnel
for (DPNTEPsInfo teps : meshedDpnList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
if (dstIp.equals(firstEndPt.getIpAddress())) {
Optional<InternalTunnel> optTunnel = Optional.absent();
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), input.getTunnelType(), dataBroker);
}
if (optTunnel.isPresent()) {
InternalTunnel tunnel = optTunnel.get();
List<String> tunnelInterfaces = tunnel.getTunnelInterfaceNames();
if (tunnelInterfaces != null && !tunnelInterfaces.isEmpty()) {
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnelInterfaces.get(0));
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
LOG.error("No tunnel interface found between source DPN {} ans destination IP {}", srcDpn, dstIp);
}
break;
} else {
LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
}
}
}
}
return Futures.immediateFuture(resultBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.
the class ItmExternalTunnelAddTest method testBuildHwVtepsTunnels.
@Test
public void testBuildHwVtepsTunnels() {
final Interface extTunnelIf1 = ItmUtils.buildTunnelInterface(dpId1, "tun030025bd04f", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
final Interface hwTunnelIf2 = ItmUtils.buildHwTunnelInterface("tun9a55a9c38f2", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface extTunnelIf3 = ItmUtils.buildTunnelInterface(dpId1, "tun17c6e20c283", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress2, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
final Interface hwTunnelIf4 = ItmUtils.buildHwTunnelInterface("tunaa109b6c8c5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface hwTunnelIf5 = ItmUtils.buildHwTunnelInterface("tund903ed434d5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress2, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface hwTunnelIf6 = ItmUtils.buildHwTunnelInterface("tunc3315b110a6", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress1, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final ExternalTunnel externalTunnel1 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1, "tun030025bd04f");
final ExternalTunnel externalTunnel2 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tun9a55a9c38f2");
final ExternalTunnel externalTunnel3 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1, "tun17c6e20c283");
final ExternalTunnel externalTunnel4 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tunaa109b6c8c5");
final ExternalTunnel externalTunnel5 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1, "tund903ed434d5");
final ExternalTunnel externalTunnel6 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1, "tunc3315b110a6");
InstanceIdentifier<TransportZone> transportZoneIdentifier = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone1)).build();
final InstanceIdentifier<Interface> ifIID1 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun030025bd04f")).build();
final InstanceIdentifier<Interface> ifIID2 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun9a55a9c38f2")).build();
final InstanceIdentifier<Interface> ifIID3 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun17c6e20c283")).build();
final InstanceIdentifier<Interface> ifIID4 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunaa109b6c8c5")).build();
final InstanceIdentifier<Interface> ifIID5 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tund903ed434d5")).build();
final InstanceIdentifier<Interface> ifIID6 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunc3315b110a6")).build();
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier2 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier3 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier4 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier5 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier6 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1));
Optional<TransportZone> optionalTransportZone = Optional.of(transportZone);
doReturn(Futures.immediateCheckedFuture(optionalTransportZone)).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
externalTunnelAddWorker.buildHwVtepsTunnels(cfgdDpnListVxlan, null);
externalTunnelAddWorker.buildHwVtepsTunnels(null, cfgdHwVtepsList);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID1, extTunnelIf1, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier1, externalTunnel1, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID2, hwTunnelIf2, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID3, extTunnelIf3, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier3, externalTunnel3, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID4, hwTunnelIf4, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier4, externalTunnel4, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID5, hwTunnelIf5, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier5, externalTunnel5, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID6, hwTunnelIf6, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier6, externalTunnel6, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.
the class ItmExternalTunnelAddTest method setupMocks.
private void setupMocks() {
ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
ipAddress3 = IpAddressBuilder.getDefaultInstance(tepIp3);
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress3).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).setUp(true).setKey(new DPNTEPsInfoKey(dpId1)).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
deviceVteps1 = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, source)).setNodeId(source).setTopologyId("hwvtep:1").build();
deviceVteps2 = new DeviceVtepsBuilder().setIpAddress(ipAddress2).setKey(new DeviceVtepsKey(ipAddress2, destination)).setNodeId(destination).setTopologyId("hwvtep:1").build();
hwVtep1 = new HwVtep();
hwVtep1.setTransportZone(transportZone1);
hwVtep1.setGatewayIP(gtwyIp1);
hwVtep1.setHwIp(ipAddress1);
hwVtep1.setTunnelType(tunnelType1);
hwVtep1.setVlanID(vlanId);
hwVtep1.setTopoId("hwvtep:1");
hwVtep1.setNodeId(source);
hwVtep1.setIpPrefix(ipPrefixTest);
cfgdDpnListVxlan.add(dpntePsInfoVxlan);
cfgdHwVtepsList.add(hwVtep1);
bigIntegerList.add(dpId1);
deviceVtepsList.add(deviceVteps1);
deviceVtepsList.add(deviceVteps2);
vtepsTest = new VtepsBuilder().setDpnId(dpId1).setIpAddress(ipAddress3).setPortname(portName1).setKey(new VtepsKey(dpId1, portName1)).build();
vtepsList.add(vtepsTest);
dpnEndpointsVxlan = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
idOutputOptional2 = RpcResultBuilder.success(expectedId2).buildFuture();
getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
idOutputOptional3 = RpcResultBuilder.success(expectedId3).buildFuture();
getIdInput3 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/s3:192.168.56.30:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional3).when(idManagerService).allocateId(getIdInput3);
idOutputOptional4 = RpcResultBuilder.success(expectedId4).buildFuture();
getIdInput4 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.40:6640/physicalswitch/s4:192.168.56.40:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional4).when(idManagerService).allocateId(getIdInput4);
idOutputOptional5 = RpcResultBuilder.success(expectedId5).buildFuture();
getIdInput5 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/s3:192.168.56.30:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional5).when(idManagerService).allocateId(getIdInput5);
idOutputOptional6 = RpcResultBuilder.success(expectedId6).buildFuture();
getIdInput6 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.40:6640/physicalswitch/s4:192.168.56.40:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional6).when(idManagerService).allocateId(getIdInput6);
tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(interval).build();
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(parentInterfaceName, String.valueOf(tunnelEndPointsVxlan.getIpAddress().getValue()), String.valueOf(ipAddress2.getValue()), tunnelType1.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
externalTunnelIdentifier = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(ipAddress2.getValue()), dpId1.toString(), tunnelType1));
iface = ItmUtils.buildTunnelInterface(dpId1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, ipAddress3, ipAddress2, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false, null);
externalTunnel = ItmUtils.buildExternalTunnel(dpId1.toString(), String.valueOf(ipAddress2.getValue()), tunnelType1, trunkInterfaceName);
subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setVteps(vtepsList).setDeviceVteps(deviceVtepsList).build();
subnetsList.add(subnets);
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method wireUp.
// for tunnels from TOR device
private boolean wireUp(String topoId, String srcNodeid, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getHwParentIf(topoId, srcNodeid);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
Interface hwTunnelIf = ItmUtils.buildHwTunnelInterface(tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, topoId, srcNodeid, tunType, srcIp, dstIp, gwyIpAddress, monitorEnabled, monitorProtocol, monitorInterval);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, hwTunnelIf);
ItmUtils.ITM_CACHE.addInterface(hwTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, hwTunnelIf, true);
// also update itm-state ds?
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), getExternalTunnelKey(srcNodeid), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(getExternalTunnelKey(srcNodeid), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class VpnRpcServiceImpl method addStaticRoute.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public ListenableFuture<RpcResult<AddStaticRouteOutput>> addStaticRoute(AddStaticRouteInput input) {
SettableFuture<RpcResult<AddStaticRouteOutput>> result = SettableFuture.create();
String destination = input.getDestination();
String vpnInstanceName = input.getVpnInstanceName();
String nexthop = input.getNexthop();
Uint32 label = input.getLabel();
LOG.info("Adding static route for Vpn {} with destination {}, nexthop {} and label {}", vpnInstanceName, destination, nexthop, label);
Collection<RpcError> rpcErrors = validateAddStaticRouteInput(input);
if (!rpcErrors.isEmpty()) {
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withRpcErrors(rpcErrors).build());
return result;
}
if (label == null || label.longValue() == VpnConstants.INVALID_LABEL) {
label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(vpnInstanceName, destination));
if (label.longValue() == VpnConstants.INVALID_LABEL) {
String message = "Unable to retrieve a new Label for the new Route";
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(RpcError.ErrorType.APPLICATION, message).build());
LOG.error("addStaticRoute: Unable to retrieve label for static route with destination {}, vpninstance" + " {}, nexthop {}", destination, vpnInstanceName, nexthop);
return result;
}
}
String vpnRd = vpnUtil.getVpnRd(input.getVpnInstanceName());
VpnInstanceOpDataEntry vpnOpEntry = vpnUtil.getVpnInstanceOpData(vpnRd);
Boolean isVxlan = VpnUtil.isL3VpnOverVxLan(vpnOpEntry.getL3vni());
VrfEntry.EncapType encapType = VpnUtil.getEncapType(isVxlan);
if (vpnRd == null) {
String message = "Could not find Route-Distinguisher for VpnName " + vpnInstanceName;
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(RpcError.ErrorType.APPLICATION, message).build());
return result;
}
Optional<InterVpnLinkDataComposite> optIVpnLink = interVpnLinkCache.getInterVpnLinkByEndpoint(nexthop);
if (optIVpnLink.isPresent()) {
try {
interVpnLinkUtil.handleStaticRoute(optIVpnLink.get(), vpnInstanceName, destination, nexthop, label);
} catch (Exception e) {
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::warn, "Could not advertise route [vpn={}, prefix={}, label={}, nexthop={}] to BGP: {}", vpnRd, destination, label, nexthop, e.getMessage(), e)).build());
return result;
}
} else {
try {
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> vpnManager.addExtraRoute(vpnInstanceName, destination, nexthop, vpnRd, null, /* routerId */
vpnOpEntry.getL3vni(), RouteOrigin.STATIC, null, /* intfName */
null, /*Adjacency*/
encapType, new HashSet<>(), /*prefixListForRefreshFib*/
confTx)).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error adding static route {}", input, e);
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(ErrorType.APPLICATION, "Error adding static route " + input, e).build());
return result;
}
}
AddStaticRouteOutput labelOutput = new AddStaticRouteOutputBuilder().setLabel(label).build();
result.set(RpcResultBuilder.success(labelOutput).build());
return result;
}
Aggregations