use of org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite in project netvirt by opendaylight.
the class InterVpnLinkNodeAddTask method installLPortDispatcherTable.
private void installLPortDispatcherTable(InterVpnLinkState interVpnLinkState, List<BigInteger> firstDpnList, List<BigInteger> secondDpnList) {
String ivpnLinkName = interVpnLinkState.getKey().getInterVpnLinkName();
Optional<InterVpnLinkDataComposite> optVpnLink = interVpnLinkCache.getInterVpnLinkByName(ivpnLinkName);
if (!optVpnLink.isPresent()) {
LOG.warn("installLPortDispatcherTable: Could not find interVpnLink {}", ivpnLinkName);
return;
}
InterVpnLinkDataComposite vpnLink = optVpnLink.get();
Optional<Long> opt1stEndpointLportTag = vpnLink.getFirstEndpointLportTag();
if (!opt1stEndpointLportTag.isPresent()) {
LOG.warn("installLPortDispatcherTable: Could not find LPortTag for 1stEnpoint in InterVpnLink {}", ivpnLinkName);
return;
}
Optional<Long> opt2ndEndpointLportTag = vpnLink.getSecondEndpointLportTag();
if (!opt2ndEndpointLportTag.isPresent()) {
LOG.warn("installLPortDispatcherTable: Could not find LPortTag for 2ndEnpoint in InterVpnLink {}", ivpnLinkName);
return;
}
String firstEndpointVpnUuid = vpnLink.getFirstEndpointVpnUuid().get();
String secondEndpointVpnUuid = vpnLink.getSecondEndpointVpnUuid().get();
// Note that in the DPN of the firstEndpoint we install the lportTag of the secondEndpoint and viceversa
String vpn1PrimaryRd = VpnUtil.getPrimaryRd(broker, firstEndpointVpnUuid);
String vpn2PrimaryRd = VpnUtil.getPrimaryRd(broker, secondEndpointVpnUuid);
if (!VpnUtil.isVpnPendingDelete(broker, vpn1PrimaryRd) && !VpnUtil.isVpnPendingDelete(broker, vpn2PrimaryRd)) {
InterVpnLinkUtil.installLPortDispatcherTableFlow(broker, mdsalManager, ivpnLinkName, firstDpnList, secondEndpointVpnUuid, opt2ndEndpointLportTag.get());
InterVpnLinkUtil.installLPortDispatcherTableFlow(broker, mdsalManager, ivpnLinkName, secondDpnList, firstEndpointVpnUuid, opt1stEndpointLportTag.get());
// Update the VPN -> DPNs Map.
// Note: when a set of DPNs is calculated for Vpn1, these DPNs are added to the VpnToDpn map of Vpn2. Why?
// because we do the handover from Vpn1 to Vpn2 in those DPNs, so in those DPNs we must know how to reach
// to Vpn2 targets. If new Vpn2 targets are added later, the Fib will be maintained in these DPNs even if
// Vpn2 is not physically present there.
InterVpnLinkUtil.updateVpnFootprint(vpnFootprintService, secondEndpointVpnUuid, vpn1PrimaryRd, firstDpnList);
InterVpnLinkUtil.updateVpnFootprint(vpnFootprintService, firstEndpointVpnUuid, vpn2PrimaryRd, secondDpnList);
}
}
use of org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite in project netvirt by opendaylight.
the class VpnRpcServiceImpl method addStaticRoute.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Future<RpcResult<AddStaticRouteOutput>> addStaticRoute(AddStaticRouteInput input) {
SettableFuture<RpcResult<AddStaticRouteOutput>> result = SettableFuture.create();
String destination = input.getDestination();
String vpnInstanceName = input.getVpnInstanceName();
String nexthop = input.getNexthop();
Long 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 == 0) {
label = (long) VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(vpnInstanceName, destination));
if (label == 0) {
String message = "Unable to retrieve a new Label for the new Route";
result.set(RpcResultBuilder.<AddStaticRouteOutput>failed().withError(RpcError.ErrorType.APPLICATION, message).build());
return result;
}
}
String vpnRd = VpnUtil.getVpnRd(dataBroker, input.getVpnInstanceName());
VpnInstanceOpDataEntry vpnOpEntry = VpnUtil.getVpnInstanceOpData(dataBroker, 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.intValue(), dataBroker, fibManager, bgpManager);
} 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 {
vpnManager.addExtraRoute(vpnInstanceName, destination, nexthop, vpnRd, null, /* routerId */
vpnOpEntry.getL3vni(), RouteOrigin.STATIC, null, /* intfName */
null, /*Adjacency*/
encapType, null);
}
AddStaticRouteOutput labelOutput = new AddStaticRouteOutputBuilder().setLabel(label).build();
result.set(RpcResultBuilder.success(labelOutput).build());
return result;
}
use of org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite in project netvirt by opendaylight.
the class InterVpnLinkTestCatalog method populateIvpnLinks.
public static void populateIvpnLinks(DataBroker broker2, List<InterVpnLinkDataComposite> ivpnLinks) throws TransactionCommitFailedException {
for (InterVpnLinkDataComposite ivpnLink : ivpnLinks) {
WriteTransaction writeTx1 = broker2.newWriteOnlyTransaction();
writeTx1.merge(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkPath(ivpnLink.getInterVpnLinkName()), ivpnLink.getInterVpnLinkConfig());
writeTx1.submit().checkedGet();
WriteTransaction writeTx2 = broker2.newWriteOnlyTransaction();
writeTx2.merge(LogicalDatastoreType.OPERATIONAL, InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLink.getInterVpnLinkName()), ivpnLink.getInterVpnLinkState());
writeTx2.submit().checkedGet();
}
}
use of org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite in project netvirt by opendaylight.
the class InterVpnLinkNodeListener method remove.
@Override
protected void remove(InstanceIdentifier<Node> identifier, Node del) {
LOG.trace("Node {} has been deleted", identifier.firstKeyOf(Node.class).toString());
NodeId nodeId = del.getNodeId();
String[] node = nodeId.getValue().split(":");
if (node.length < 2) {
LOG.warn("Unexpected nodeId {}", nodeId.getValue());
return;
}
BigInteger dpId = new BigInteger(node[1]);
List<InterVpnLinkDataComposite> allInterVpnLinks = interVpnLinkCache.getAllInterVpnLinks();
allInterVpnLinks.stream().filter(// Only those affected by DPN going down
ivl -> ivl.stepsOnDpn(dpId)).forEach(// Move them somewhere else
this::reinstallInterVpnLink);
}
use of org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite in project netvirt by opendaylight.
the class FibManagerImpl method removeInterVPNLinkRouteFlows.
@Override
public void removeInterVPNLinkRouteFlows(final String interVpnLinkName, final boolean isVpnFirstEndPoint, final VrfEntry vrfEntry) {
Optional<InterVpnLinkDataComposite> optInterVpnLink = interVpnLinkCache.getInterVpnLinkByName(interVpnLinkName);
if (!optInterVpnLink.isPresent()) {
LOG.warn("Could not find InterVpnLink with name {}. InterVpnLink route flows wont be removed", interVpnLinkName);
return;
}
InterVpnLinkDataComposite interVpnLink = optInterVpnLink.get();
String vpnName = isVpnFirstEndPoint ? interVpnLink.getFirstEndpointVpnUuid().get() : interVpnLink.getSecondEndpointVpnUuid().get();
vrfEntryListener.removeInterVPNLinkRouteFlows(interVpnLink, vpnName, vrfEntry);
}
Aggregations