- protected void add(InstanceIdentifier<VpnInterface> identifier,
- VpnInterface vpnIf) {
- LOG.info("key: " + identifier + ", value=" + vpnIf );
-
- String vpnName = vpnIf.getVpnInstanceName();
- 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();
-
- //Read NextHops
- InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
- Optional<Adjacencies> adjacencies = read(LogicalDatastoreType.CONFIGURATION, path);
-
- if (adjacencies.isPresent()) {
- List<Adjacency> nextHops = adjacencies.get().getAdjacency();
- List<Adjacency> value = new ArrayList<>();
-
- if (!nextHops.isEmpty()) {
- LOG.info("NextHops are " + nextHops);
- for (Adjacency nextHop : nextHops) {
- nexthopManager.createLocalNextHop(interfaceName, vpnName, nextHop.getIpAddress());
- }
- }
- }
+ protected void add(InstanceIdentifier<Adjacencies> identifier,
+ Adjacencies adjs) {
+
+ InstanceIdentifier<VpnInterface> vpnIfId = identifier.firstIdentifierOf(VpnInterface.class);
+ Optional<VpnInterface> vpnIf = read(LogicalDatastoreType.CONFIGURATION, vpnIfId);
+ VpnInterface vpnIfData = vpnIf.get();
+
+ List<Adjacency> adjList = adjs.getAdjacency();
+ for (Adjacency adjacency : adjList) {
+ nexthopManager.createLocalNextHop(
+ vpnIfData.getName(),
+ vpnIfData.getVpnInstanceName(),
+ adjacency.getIpAddress(),
+ adjacency.getMacAddress());