+ protected void remove( InstanceIdentifier<VpnInterface> identifier, VpnInterface vpnInterface) {
+ LOG.info("Remove event - key: {}, value: {}" ,identifier, vpnInterface );
+ final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class, VpnInterfaceKey.class);
+ String interfaceName = key.getName();
+ InstanceIdentifierBuilder<Interface> idBuilder =
+ InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(interfaceName));
+ InstanceIdentifier<Interface> id = idBuilder.build();
+ Optional<Interface> port = read(LogicalDatastoreType.CONFIGURATION, id);
+ if (port.isPresent()) {
+ Interface interf = port.get();
+ unbindServiceOnInterface(interf);
+ removeNextHops(identifier, vpnInterface);
+ } else {
+ LOG.info("No nexthops were available to handle remove event {}", interfaceName);
+ }
+ }
+
+ private void removeNextHops(final InstanceIdentifier<VpnInterface> identifier, VpnInterface intf) {
+ //Read NextHops
+ InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
+ Optional<Adjacencies> adjacencies = read(LogicalDatastoreType.OPERATIONAL, path);
+ String intfName = intf.getName();
+
+ if (adjacencies.isPresent()) {
+ List<Adjacency> nextHops = adjacencies.get().getAdjacency();