X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=nexthopmgr%2Fnexthopmgr-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fnexthopmgr%2FNexthopManager.java;h=a8f411c7ddb301a471b71d0bb1da7476daaa921d;hb=f712d08c9d4d33d7c3f8373a5796d617c523f2b8;hp=c9fee48716f391c0717b0f77db162d4be176c28f;hpb=5aec3fe950ffef616684d33ed7627b6ada8aa483;p=vpnservice.git diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java index c9fee487..a8f411c7 100644 --- a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java +++ b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java @@ -165,7 +165,8 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { BucketInfo bucket = new BucketInfo(listActionInfo); // MAC re-write if (macAddress != null) { - listActionInfo.add(new ActionInfo(ActionType.set_field_eth_dest, new String[]{macAddress})); + listActionInfo.add(0, new ActionInfo(ActionType.set_field_eth_dest, new String[]{macAddress})); + listActionInfo.add(new ActionInfo(ActionType.pop_mpls, new String[]{})); } else { //FIXME: Log message here. } @@ -214,7 +215,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { // check if vpn node is there or to be created InstanceIdentifier id = idBuilder.build(); - Optional nexthops = read(LogicalDatastoreType.CONFIGURATION, id); + Optional nexthops = read(LogicalDatastoreType.OPERATIONAL, id); if (!nexthops.isPresent()) { // create a new node VpnNexthops node = new VpnNexthopsBuilder().setKey(new VpnNexthopsKey(vpnId)).setVpnId(vpnId).build(); @@ -240,7 +241,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { // check if dpn node is there or to be created InstanceIdentifier id = idBuilder.build(); - Optional nexthops = read(LogicalDatastoreType.CONFIGURATION, id); + Optional nexthops = read(LogicalDatastoreType.OPERATIONAL, id); if (!nexthops.isPresent()) { // create a new node TunnelNexthops node = new TunnelNexthopsBuilder() @@ -269,8 +270,8 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { InstanceIdentifierBuilder idBuilder = InstanceIdentifier.builder(L3nexthop.class) .child(VpnNexthops.class, new VpnNexthopsKey(vpnId)); InstanceIdentifier id = idBuilder.build(); - Optional vpnNexthops = read(LogicalDatastoreType.CONFIGURATION, id); - if (!vpnNexthops.isPresent()) { + Optional vpnNexthops = read(LogicalDatastoreType.OPERATIONAL, id); + if (vpnNexthops.isPresent()) { // get nexthops list for vpn List nexthops = vpnNexthops.get().getVpnNexthop(); @@ -292,8 +293,8 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { // check if vpn node is there InstanceIdentifier id = idBuilder.build(); - Optional dpnNexthops = read(LogicalDatastoreType.CONFIGURATION, id); - if (!dpnNexthops.isPresent()) { + Optional dpnNexthops = read(LogicalDatastoreType.OPERATIONAL, id); + if (dpnNexthops.isPresent()) { List nexthops = dpnNexthops.get().getTunnelNexthop(); for (TunnelNexthop nexthop : nexthops) { if (nexthop.getIpAddress().equals(ipAddress)) { @@ -336,17 +337,16 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { } - 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 { @@ -363,6 +363,10 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { // 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 { @@ -424,4 +428,20 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { Futures.addCallback(tx.submit(), DEFAULT_CALLBACK); } + @Override + public Future> removeLocalNextHop(RemoveLocalNextHopInput input) { + VpnNexthop vpnNextHop = getVpnNexthop(input.getVpnId(), input.getIpPrefix()); + RpcResultBuilder 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()); + } + }