- /**
- * Leaks a route from one VPN to another.
- *
- * @param broker dataBroker service reference
- * @param bgpManager Used to advertise routes to the BGP Router
- * @param interVpnLink Reference to the object that holds the info about the link between the 2 VPNs
- * @param srcVpnUuid UUID of the VPN that has the route that is going to be leaked to the other VPN
- * @param dstVpnUuid UUID of the VPN that is going to receive the route
- * @param prefix Prefix of the route
- * @param label Label of the route in the original VPN
- * @param forcedOrigin By default, origin for leaked routes should be INTERVPN, however it is possible to
- * provide a different origin if desired.
- */
- public static void leakRoute(DataBroker broker, IBgpManager bgpManager, InterVpnLink interVpnLink,
- String srcVpnUuid, String dstVpnUuid, String prefix, Long label,
- RouteOrigin forcedOrigin) {
- Preconditions.checkNotNull(interVpnLink);
-
- // The source VPN must participate in the InterVpnLink
- Preconditions.checkArgument(interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(srcVpnUuid)
- || interVpnLink.getSecondEndpoint().getVpnUuid().getValue().equals(srcVpnUuid),
- "The source VPN {} does not participate in the interVpnLink {}",
- srcVpnUuid, interVpnLink.getName());
- // The destination VPN must participate in the InterVpnLink
- Preconditions.checkArgument(interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(dstVpnUuid)
- || interVpnLink.getSecondEndpoint().getVpnUuid().getValue().equals(dstVpnUuid),
- "The destination VPN {} does not participate in the interVpnLink {}",
- dstVpnUuid, interVpnLink.getName());
-
- boolean destinationIs1stEndpoint = interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(dstVpnUuid);
-
- String endpointIp = (destinationIs1stEndpoint) ? interVpnLink.getSecondEndpoint().getIpAddress().getValue()
- : interVpnLink.getFirstEndpoint().getIpAddress().getValue();
-
- VrfEntry newVrfEntry = new VrfEntryBuilder().setKey(new VrfEntryKey(prefix)).setDestPrefix(prefix)
- .setLabel(label).setNextHopAddressList(Arrays.asList(endpointIp))
- .setOrigin(RouteOrigin.INTERVPN.getValue())
- .build();