summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-08 09:46:46 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-09-12 08:13:36 +0000
commitc8594544f25f90dcf89e8b8e8e1716a53bcab820 (patch)
treec9015d5301b94cb32ae32a37fa7e7a9a4500584f
parent1a19891ced58cae69265e0d328a864b4425899ac (diff)
Fixed filtering by referenced interface for locators
Cherrypicked to https://gerrit.fd.io/r/#/c/2727/1 Change-Id: I471e9b9f2d2ecb0f8e3b3e181118de42247ba7ec Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java
index d12c730..cc8bbf5 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java
@@ -87,14 +87,22 @@ public class InterfaceCustomizer
@Override
public void readCurrentAttributes(InstanceIdentifier<Interface> id, InterfaceBuilder builder, ReadContext ctx)
throws ReadFailedException {
- checkState(id.firstKeyOf(LocatorSet.class) != null, "Cannot find reference to parent locator set");
- final String name = id.firstKeyOf(LocatorSet.class).getName();
- checkState(locatorSetContext.containsIndex(name, ctx.getMappingContext()));
- final int interfaceIndex = locatorSetContext.getIndex(name, ctx.getMappingContext());
+ final String locatorSetName = id.firstKeyOf(LocatorSet.class).getName();
+ final String referencedInterfaceName = id.firstKeyOf(Interface.class).getInterfaceRef();
+
+ checkState(interfaceContext.containsIndex(referencedInterfaceName, ctx.getMappingContext()),
+ "No interface mapping for name %s", referencedInterfaceName);
+ checkState(locatorSetContext.containsIndex(locatorSetName, ctx.getMappingContext()),
+ "No locator set mapping for name %s", locatorSetName);
+
+ final int locatorSetIndexIndex = locatorSetContext.getIndex(locatorSetName, ctx.getMappingContext());
+ final int referencedInterfaceIndex =
+ interfaceContext.getIndex(referencedInterfaceName, ctx.getMappingContext());
+
final LocatorDumpParams params = new LocatorDumpParams.LocatorDumpParamsBuilder()
.setFilter(LocatorDumpParams.LocatorDumpFilter.LOCAL)
- .setLocatorSetIndex(interfaceIndex)
+ .setLocatorSetIndex(locatorSetIndexIndex)
.build();
Optional<LispLocatorDetailsReplyDump> reply;
@@ -108,7 +116,7 @@ public class InterfaceCustomizer
final LispLocatorDetails details = reply.get()
.lispLocatorDetails
.stream()
- .filter(a -> a.swIfIndex == interfaceIndex)
+ .filter(a -> a.swIfIndex == referencedInterfaceIndex)
.collect(RWUtils.singleItemCollector());
final String interfaceRef = interfaceContext.getName(details.swIfIndex, ctx.getMappingContext());