private static final FutureCallback<Void> DEFAULT_CALLBACK =
new FutureCallback<Void>() {
public void onSuccess(Void result) {
- LOG.info("Success in Datastore write operation");
+ LOG.debug("Success in Datastore write operation");
}
public void onFailure(Throwable error) {
LOG.error("Error in Datastore write operation", error);
.build();
//TODO: Error handling
Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
+ LOG.trace("NextHopPointerPool result : {}", result);
// try {
// LOG.info("Result2: {}",result.get());
// } catch (InterruptedException | ExecutionException e) {
}
- private long getVpnId(String vpnName) {
+ protected long getVpnId(String vpnName) {
InstanceIdentifierBuilder<VpnInstance> idBuilder = InstanceIdentifier.builder(VpnInstances.class)
.child(VpnInstance.class, new VpnInstanceKey(vpnName));
Optional<VpnInstance1> vpn = read(LogicalDatastoreType.OPERATIONAL, idx);
if (vpn.isPresent()) {
+ LOG.debug("VPN id returned: {}", vpn.get().getVpnId());
return vpn.get().getVpnId();
} else {
return -1;
private long getDpnId(String ifName) {
String[] fields = ifName.split(":");
long dpn = Integer.parseInt(fields[1]);
+ LOG.debug("DpnId: {}", dpn);
return dpn;
}
- private int createNextHopPointer(String nexthopKey) {
+ protected int createNextHopPointer(String nexthopKey) {
GetUniqueIdInput getIdInput = new GetUniqueIdInputBuilder()
.setPoolName("nextHopPointerPool").setIdKey(nexthopKey)
.build();
long vpnId = getVpnId(vpnName);
long dpnId = interfaceManager.getDpnForInterface(ifName);
VpnNexthop nexthop = getVpnNexthop(vpnId, ipAddress);
+ LOG.trace("nexthop: {}", nexthop);
if (nexthop == null) {
List<BucketInfo> listBucketInfo = new ArrayList<BucketInfo>();
List<ActionInfo> listActionInfo = interfaceManager.getInterfaceEgressActions(ifName);
// MAC re-write
if (macAddress != null) {
listActionInfo.add(0, new ActionInfo(ActionType.set_field_eth_dest, new String[]{macAddress}));
+ listActionInfo.add(0, new ActionInfo(ActionType.pop_mpls, new String[]{}));
} else {
//FIXME: Log message here.
+ LOG.debug("mac address for new local nexthop is null");
}
listBucketInfo.add(bucket);
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
}
}
- private void addVpnNexthopToDS(long vpnId, String ipPrefix, long egressPointer) {
+ protected void addVpnNexthopToDS(long vpnId, String ipPrefix, long egressPointer) {
InstanceIdentifierBuilder<VpnNexthops> idBuilder = InstanceIdentifier.builder(L3nexthop.class)
.child(VpnNexthops.class, new VpnNexthopsKey(vpnId));
InstanceIdentifier<VpnNexthop> id1 = idBuilder
.child(VpnNexthop.class, new VpnNexthopKey(ipPrefix)).build();
-
+ LOG.trace("Adding vpnnextHop {} to Operational DS", nh);
asyncWrite(LogicalDatastoreType.OPERATIONAL, id1, nh, DEFAULT_CALLBACK);
}
.setKey(new TunnelNexthopsKey(dpnId))
.setDpnId(dpnId)
.build();
+ LOG.trace("Adding tunnelnextHop {} to Operational DS for a new node", node);
asyncWrite(LogicalDatastoreType.OPERATIONAL, id, node, DEFAULT_CALLBACK);
}
InstanceIdentifier<TunnelNexthop> id1 = idBuilder
.child(TunnelNexthop.class, new TunnelNexthopKey(ipPrefix)).build();
-
+ LOG.trace("Adding tunnelnextHop {} to Operational DS for a dpn node", nh);
asyncWrite(LogicalDatastoreType.OPERATIONAL, id1, nh, DEFAULT_CALLBACK);
}
- private VpnNexthop getVpnNexthop(long vpnId, String ipAddress) {
+ protected VpnNexthop getVpnNexthop(long vpnId, String ipAddress) {
// check if vpn node is there
InstanceIdentifierBuilder<VpnNexthops> idBuilder = InstanceIdentifier.builder(L3nexthop.class)
for (VpnNexthop nexthop : nexthops) {
if (nexthop.getIpAddress().equals(ipAddress)) {
// return nexthop
+ LOG.trace("VpnNextHop : {}",nexthop);
return nexthop;
}
}
List<TunnelNexthop> nexthops = dpnNexthops.get().getTunnelNexthop();
for (TunnelNexthop nexthop : nexthops) {
if (nexthop.getIpAddress().equals(ipAddress)) {
+ LOG.trace("TunnelNextHop : {}",nexthop);
return nexthop;
}
}
return vpnNextHop.getEgressPointer();
} else {
TunnelNexthop tunnelNextHop = getTunnelNexthop(dpnId, nextHopIp);
+ LOG.trace("NExtHopPointer : {}", tunnelNextHop.getEgressPointer());
return tunnelNextHop.getEgressPointer();
}
}
.child(TunnelNexthop.class, new TunnelNexthopKey(ipPrefix));
InstanceIdentifier<TunnelNexthop> id = idBuilder.build();
// remove from DS
+ LOG.trace("Removing tunnel next hop from datastore : {}", id);
delete(LogicalDatastoreType.OPERATIONAL, id);
}
.child(VpnNexthop.class, new VpnNexthopKey(ipPrefix));
InstanceIdentifier<VpnNexthop> id = idBuilder.build();
// remove from DS
+ LOG.trace("Removing vpn next hop from datastore : {}", id);
delete(LogicalDatastoreType.OPERATIONAL, id);
}
- public void removeLocalNextHop(String vpnName, String ipAddress) {
-
- long vpnId = getVpnId(vpnName);
+ public void removeLocalNextHop(Long dpId, Long vpnId, String ipAddress) {
VpnNexthop nh = getVpnNexthop(vpnId, ipAddress);
if (nh != null) {
// how to inform and remove dependent FIB entries??
// we need to do it before the group is removed
-
+ GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
+ dpId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
// remove Group ...
-
+ mdsalManager.removeGroup(groupEntity);
//update MD-SAL DS
removeVpnNexthopFromDS(vpnId, ipAddress);
} else {
//throw error
+ LOG.error("removal of local next hop failed");
}
}
// we need to do it before the group is removed
// remove Group ...
+ GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
+ dpnId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
+ // remove Group ...
+ mdsalManager.removeGroup(groupEntity);
//update MD-SAL DS
removeTunnelNexthopFromDS(dpnId, ipAddress);
} else {
//throw error
+ LOG.error("removal of remote next hop failed : dpnid : {}, ipaddress : {}", dpnId, ipAddress);
}
}
GetEgressPointerOutputBuilder output = new GetEgressPointerOutputBuilder();
String endpointIp = interfaceManager.getEndpointIpForDpn(input.getDpnId());
+ LOG.trace("getEgressPointer: input {}, endpointIp {}", input, endpointIp);
if (input.getNexthopIp().equals(endpointIp)) {
VpnNexthop vpnNextHop = getVpnNexthop(input.getVpnId(), input.getIpPrefix());
output.setEgressPointer(vpnNextHop.getEgressPointer());
Futures.addCallback(tx.submit(), DEFAULT_CALLBACK);
}
+ @Override
+ public Future<RpcResult<Void>> removeLocalNextHop(RemoveLocalNextHopInput input) {
+ VpnNexthop vpnNextHop = getVpnNexthop(input.getVpnId(), input.getIpPrefix());
+ RpcResultBuilder<Void> rpcResultBuilder;
+ LOG.debug("vpnnexthop is: {}", vpnNextHop);
+ try {
+ removeLocalNextHop(input.getDpnId(),input.getVpnId(), input.getIpPrefix());
+ rpcResultBuilder = RpcResultBuilder.success();
+ }
+ catch(Exception e){
+ LOG.error("Removal of local next hop for vpnNextHop {} failed {}" ,vpnNextHop, e);
+ rpcResultBuilder = RpcResultBuilder.failed();
+ }
+ return Futures.immediateFuture(rpcResultBuilder.build());
+ }
+
}