summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/lisp2vpp/src/main')
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java15
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java5
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactory.java46
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactoryProvider.java36
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java66
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java8
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizer.java106
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java85
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java47
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java21
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java4
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java125
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java34
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizer.java103
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractJvppDumpExecutor.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java)8
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/ItrRemoteLocatorSetDumpExecutor.java48
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java2
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/SubtableDumpExecutor.java68
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java16
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/SubtableDumpParams.java75
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java22
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java122
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java17
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java3
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java4
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingFilterProvider.java50
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducer.java56
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReader.java56
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidMetadataProvider.java36
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java45
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java92
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/BridgeDomainSubtableCustomizer.java97
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java82
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java10
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java9
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java20
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java63
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VrfSubtableCustomizer.java82
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java14
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java3
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java4
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java98
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/trait/SubtableWriter.java82
47 files changed, 1697 insertions, 300 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java
index 5344dfc7f..2317b49f7 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java
@@ -23,10 +23,12 @@ import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEX
import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
import io.fd.honeycomb.data.init.DataTreeInitializer;
import io.fd.honeycomb.lisp.cfgattrs.LispConfiguration;
+import io.fd.honeycomb.lisp.context.util.ContextsReaderFactoryProvider;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.initializers.LispInitializer;
import io.fd.honeycomb.lisp.translate.read.factory.LispStateReaderFactory;
@@ -44,10 +46,8 @@ public class LispModule extends AbstractModule {
@Override
protected void configure() {
- LOG.info("Installing configuration module");
+ LOG.info("Configuring module Lisp");
install(ConfigurationModule.create());
-
- LOG.info("Injecting Lisp configuration");
requestInjection(LispConfiguration.class);
LOG.info("Binding Naming context[{}]", LOCATOR_SET_CONTEXT);
@@ -67,26 +67,23 @@ public class LispModule extends AbstractModule {
LOG.info("Binding reader factories");
final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
-
- LOG.info("Binding [{}]", LispStateReaderFactory.class.getName());
readerFactoryBinder.addBinding().to(LispStateReaderFactory.class);
LOG.info("Reader factories binded");
LOG.info("Binding writer factories");
final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
-
- LOG.info("Binding [{}]", LispWriterFactory.class.getName());
writerFactoryBinder.addBinding().to(LispWriterFactory.class);
LOG.info("Writer factories binded");
LOG.info("Binding initializers");
final Multibinder<DataTreeInitializer> initializerBinder =
Multibinder.newSetBinder(binder(), DataTreeInitializer.class);
-
- LOG.info("Binding [{}]", LispInitializer.class.getName());
initializerBinder.addBinding().to(LispInitializer.class);
LOG.info("Initializers binded");
+ final Multibinder<ReaderFactory> readerBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
+ readerBinder.addBinding().toProvider(ContextsReaderFactoryProvider.class).in(Singleton.class);
+
LOG.info("Module Lisp successfully configured");
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java
index dae41cebd..75083468c 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java
@@ -53,11 +53,6 @@ public class LispConfiguration {
public static final String HONEYCOMB_INITIALIZER = "honeycomb-initializer";
/**
- * Unique prefix for naming context of interfaces.
- **/
- public static final String INTERFACE_CONTEXT_PREFIX = "interface-";
-
- /**
* Unique prefix for naming context of locator sets.
**/
public static final String LOCATOR_SET_CONTEXT_PREFIX = "locator-set-";
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactory.java
new file mode 100644
index 000000000..29a5e3fd4
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.context.util;
+
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import io.fd.honeycomb.translate.util.read.BindingBrokerReader;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.Contexts;
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.ContextsBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * {@link ReaderFactory} initiating reader providing data from context data store for eid's.
+ * Making them available over RESTCONF/NETCONF.
+ */
+public class ContextsReaderFactory implements ReaderFactory {
+
+ private final DataBroker contextBindingBrokerDependency;
+
+ public ContextsReaderFactory(final DataBroker contextBindingBrokerDependency) {
+ this.contextBindingBrokerDependency = contextBindingBrokerDependency;
+ }
+
+ @Override
+ public void init(final ModifiableReaderRegistryBuilder registry) {
+ registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(Contexts.class),
+ contextBindingBrokerDependency,
+ LogicalDatastoreType.OPERATIONAL, ContextsBuilder.class));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactoryProvider.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactoryProvider.java
new file mode 100644
index 000000000..d023b3e9f
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/ContextsReaderFactoryProvider.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.context.util;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.name.Named;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+
+
+public class ContextsReaderFactoryProvider implements Provider<ReaderFactory> {
+
+ @Inject
+ @Named("honeycomb-context")
+ private DataBroker contextDataBroker;
+
+ @Override
+ public ReaderFactory get() {
+ return new ContextsReaderFactory(contextDataBroker);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
index 153061ef5..d9513e10e 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
@@ -17,6 +17,7 @@
package io.fd.honeycomb.lisp.context.util;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
@@ -35,12 +36,15 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utility class allowing {@link MappingId} to {@link Eid} mapping
*/
public class EidMappingContext implements EidTranslator {
+ private static final Logger LOG = LoggerFactory.getLogger(EidMappingContext.class);
private static final Collector<Mapping, ?, Mapping> SINGLE_ITEM_COLLECTOR = RWUtils.singleItemCollector();
private final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.EidMappingContext, EidMappingContextKey>
@@ -60,22 +64,22 @@ public class EidMappingContext implements EidTranslator {
/**
* Retrieve name for mapping stored provided mappingContext instance.
*
- * @param eid eid of a mapped item
+ * @param remoteEid eid of a mapped item
* @param mappingContext mapping context providing context data for current transaction
* @return name mapped to provided index
*/
@Nonnull
public synchronized MappingId getId(
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid remoteEid,
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
+ checkState(read.isPresent(), "Mapping for eid: %s is not present. But should be", remoteEid);
- //dont create artificial name as naming context, to not create refference to some artificial(in vpp non-existing)eid
- checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
-
- return read.get().getMapping().stream()
- .filter(mapping -> compareEids(mapping.getEid(), eid))
+ return read.get().getMapping()
+ .stream()
+ //cannot split to map + filtering,because its collecting mappings,not eid's
+ .filter(mapping -> compareEids(mapping.getEid(), remoteEid))
.collect(SINGLE_ITEM_COLLECTOR).getId();
}
@@ -88,21 +92,13 @@ public class EidMappingContext implements EidTranslator {
*/
@Nonnull
public synchronized MappingId getId(
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid eid,
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
+ //don't create artificial name as naming context, to not create reference to some artificial(in vpp non-existing)eid
+ checkState(read.isPresent(), "Mapping for eid: %s is not present. But should be", eid);
- //dont create artificial name as naming context, to not create refference to some artificial(in vpp non-existing)eid
- checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
-
- //this kind of comparing is needed ,because yang generated containers does not override equals,unless they are defined as types
- //in this hierarchy the first that define proper equals is Ipv4Address/Ipv6Address/MacAddress
- //
- // From official javadoc
- // The equals method for class Object implements the most discriminating possible equivalence relation on objects;
- // that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object
- // (x == y has the value true).
return read.get().getMapping().stream()
.filter(mapping -> compareEids(mapping.getEid(), eid))
.collect(SINGLE_ITEM_COLLECTOR).getId();
@@ -116,16 +112,14 @@ public class EidMappingContext implements EidTranslator {
* @return true if present, false otherwise
*/
public synchronized boolean containsId(
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid eid,
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
- //dont create artificial name as naming context, to not create refference to some artificial(in vpp non-existing)eid
- checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
-
- return read.isPresent()
- ? read.get().getMapping().stream().anyMatch(mapping -> compareEids(mapping.getEid(), eid))
- : false;
+ return read.isPresent() &&
+ read.get().getMapping()
+ .stream()
+ .anyMatch(mapping -> compareEids(mapping.getEid(), eid));
}
/**
@@ -136,15 +130,14 @@ public class EidMappingContext implements EidTranslator {
* @return true if present, false otherwise
*/
public synchronized boolean containsId(
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid eid,
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
- checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
-
- return read.isPresent()
- ? read.get().getMapping().stream().anyMatch(mapping -> compareEids(mapping.getEid(), eid))
- : false;
+ return read.isPresent() &&
+ read.get().getMapping()
+ .stream()
+ .anyMatch(mapping -> compareEids(mapping.getEid(), eid));
}
@@ -157,11 +150,10 @@ public class EidMappingContext implements EidTranslator {
*/
public synchronized void addEid(
@Nonnull final MappingId index,
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid eid,
final MappingContext mappingContext) {
final KeyedInstanceIdentifier<Mapping, MappingKey> mappingIid = getMappingIid(index);
- //this copy is needed (type of eid in mapping is different that in local mapping,they only have same ancestor)
mappingContext.put(mappingIid, new MappingBuilder().setId(index).setEid(copyEid(eid)).build());
}
@@ -174,7 +166,7 @@ public class EidMappingContext implements EidTranslator {
*/
public synchronized void addEid(
@Nonnull final MappingId index,
- @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid eid,
+ @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid eid,
final MappingContext mappingContext) {
final KeyedInstanceIdentifier<Mapping, MappingKey> mappingIid = getMappingIid(index);
@@ -186,13 +178,13 @@ public class EidMappingContext implements EidTranslator {
}
private Eid copyEid(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid eid) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid eid) {
return new EidBuilder().setAddress(eid.getAddress()).setAddressType(eid.getAddressType())
.setVirtualNetworkId(eid.getVirtualNetworkId()).build();
}
private Eid copyEid(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid eid) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid eid) {
return new EidBuilder().setAddress(eid.getAddress()).setAddressType(eid.getAddressType())
.setVirtualNetworkId(eid.getVirtualNetworkId()).build();
}
@@ -218,7 +210,7 @@ public class EidMappingContext implements EidTranslator {
public synchronized Eid getEid(@Nonnull final MappingId index, final MappingContext mappingContext) {
final Optional<Mapping> read = mappingContext.read(getMappingIid(index));
checkArgument(read.isPresent(), "No mapping stored for index: %s", index);
- return mappingContext.read(getMappingIid(index)).get().getEid();
+ return read.get().getEid();
}
/**
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java
index 105ee0aec..690d2a91a 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java
@@ -58,11 +58,7 @@ public class LispInitializer extends AbstractDataTreeConverter<LispState, Lisp>
// configuration can fail)
return lispBuilder.setEnable(operationalData.isEnable())
- .setEidTable(operationalData.getEidTable())
- .setLocatorSets(operationalData.getLocatorSets())
- .setMapResolvers(operationalData.getMapResolvers())
- .setPitrCfg(operationalData.getPitrCfg())
+ .setLispFeatureData(operationalData.getLispFeatureData())
.build();
}
-
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java
index 373de70b3..ef5de97f2 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java
@@ -25,10 +25,10 @@ import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.naming.OperationNotSupportedException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.AdjacenciesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.AdjacenciesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.AdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.AdjacencyKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizer.java
new file mode 100644
index 000000000..e75562651
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizer.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.SubtableDumpExecutor;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams;
+import io.fd.honeycomb.lisp.translate.read.trait.SubtableReader;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.vpp.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtableBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BridgeDomainSubtableCustomizer extends FutureJVppCustomizer implements
+ ReaderCustomizer<BridgeDomainSubtable, BridgeDomainSubtableBuilder>, SubtableReader {
+
+ private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainSubtableCustomizer.class);
+ private static final String CACHE_KEY = BridgeDomainSubtableCustomizer.class.getName();
+
+ private final DumpCacheManager<LispEidTableMapDetailsReplyDump, SubtableDumpParams> dumpManager;
+ private final SubtableDumpExecutor dumpExecutor;
+ private final NamingContext bridgeDomainContext;
+
+ public BridgeDomainSubtableCustomizer(@Nonnull final FutureJVppCore futureJvppCore,
+ @Nonnull final NamingContext bridgeDomainContext) {
+ super(futureJvppCore);
+ dumpExecutor = new SubtableDumpExecutor(futureJvppCore);
+ dumpManager =
+ new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, SubtableDumpParams>()
+ .withExecutor(dumpExecutor)
+ .build();
+ this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
+ }
+
+ @Nonnull
+ @Override
+ public BridgeDomainSubtableBuilder getBuilder(@Nonnull final InstanceIdentifier<BridgeDomainSubtable> id) {
+ return new BridgeDomainSubtableBuilder();
+ }
+
+ @Override
+ public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomainSubtable> id,
+ @Nonnull final BridgeDomainSubtableBuilder builder,
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
+ final int vni = checkNotNull(id.firstKeyOf(VniTable.class), "Cannot find parent VNI Table")
+ .getVirtualNetworkIdentifier().intValue();
+ LOG.debug("Read attributes for id {}", id);
+ //dumps only L2(bridge domains)
+ final Optional<LispEidTableMapDetailsReplyDump> reply =
+ readSubtable(dumpManager, CACHE_KEY, ctx.getModificationCache(), id, L2_PARAMS);
+
+ if (!reply.isPresent() || reply.get().lispEidTableMapDetails.isEmpty()) {
+ return;
+ }
+
+ // Single item collector cant be used in this case,because bridge-domain-subtable is container
+ // so read is invoked every time parent is defined
+ final List<LispEidTableMapDetails>
+ details = reply.get().lispEidTableMapDetails.stream().filter(a -> a.vni == vni)
+ .collect(Collectors.toList());
+ if (details.size() == 1) {
+ final LispEidTableMapDetails detail = details.get(0);
+ builder.setBridgeDomainRef(bridgeDomainContext.getName(detail.dpTable, ctx.getMappingContext()));
+ LOG.debug("Attributes for {} successfully loaded", id);
+ }
+ }
+
+ @Override
+ public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder,
+ @Nonnull final BridgeDomainSubtable readValue) {
+ ((VniTableBuilder) parentBuilder).setBridgeDomainSubtable(readValue);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java
new file mode 100644
index 000000000..48e559ddc
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read;
+
+
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.ItrRemoteLocatorSetDumpExecutor;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer
+ implements ReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder>, ByteDataTranslator {
+
+ private static final String CACHE_KEY = ItrRemoteLocatorSetCustomizer.class.getName();
+
+ private final DumpCacheManager<LispGetMapRequestItrRlocsReply, Void> dumpCacheManager;
+
+ public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
+ super(futureJVppCore);
+ dumpCacheManager = new DumpCacheManagerBuilder<LispGetMapRequestItrRlocsReply, Void>()
+ .withExecutor(new ItrRemoteLocatorSetDumpExecutor(futureJVppCore)).build();
+ }
+
+ @Nonnull
+ @Override
+ public ItrRemoteLocatorSetBuilder getBuilder(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id) {
+ return new ItrRemoteLocatorSetBuilder();
+ }
+
+ @Override
+ public void readCurrentAttributes(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id,
+ @Nonnull final ItrRemoteLocatorSetBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
+
+ Optional<LispGetMapRequestItrRlocsReply> reply;
+ try {
+ reply = dumpCacheManager.getDump(CACHE_KEY, ctx.getModificationCache(), NO_PARAMS);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ if (!reply.isPresent() || reply.get().locatorSetName == null) {
+ return;
+ }
+
+ builder.setRemoteLocatorSetName(toString(reply.get().locatorSetName));
+ }
+
+ @Override
+ public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder,
+ @Nonnull final ItrRemoteLocatorSet readValue) {
+ ((LispFeatureDataBuilder) parentBuilder).setItrRemoteLocatorSet(readValue);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
index 0290aa086..52135def3 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
@@ -27,6 +27,7 @@ import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
+import io.fd.honeycomb.lisp.translate.read.trait.MappingFilterProvider;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -36,23 +37,24 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.LocalMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMappingKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappingsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,11 +63,13 @@ import org.slf4j.LoggerFactory;
*/
public class LocalMappingCustomizer
extends FutureJVppCustomizer
- implements ListReaderCustomizer<LocalMapping, LocalMappingKey, LocalMappingBuilder>, EidTranslator {
+ implements ListReaderCustomizer<LocalMapping, LocalMappingKey, LocalMappingBuilder>, EidTranslator,
+ MappingFilterProvider {
private static final Logger LOG = LoggerFactory.getLogger(LocalMappingCustomizer.class);
private static final String KEY = LocalMappingCustomizer.class.getName();
+
private final DumpCacheManager<LispEidTableDetailsReplyDump, MappingsDumpParams> dumpManager;
private final MappingsDumpExecutor dumpExecutor;
private final NamingContext locatorSetContext;
@@ -83,7 +87,6 @@ public class LocalMappingCustomizer
.build();
}
-
@Override
public LocalMappingBuilder getBuilder(InstanceIdentifier<LocalMapping> id) {
return new LocalMappingBuilder();
@@ -128,17 +131,20 @@ public class LocalMappingCustomizer
}
LispEidTableDetails details = replyOptional.get().lispEidTableDetails.stream()
- .filter(a -> compareAddresses(eid.getAddress(),
- getArrayAsEidLocal(valueOf(a.eidType), a.eid).getAddress()))
- .collect(
- RWUtils.singleItemCollector());
+ .filter(subtableFilterForLocalMappings(id))
+ .filter(detail -> compareAddresses(eid.getAddress(), getAddressFromDumpDetail(detail)))
+ .collect(RWUtils.singleItemCollector());
//in case of local mappings,locator_set_index stands for interface index
checkState(locatorSetContext.containsName(details.locatorSetIndex, ctx.getMappingContext()),
"No Locator Set name found for index %s", details.locatorSetIndex);
builder.setLocatorSet(locatorSetContext.getName(details.locatorSetIndex, ctx.getMappingContext()));
builder.setKey(new LocalMappingKey(new MappingId(id.firstKeyOf(LocalMapping.class).getId())));
- builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid));
+ builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid, details.vni));
+ }
+
+ private Address getAddressFromDumpDetail(final LispEidTableDetails detail) {
+ return getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.vni).getAddress();
}
@Override
@@ -173,14 +179,14 @@ public class LocalMappingCustomizer
return Collections.emptyList();
}
+
return replyOptional.get().lispEidTableDetails.stream()
- //filtering with vni to skip help local mappings that are created in vpp to handle remote mappings(vpp feature)
.filter(a -> a.vni == vni)
- .map(a -> new LocalMappingKey(
- new MappingId(
- localMappingContext.getId(
- getArrayAsEidLocal(valueOf(a.eidType), a.eid),
- context.getMappingContext()))))
+ .filter(subtableFilterForLocalMappings(id))
+ .map(detail -> getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.vni))
+ .map(localEid -> localMappingContext.getId(localEid, context.getMappingContext()))
+ .map(MappingId::new)
+ .map(LocalMappingKey::new)
.collect(Collectors.toList());
}
@@ -192,4 +198,5 @@ public class LocalMappingCustomizer
private static String bindKey(String prefix) {
return prefix + "_" + KEY;
}
+
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
index d4e0ef60e..21281c75b 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
@@ -28,6 +28,10 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.vpp.util.AddressTranslator;
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails;
+import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -39,9 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails;
-import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,12 +84,10 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
}
final MapResolverKey key = id.firstKeyOf(MapResolver.class);
- //revert searched key to match vpp's reversed order ip's
- final IpAddress address = reverseAddress(key.getIpAddress());
final LispMapResolverDetails mapResolverDetails =
dumpOptional.get().lispMapResolverDetails.stream()
- .filter(a -> address
- .equals(arrayToIpAddress(byteToBoolean(a.isIpv6), a.ipAddress)))
+ .filter(a -> addressesEqual(key.getIpAddress(),
+ arrayToIpAddressReversed(byteToBoolean(a.isIpv6), a.ipAddress)))
.collect(RWUtils.singleItemCollector());
builder.setKey(key);
@@ -96,6 +95,12 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
arrayToIpAddress(byteToBoolean(mapResolverDetails.isIpv6), mapResolverDetails.ipAddress));
}
+ // safest way to compare addresses - prevents returning false while using different types from hierarchy
+ // Ex. Key for MapResolver contains Ipv4Address as value but we translate addresses from binary data to Ipv4AddressNoZone
+ private boolean addressesEqual(final IpAddress left, final IpAddress right) {
+ return Arrays.equals(left.getValue(), right.getValue());
+ }
+
@Override
public List<MapResolverKey> getAllIds(InstanceIdentifier<MapResolver> id, ReadContext context)
throws ReadFailedException {
@@ -114,7 +119,7 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
return dumpOptional.get().lispMapResolverDetails.stream()
.map(resolver -> new MapResolverKey(
- arrayToIpAddress(byteToBoolean(resolver.isIpv6), resolver.ipAddress)))
+ arrayToIpAddressReversed(byteToBoolean(resolver.isIpv6), resolver.ipAddress)))
.collect(Collectors.toList());
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
index 6e97216bc..4d8bbede0 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
@@ -24,7 +24,7 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
import org.opendaylight.yangtools.concepts.Builder;
@@ -74,7 +74,7 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer
@Override
public void merge(Builder<? extends DataObject> parentBuilder, PitrCfg readValue) {
- ((LispStateBuilder) parentBuilder).setPitrCfg(readValue);
+ ((LispFeatureDataBuilder) parentBuilder).setPitrCfg(readValue);
}
public ShowLispPitrReply getPitrStatus() throws TimeoutException, VppBaseCallException {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
index 230c8766d..5d092f988 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
@@ -21,38 +21,57 @@ import static com.google.common.base.Preconditions.checkState;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.valueOf;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
+import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction.NoAction;
import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.LocatorDumpExecutor;
import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams.LocatorDumpParamsBuilder;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType;
+import io.fd.honeycomb.lisp.translate.read.trait.MappingFilterProvider;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
+import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.vpp.util.AddressTranslator;
+import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.LispLocatorDetails;
+import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.RemoteMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.NegativeMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.PositiveMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReplyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.RlocsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.LocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.LocatorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappingsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,12 +80,13 @@ import org.slf4j.LoggerFactory;
*/
public class RemoteMappingCustomizer extends FutureJVppCustomizer
implements ListReaderCustomizer<RemoteMapping, RemoteMappingKey, RemoteMappingBuilder>,
- EidTranslator {
+ EidTranslator, AddressTranslator, ByteDataTranslator, MappingFilterProvider {
private static final Logger LOG = LoggerFactory.getLogger(RemoteMappingCustomizer.class);
private static final String KEY = RemoteMappingCustomizer.class.getName();
private final DumpCacheManager<LispEidTableDetailsReplyDump, MappingsDumpParams> dumpManager;
+ private final DumpCacheManager<LispLocatorDetailsReplyDump, LocatorDumpParams> locatorsDumpManager;
private final EidMappingContext remoteMappingContext;
public RemoteMappingCustomizer(@Nonnull FutureJVppCore futureJvpp,
@@ -77,6 +97,10 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableDetailsReplyDump, MappingsDumpParams>()
.withExecutor(new MappingsDumpExecutor(futureJvpp))
.build();
+ this.locatorsDumpManager =
+ new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorDetailsReplyDump, LocatorDumpParams>()
+ .withExecutor(new LocatorDumpExecutor(futureJvpp))
+ .build();
}
@@ -130,16 +154,18 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
LOG.debug("Valid dump loaded");
LispEidTableDetails details = replyOptional.get().lispEidTableDetails.stream()
+ .filter(subtableFilterForRemoteMappings(id))
.filter(a -> compareAddresses(eid.getAddress(),
- getArrayAsEidLocal(valueOf(a.eidType), a.eid).getAddress()))
+ getArrayAsEidLocal(valueOf(a.eidType), a.eid, a.vni).getAddress()))
.collect(
RWUtils.singleItemCollector());
- builder.setEid(getArrayAsEidRemote(valueOf(details.eidType), details.eid));
+ builder.setEid(getArrayAsEidRemote(valueOf(details.eidType), details.eid, details.vni));
builder.setKey(new RemoteMappingKey(new MappingId(id.firstKeyOf(RemoteMapping.class).getId())));
builder.setTtl(resolveTtl(details.ttl));
builder.setAuthoritative(
new RemoteMapping.Authoritative(byteToBoolean(details.authoritative)));
+ resolverMappings(id, builder, details, ctx.getModificationCache());
}
//compensate ~0 as default value of ttl
@@ -185,12 +211,11 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
.lispEidTableDetails
.stream()
.filter(a -> a.vni == vni)
- .map(detail -> new RemoteMappingKey(
- new MappingId(
- remoteMappingContext.getId(
- getArrayAsEidRemote(
- valueOf(detail.eidType), detail.eid),
- context.getMappingContext()))))
+ .filter(subtableFilterForRemoteMappings(id))
+ .map(detail -> getArrayAsEidRemote(valueOf(detail.eidType), detail.eid, detail.vni))
+ .map(remoteEid -> remoteMappingContext.getId(remoteEid, context.getMappingContext()))
+ .map(MappingId::new)
+ .map(RemoteMappingKey::new)
.collect(Collectors.toList());
}
@@ -202,4 +227,68 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
private String bindKey(String prefix) {
return prefix + "_" + KEY;
}
+
+ private void resolverMappings(final InstanceIdentifier id, final RemoteMappingBuilder builder,
+ final LispEidTableDetails details,
+ final ModificationCache cache) throws ReadFailedException {
+
+ if (details.action != 0) {
+ // in this case ,negative action was defined
+ bindNegativeMapping(builder, MapReplyAction.forValue(details.action));
+ } else {
+ // in this case, there is no clear determination whether negative action with NO_ACTION(value == 0) was defined,
+ // or if its default value and remote locators, are defined, so only chance to determine so, is to dump locators for this mapping
+
+ // cache key needs to have locator set scope to not mix with cached data
+ final Optional<LispLocatorDetailsReplyDump> reply;
+ try {
+ reply = locatorsDumpManager.getDump(KEY + "_locator_set_" + details.locatorSetIndex, cache,
+ new LocatorDumpParamsBuilder().setLocatorSetIndex(details.locatorSetIndex).build());
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id,
+ new IllegalStateException("Unable to resolve Positive/Negative mapping for RemoteMapping", e));
+ }
+
+ if (!reply.isPresent() || reply.get().lispLocatorDetails.isEmpty()) {
+ // no remote locators exist, therefore there was NO_ACTION defined
+ bindNegativeMapping(builder, NoAction);
+ } else {
+ // bind remote locators
+ bindPositiveMapping(builder, reply.get());
+ }
+ }
+ }
+
+ private void bindNegativeMapping(final RemoteMappingBuilder builder,
+ final MapReplyAction action) {
+ builder.setLocatorList(
+ new NegativeMappingBuilder().setMapReply(new MapReplyBuilder().setMapReplyAction(action).build())
+ .build());
+ }
+
+ private void bindPositiveMapping(final RemoteMappingBuilder builder, final LispLocatorDetailsReplyDump reply) {
+ builder.setLocatorList(
+ new PositiveMappingBuilder()
+ .setRlocs(
+ new RlocsBuilder()
+ .setLocator(reply
+ .lispLocatorDetails
+ .stream()
+ .map(this::detailsToLocator)
+ .collect(Collectors.toList()))
+ .build()
+ )
+ .build()
+ );
+ }
+
+ private Locator detailsToLocator(final LispLocatorDetails details) {
+ final IpAddress address = arrayToIpAddressReversed(byteToBoolean(details.isIpv6), details.ipAddress);
+ return new LocatorBuilder()
+ .setAddress(address)
+ .setKey(new LocatorKey(address))
+ .setPriority((short) details.priority)
+ .setWeight((short) details.weight)
+ .build();
+ }
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java
index 3e26de47d..e8a28cc1b 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java
@@ -28,6 +28,11 @@ import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -39,9 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails;
-import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,16 +56,16 @@ public class VniTableCustomizer extends FutureJVppCustomizer
private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
private static final String LISP_TABLE_ID_DUMP = VniTableCustomizer.class.getName();
- private final DumpCacheManager<LispEidTableMapDetailsReplyDump, Void> dumpManager;
+ private final DumpCacheManager<LispEidTableVniDetailsReplyDump, Void> dumpManager;
public VniTableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
super(futureJvpp);
- this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, Void>()
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableVniDetailsReplyDump, Void>()
.withExecutor(new VniTableDumpExecutor(futureJvpp))
.build();
}
- private static VniTableKey detailsToKey(final LispEidTableMapDetails lispEidTableMapDetails) {
+ private static VniTableKey detailsToKey(final LispEidTableVniDetails lispEidTableMapDetails) {
return new VniTableKey(Integer.valueOf(lispEidTableMapDetails.vni).longValue());
}
@@ -86,18 +88,18 @@ public class VniTableCustomizer extends FutureJVppCustomizer
throws ReadFailedException {
LOG.trace("Reading all IDS...");
- Optional<LispEidTableMapDetailsReplyDump> optionalReply;
+ Optional<LispEidTableVniDetailsReplyDump> optionalReply;
try {
optionalReply = dumpManager.getDump(LISP_TABLE_ID_DUMP, context.getModificationCache(), NO_PARAMS);
} catch (DumpExecutionFailedException e) {
throw new ReadFailedException(id, e);
}
- if (!optionalReply.isPresent() || optionalReply.get().lispEidTableMapDetails.isEmpty()) {
+ if (!optionalReply.isPresent() || optionalReply.get().lispEidTableVniDetails.isEmpty()) {
return Collections.emptyList();
}
- return optionalReply.get().lispEidTableMapDetails.stream().map(VniTableCustomizer::detailsToKey)
+ return optionalReply.get().lispEidTableVniDetails.stream().map(VniTableCustomizer::detailsToKey)
.collect(Collectors.toList());
}
@@ -109,23 +111,25 @@ public class VniTableCustomizer extends FutureJVppCustomizer
checkState(id.firstKeyOf(VniTable.class) != null, "No VNI present");
VniTableKey key = new VniTableKey(id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier());
- Optional<LispEidTableMapDetailsReplyDump> optionalReply;
+ Optional<LispEidTableVniDetailsReplyDump> optionalReply;
try {
optionalReply = dumpManager.getDump(LISP_TABLE_ID_DUMP, ctx.getModificationCache(), NO_PARAMS);
} catch (DumpExecutionFailedException e) {
throw new ReadFailedException(id, e);
}
- if (!optionalReply.isPresent() || optionalReply.get().lispEidTableMapDetails.isEmpty()) {
+ if (!optionalReply.isPresent() || optionalReply.get().lispEidTableVniDetails.isEmpty()) {
return;
}
//transforming right away to single detail(specific request should do the magic)
- final LispEidTableMapDetails details =
- optionalReply.get().lispEidTableMapDetails.stream().filter(a -> detailsToKey(a).equals(key))
- .collect(RWUtils.singleItemCollector());
+ final LispEidTableVniDetails details = optionalReply.get()
+ .lispEidTableVniDetails
+ .stream()
+ .filter(a -> a.vni == key.getVirtualNetworkIdentifier().intValue())
+ .collect(RWUtils.singleItemCollector());
builder.setVirtualNetworkIdentifier((long) details.vni);
- builder.setTableId((long) details.dpTable);
+ builder.setKey(new VniTableKey(Long.valueOf(details.vni)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizer.java
new file mode 100644
index 000000000..5072c37c2
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizer.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.SubtableDumpExecutor;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams;
+import io.fd.honeycomb.lisp.translate.read.trait.SubtableReader;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtableBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VrfSubtableCustomizer extends FutureJVppCustomizer
+ implements ReaderCustomizer<VrfSubtable, VrfSubtableBuilder>, SubtableReader {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VrfSubtableCustomizer.class);
+ private static final String CACHE_KEY = VrfSubtableCustomizer.class.getName();
+
+ private final DumpCacheManager<LispEidTableMapDetailsReplyDump, SubtableDumpParams> dumpManager;
+ private final SubtableDumpExecutor dumpExecutor;
+
+ public VrfSubtableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ dumpExecutor = new SubtableDumpExecutor(futureJvpp);
+ dumpManager =
+ new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, SubtableDumpParams>()
+ .withExecutor(dumpExecutor)
+ .build();
+ }
+
+ @Nonnull
+ @Override
+ public VrfSubtableBuilder getBuilder(@Nonnull final InstanceIdentifier<VrfSubtable> id) {
+ return new VrfSubtableBuilder();
+ }
+
+ @Override
+ public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
+ @Nonnull final VrfSubtableBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
+ LOG.debug("Read attributes for {}", id);
+ final int vni = checkNotNull(id.firstKeyOf(VniTable.class), "Cannot find parent VNI Table")
+ .getVirtualNetworkIdentifier().intValue();
+
+ final Optional<LispEidTableMapDetailsReplyDump> reply =
+ readSubtable(dumpManager, CACHE_KEY, ctx.getModificationCache(), id, L3_PARAMS);
+
+ if (!reply.isPresent() || reply.get().lispEidTableMapDetails.isEmpty()) {
+ return;
+ }
+
+ // Single item collector cant be used in this case,because vrf-subtable is container
+ // so read is invoked every time parent is defined
+ final List<LispEidTableMapDetails> details =
+ reply.get().lispEidTableMapDetails.stream().filter(a -> a.vni == vni)
+ .collect(Collectors.toList());
+ if (details.size() == 1) {
+ final LispEidTableMapDetails detail = details.get(0);
+ builder.setTableId(Integer.valueOf(detail.dpTable).longValue());
+
+ LOG.debug("Attributes for {} successfully loaded", id);
+ }
+ }
+
+ @Override
+ public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder,
+ @Nonnull final VrfSubtable readValue) {
+ ((VniTableBuilder) parentBuilder).setVrfSubtable(readValue);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractJvppDumpExecutor.java
index d1aea12b0..65f41443c 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractJvppDumpExecutor.java
@@ -23,13 +23,13 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
- * Abstract holder for jvpp refference
+ * Abstract holder for jvpp reference
*/
-public abstract class AbstractDumpExecutor {
+public abstract class AbstractJvppDumpExecutor {
protected final FutureJVppCore vppApi;
- protected AbstractDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
- this.vppApi = checkNotNull(vppApi, "VPP Api refference cannot be null");
+ public AbstractJvppDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ this.vppApi = checkNotNull(vppApi, "VPP Api reference cannot be null");
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/ItrRemoteLocatorSetDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/ItrRemoteLocatorSetDumpExecutor.java
new file mode 100644
index 000000000..391fa7668
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/ItrRemoteLocatorSetDumpExecutor.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs;
+import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+public class ItrRemoteLocatorSetDumpExecutor extends AbstractJvppDumpExecutor
+ implements EntityDumpExecutor<LispGetMapRequestItrRlocsReply, Void>, JvppReplyConsumer {
+
+ public ItrRemoteLocatorSetDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public LispGetMapRequestItrRlocsReply executeDump(final Void params) throws DumpExecutionFailedException {
+ try {
+ return getReply(vppApi.lispGetMapRequestItrRlocs(new LispGetMapRequestItrRlocs()).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException.wrapTimeoutException("Dumping of Itr Remote Locator Sets ended in timeout", e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException.wrapFailedCallException("Dumping of Itr Remote Locator Sets failed", e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
index ad588e28d..86ac1ac63 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
@@ -35,7 +35,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Executor for dumping of locators
*/
-public class LocatorDumpExecutor extends AbstractDumpExecutor
+public class LocatorDumpExecutor extends AbstractJvppDumpExecutor
implements EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams>, JvppReplyConsumer {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
index ec2cb3405..383cb8e78 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
@@ -30,7 +30,7 @@ import io.fd.vpp.jvpp.core.dto.LispLocatorSetDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
+public class LocatorSetsDumpExecutor extends AbstractJvppDumpExecutor
implements EntityDumpExecutor<LispLocatorSetDetailsReplyDump, Void>, JvppReplyConsumer {
public LocatorSetsDumpExecutor(@Nonnull FutureJVppCore api) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
index 9b6f5dec3..7df537040 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
@@ -30,7 +30,7 @@ import io.fd.vpp.jvpp.core.dto.LispMapResolverDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-public class MapResolversDumpExecutor extends AbstractDumpExecutor
+public class MapResolversDumpExecutor extends AbstractJvppDumpExecutor
implements EntityDumpExecutor<LispMapResolverDetailsReplyDump, Void>, JvppReplyConsumer {
public MapResolversDumpExecutor(@Nonnull FutureJVppCore api) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
index bdf84e14d..8e68c143a 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
@@ -36,7 +36,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Common dump executor for both local and remote mappings
*/
-public class MappingsDumpExecutor extends AbstractDumpExecutor
+public class MappingsDumpExecutor extends AbstractJvppDumpExecutor
implements EntityDumpExecutor<LispEidTableDetailsReplyDump, MappingsDumpParams>, JvppReplyConsumer {
public MappingsDumpExecutor(@Nonnull FutureJVppCore vppApi) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/SubtableDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/SubtableDumpExecutor.java
new file mode 100644
index 000000000..722cbb182
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/SubtableDumpExecutor.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+/**
+ * Dump executor for {@link VrfSubtable}/{@link BridgeDomainSubtable}
+ */
+public final class SubtableDumpExecutor extends AbstractJvppDumpExecutor
+ implements EntityDumpExecutor<LispEidTableMapDetailsReplyDump, SubtableDumpParams>, JvppReplyConsumer {
+
+ private SubtableDumpParams params;
+ private LispEidTableMapDump request;
+
+ public SubtableDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public LispEidTableMapDetailsReplyDump executeDump(final SubtableDumpParams params)
+ throws DumpExecutionFailedException {
+ this.params = checkNotNull(params, "Cannot bind null params");
+
+ LispEidTableMapDump request = new LispEidTableMapDump();
+ request.isL2 = params.isL2();
+
+ try {
+ return getReply(vppApi.lispEidTableMapDump(request).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException
+ .wrapTimeoutException("Dumping subtable with params " + params + " timed out", e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException
+ .wrapFailedCallException("Dumping subtable with params " + params + " timed out", e);
+ }
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
index 05e33c2e1..6c9a21ef1 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
@@ -22,25 +22,25 @@ import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecut
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
-import java.util.concurrent.TimeoutException;
-import javax.annotation.Nonnull;
import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.LispEidTableMapDump;
+import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.LispEidTableVniDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
-public class VniTableDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispEidTableMapDetailsReplyDump, Void>, JvppReplyConsumer {
+public class VniTableDumpExecutor extends AbstractJvppDumpExecutor
+ implements EntityDumpExecutor<LispEidTableVniDetailsReplyDump, Void>, JvppReplyConsumer {
public VniTableDumpExecutor(@Nonnull FutureJVppCore api) {
super(api);
}
@Override
- public LispEidTableMapDetailsReplyDump executeDump(Void params) throws DumpExecutionFailedException {
+ public LispEidTableVniDetailsReplyDump executeDump(Void params) throws DumpExecutionFailedException {
try {
- return getReply(vppApi.lispEidTableMapDump(new LispEidTableMapDump()).toCompletableFuture());
+ return getReply(vppApi.lispEidTableVniDump(new LispEidTableVniDump()).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException.wrapTimeoutException("Eid table map dump ended in timeout", e);
} catch (VppBaseCallException e) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/SubtableDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/SubtableDumpParams.java
new file mode 100644
index 000000000..a9a19ccf5
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/SubtableDumpParams.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor.params;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+
+/**
+ * Parameters for dumping {@link VrfSubtable}/{@link BridgeDomainSubtable}
+ */
+public final class SubtableDumpParams {
+
+ private final byte isL2;
+
+ private SubtableDumpParams(SubtableDumpParamsBuilder builder) {
+ this.isL2 = builder.isL2;
+ }
+
+ public byte isL2() {
+ return isL2;
+ }
+
+ @Override
+ public String toString() {
+ return "SubtableDumpParams{" +
+ "isL2=" + isL2 +
+ '}';
+ }
+
+ public enum MapLevel {
+ L2(1),
+ L3(0);
+
+ private final int value;
+
+ private MapLevel(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+ }
+
+ public static final class SubtableDumpParamsBuilder {
+
+ private byte isL2;
+
+ public SubtableDumpParamsBuilder setL2(@Nonnull final MapLevel mapLevel) {
+ isL2 = Integer.valueOf(checkNotNull(mapLevel, "Cannot set null map level").getValue()).byteValue();
+ return this;
+ }
+
+ public SubtableDumpParams build() {
+ return new SubtableDumpParams(this);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
index 123aba59d..2aec19fcb 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
@@ -35,6 +35,7 @@ abstract class AbstractLispReaderFactoryBase {
protected final FutureJVppCore vppApi;
protected NamingContext interfaceContext;
protected NamingContext locatorSetContext;
+ protected NamingContext bridgeDomainContext;
protected EidMappingContext localMappingContext;
protected EidMappingContext remoteMappingContext;
@@ -76,4 +77,25 @@ abstract class AbstractLispReaderFactoryBase {
this.remoteMappingContext = checkNotNull(remoteMappingContext,
"Remote mappings reference is null,for readers that don't need this dependency use different constructor");
}
+
+ protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext,
+ @Nonnull final NamingContext bridgeDomainContext,
+ @Nonnull final EidMappingContext localMappingContext,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
+ this.interfaceContext = checkNotNull(interfaceContext,
+ "Interface naming context is null,for readers that don't need this dependency,use different constructor");
+ this.locatorSetContext = checkNotNull(locatorSetContext,
+ "Locator set naming context is null,for readers that don't need this dependency,use different constructor");
+ this.bridgeDomainContext = checkNotNull(bridgeDomainContext,
+ "Bridge domain naming context is null,for readers that don't need this dependency,use different constructor");
+ this.localMappingContext = checkNotNull(localMappingContext,
+ "Local mappings reference is null,for readers that don't need this dependency use different constructor");
+ this.remoteMappingContext = checkNotNull(remoteMappingContext,
+ "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
+ }
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java
index 6395f29a2..805d6c5bd 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java
@@ -20,31 +20,40 @@ package io.fd.honeycomb.lisp.translate.read.factory;
import com.google.common.collect.ImmutableSet;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.read.AdjacencyCustomizer;
+import io.fd.honeycomb.lisp.translate.read.BridgeDomainSubtableCustomizer;
import io.fd.honeycomb.lisp.translate.read.LocalMappingCustomizer;
import io.fd.honeycomb.lisp.translate.read.RemoteMappingCustomizer;
import io.fd.honeycomb.lisp.translate.read.VniTableCustomizer;
+import io.fd.honeycomb.lisp.translate.read.VrfSubtableCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
+import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.AdjacenciesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.LocalMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.RemoteMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.AdjacenciesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappingsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappingsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
@@ -56,57 +65,110 @@ final class EidTableReaderFactory extends AbstractLispReaderFactoryBase implemen
final FutureJVppCore vppApi,
final NamingContext interfaceContext,
final NamingContext locatorSetContext,
+ final NamingContext bridgeDomainContext,
final EidMappingContext localMappingContext,
final EidMappingContext remoteMappingContext) {
- super(lispStateId, vppApi,interfaceContext, locatorSetContext, localMappingContext, remoteMappingContext);
+ super(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext, localMappingContext,
+ remoteMappingContext);
}
public static EidTableReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
@Nonnull final FutureJVppCore vppApi,
@Nonnull final NamingContext interfaceContext,
@Nonnull final NamingContext locatorSetContext,
+ @Nonnull final NamingContext bridgeDomainContext,
@Nonnull final EidMappingContext localMappingContext,
@Nonnull final EidMappingContext remoteMappingContext) {
- return new EidTableReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext, localMappingContext,
+ return new EidTableReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext,
+ localMappingContext,
remoteMappingContext);
}
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
- InstanceIdentifier<EidTable> eidTableInstanceIdentifier = lispStateId.child(EidTable.class);
- InstanceIdentifier<VniTable> vniTableInstanceIdentifier = eidTableInstanceIdentifier.child(VniTable.class);
- InstanceIdentifier<LocalMappings> localMappingsInstanceIdentifier =
- vniTableInstanceIdentifier.child(LocalMappings.class);
- InstanceIdentifier<RemoteMappings> remoteMappingsInstanceIdentifier =
- vniTableInstanceIdentifier.child(RemoteMappings.class);
- InstanceIdentifier<Adjacencies> adjacenciesInstanceIdentifier =
- vniTableInstanceIdentifier.child(Adjacencies.class);
+ final InstanceIdentifier<EidTable> eidTableInstanceIdentifier =
+ lispStateId.child(LispFeatureData.class).child(EidTable.class);
+ final InstanceIdentifier<VniTable> vniTableInstanceIdentifier =
+ eidTableInstanceIdentifier.child(VniTable.class);
+ final InstanceIdentifier<VrfSubtable> vrfSubtable = vniTableInstanceIdentifier.child(VrfSubtable.class);
+ final InstanceIdentifier<BridgeDomainSubtable> bridgeDomainSubtable =
+ vniTableInstanceIdentifier.child(BridgeDomainSubtable.class);
+
+ final InstanceIdentifier<LocalMappings> vrfTableLocalMappingsInstanceIdentifier =
+ vrfSubtable.child(LocalMappings.class);
+ final InstanceIdentifier<RemoteMappings> vrfTableRemoteMappingsInstanceIdentifier =
+ vrfSubtable.child(RemoteMappings.class);
+ final InstanceIdentifier<Adjacencies> vrfTableAdjacenciesInstanceIdentifier =
+ vrfSubtable.child(RemoteMappings.class).child(RemoteMapping.class).child(Adjacencies.class);
+ final InstanceIdentifier<LocalMappings> bridgeDomainLocalMappingsInstanceIdentifier =
+ bridgeDomainSubtable.child(LocalMappings.class);
+ final InstanceIdentifier<RemoteMappings> bridgeDomainRemoteMappingsInstanceIdentifier =
+ bridgeDomainSubtable.child(RemoteMappings.class);
+ final InstanceIdentifier<Adjacencies> bridgeDomainAdjacenciesInstanceIdentifier =
+ bridgeDomainSubtable.child(RemoteMappings.class).child(RemoteMapping.class).child(Adjacencies.class);
+
+ //EidTable
registry.addStructuralReader(eidTableInstanceIdentifier, EidTableBuilder.class);
+ //EidTable -> VniTable
registry.add(new GenericListReader<>(vniTableInstanceIdentifier, new VniTableCustomizer(vppApi)));
- registry.addStructuralReader(localMappingsInstanceIdentifier, LocalMappingsBuilder.class);
+ //EidTable -> VniTable -> VrfSubtable
+ registry.add(new GenericReader<>(vrfSubtable, new VrfSubtableCustomizer(vppApi)));
+
+ //EidTable -> VniTable -> BridgeDomainSubtable
+ registry.add(new GenericReader<>(bridgeDomainSubtable,
+ new BridgeDomainSubtableCustomizer(vppApi, bridgeDomainContext)));
+
+ //EidTable -> VniTable -> VrfSubtable -> LocalMappings
+ registry.addStructuralReader(vrfTableLocalMappingsInstanceIdentifier, LocalMappingsBuilder.class);
+ //EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings
+ registry.addStructuralReader(bridgeDomainLocalMappingsInstanceIdentifier, LocalMappingsBuilder.class);
final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
+ //EidTable -> VniTable -> VrfSubtable -> LocalMappings -> LocalMapping
registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid.class)),
- new GenericListReader<>(localMappingsInstanceIdentifier.child(LocalMapping.class),
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
+ new GenericListReader<>(vrfTableLocalMappingsInstanceIdentifier.child(LocalMapping.class),
new LocalMappingCustomizer(vppApi, locatorSetContext, localMappingContext)));
- registry.addStructuralReader(remoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
+ //EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings -> LocalMapping
+ registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
+ new GenericListReader<>(bridgeDomainLocalMappingsInstanceIdentifier.child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, locatorSetContext, localMappingContext)));
+
+ //EidTable -> VniTable -> VrfSubtable -> RemoteMappings
+ registry.addStructuralReader(vrfTableRemoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
+ registry.addStructuralReader(bridgeDomainRemoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid.class)),
- new GenericListReader<>(remoteMappingsInstanceIdentifier.child(RemoteMapping.class),
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class)),
+ new GenericListReader<>(vrfTableRemoteMappingsInstanceIdentifier.child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+ registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class)),
+ new GenericListReader<>(bridgeDomainRemoteMappingsInstanceIdentifier.child(RemoteMapping.class),
new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
- registry.addStructuralReader(adjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
+ registry.addStructuralReader(vrfTableAdjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
+ registry.addStructuralReader(bridgeDomainAdjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
registry.subtreeAdd(
ImmutableSet.of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListReader<>(adjacenciesInstanceIdentifier.child(Adjacency.class),
+ new GenericListReader<>(vrfTableAdjacenciesInstanceIdentifier.child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi)));
+ registry.subtreeAdd(
+ ImmutableSet.of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
+ new GenericListReader<>(bridgeDomainAdjacenciesInstanceIdentifier.child(Adjacency.class),
new AdjacencyCustomizer(vppApi)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java
index 9e710c69f..a2290bda1 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java
@@ -30,11 +30,13 @@ import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
@@ -46,26 +48,27 @@ public class LispStateReaderFactory extends AbstractLispReaderFactoryBase implem
public LispStateReaderFactory(final FutureJVppCore vppApi,
@Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
@Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
+ @Named("bridge-domain-context") final NamingContext bridgeDomainContext,
@Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
@Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext) {
super(InstanceIdentifier.create(LispState.class), vppApi, interfaceContext, locatorSetContext,
- localMappingContext,
- remoteMappingContext);
+ bridgeDomainContext, localMappingContext, remoteMappingContext);
}
-
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
registry.add(new GenericReader<>(lispStateId, new LispStateCustomizer(vppApi)));
+ registry.addStructuralReader(lispStateId.child(LispFeatureData.class), LispFeatureDataBuilder.class);
LocatorSetsReaderFactory.newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext).init(registry);
MapResolversReaderFactory.newInstance(lispStateId, vppApi).init(registry);
EidTableReaderFactory
- .newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext, localMappingContext,
- remoteMappingContext)
+ .newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext,
+ localMappingContext, remoteMappingContext)
.init(registry);
- registry.add(new GenericReader<>(lispStateId.child(PitrCfg.class), new PitrCfgCustomizer(vppApi)));
+ registry.add(new GenericReader<>(lispStateId.child(LispFeatureData.class).child(PitrCfg.class),
+ new PitrCfgCustomizer(vppApi)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
index bc96474f5..9a8e74383 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
@@ -25,6 +25,7 @@ import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSetsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
@@ -57,7 +58,7 @@ public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase impl
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
- InstanceIdentifier<LocatorSets> locatorSetsInstanceIdentifier = lispStateId.child(LocatorSets.class);
+ InstanceIdentifier<LocatorSets> locatorSetsInstanceIdentifier = lispStateId.child(LispFeatureData.class).child(LocatorSets.class);
InstanceIdentifier<LocatorSet> locatorSetInstanceIdentifier =
locatorSetsInstanceIdentifier.child(LocatorSet.class);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java
index a484f3635..b41f26f81 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java
@@ -23,6 +23,7 @@ import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolversBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
@@ -47,7 +48,8 @@ public class MapResolversReaderFactory extends AbstractLispReaderFactoryBase imp
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
- InstanceIdentifier<MapResolvers> mapResolversInstanceIdentifier = lispStateId.child(MapResolvers.class);
+ InstanceIdentifier<MapResolvers> mapResolversInstanceIdentifier =
+ lispStateId.child(LispFeatureData.class).child(MapResolvers.class);
registry.addStructuralReader(mapResolversInstanceIdentifier, MapResolversBuilder.class);
registry.add(new GenericListReader<>(mapResolversInstanceIdentifier.child(MapResolver.class),
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingFilterProvider.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingFilterProvider.java
new file mode 100644
index 000000000..ef1ca0438
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingFilterProvider.java
@@ -0,0 +1,50 @@
+package io.fd.honeycomb.lisp.translate.read.trait;
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+
+import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
+
+/**
+ * Trait providing predicates to filter mappings to respective subtables
+ */
+public interface MappingFilterProvider {
+
+ Predicate<LispEidTableDetails> BRIDGE_DOMAIN_MAPPINGS_ONLY =
+ (LispEidTableDetails detail) -> detail.eidType == MAC.getValue();
+
+ Predicate<LispEidTableDetails> VRF_MAPPINGS_ONLY =
+ (LispEidTableDetails detail) -> detail.eidType == IPV4.getValue() || detail.eidType == IPV6.getValue();
+
+ default Predicate<LispEidTableDetails> subtableFilterForLocalMappings(
+ @Nonnull final InstanceIdentifier<LocalMapping> identifier) {
+
+ if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
+ return VRF_MAPPINGS_ONLY;
+ } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
+ return BRIDGE_DOMAIN_MAPPINGS_ONLY;
+ } else {
+ throw new IllegalArgumentException("Cannot determine mappings predicate for " + identifier);
+ }
+ }
+
+ default Predicate<LispEidTableDetails> subtableFilterForRemoteMappings(
+ @Nonnull final InstanceIdentifier<RemoteMapping> identifier) {
+
+ if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
+ return VRF_MAPPINGS_ONLY;
+ } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
+ return BRIDGE_DOMAIN_MAPPINGS_ONLY;
+ } else {
+ throw new IllegalArgumentException("Cannot determine mappings predicate for " + identifier);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducer.java
new file mode 100644
index 000000000..104e696e3
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducer.java
@@ -0,0 +1,56 @@
+package io.fd.honeycomb.lisp.translate.read.trait;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4Afi;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6Afi;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Trait that verifies data for mappings
+ */
+public interface MappingProducer {
+
+ /**
+ * Checks whether provided {@link LocalMapping} can be written under subtree idenfied by {@link InstanceIdentifier}
+ */
+ default void checkAllowedCombination(@Nonnull final InstanceIdentifier<LocalMapping> identifier,
+ @Nonnull final LocalMapping data) throws WriteFailedException {
+ final Class<? extends LispAddressFamily> eidAddressType = data.getEid().getAddressType();
+
+ if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
+ if (Ipv4Afi.class != eidAddressType && Ipv6Afi.class != eidAddressType) {
+ throw new WriteFailedException.CreateFailedException(identifier, data,
+ new IllegalArgumentException("Only Ipv4/Ipv6 eid's are allowed for Vrf Subtable"));
+ }
+ } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
+ if (MacAfi.class != eidAddressType) {
+ throw new WriteFailedException.CreateFailedException(identifier, data,
+ new IllegalArgumentException("Only Mac eid's are allowed for Bridge Domain Subtable"));
+ }
+ }
+ }
+
+ default void checkAllowedCombination(@Nonnull final InstanceIdentifier<RemoteMapping> identifier,
+ @Nonnull final RemoteMapping data) throws WriteFailedException {
+ final Class<? extends LispAddressFamily> eidAddressType = data.getEid().getAddressType();
+
+ if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
+ if (Ipv4Afi.class != eidAddressType && Ipv6Afi.class != eidAddressType) {
+ throw new WriteFailedException.CreateFailedException(identifier, data,
+ new IllegalArgumentException("Only Ipv4/Ipv6 eid's are allowed for Vrf Subtable"));
+ }
+ } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
+ if (MacAfi.class != eidAddressType) {
+ throw new WriteFailedException.CreateFailedException(identifier, data,
+ new IllegalArgumentException("Only Mac eid's are allowed for Bridge Domain Subtable"));
+ }
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReader.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReader.java
new file mode 100644
index 000000000..7af6a7e90
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReader.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.trait;
+
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L2;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L3;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.SubtableDumpParamsBuilder;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+
+/**
+ * Provides common logic for reading Eid subtables
+ */
+public interface SubtableReader {
+
+ SubtableDumpParams L2_PARAMS = new SubtableDumpParamsBuilder().setL2(L2).build();
+ SubtableDumpParams L3_PARAMS = new SubtableDumpParamsBuilder().setL2(L3).build();
+
+ default Optional<LispEidTableMapDetailsReplyDump> readSubtable(
+ @Nonnull final DumpCacheManager<LispEidTableMapDetailsReplyDump, SubtableDumpParams> dumpManager,
+ @Nonnull final String cacheKey,
+ @Nonnull final ModificationCache cache,
+ @Nonnull final InstanceIdentifier<? extends ChildOf<VniTable>> id,
+ @Nonnull final SubtableDumpParams params) throws ReadFailedException {
+ try {
+ return dumpManager.getDump(cacheKey, cache, params);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidMetadataProvider.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidMetadataProvider.java
new file mode 100644
index 000000000..11de4e7b8
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidMetadataProvider.java
@@ -0,0 +1,36 @@
+package io.fd.honeycomb.lisp.translate.util;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily;
+
+/**
+ * Trait providing metadata for eid's
+ */
+public interface EidMetadataProvider {
+
+ /**
+ * Returns new {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder}
+ * binded with metadata
+ */
+ default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder newRemoteEidBuilder(
+ @Nonnull final Class<? extends LispAddressFamily> eidAddressType,
+ final int vni) {
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder()
+ .setAddressType(eidAddressType)
+ .setVirtualNetworkId(new InstanceIdType(Long.valueOf(vni)));
+ }
+
+ /**
+ * Returns new {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.EidBuilder}
+ * binded with metadata
+ */
+ default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.EidBuilder newLocalEidBuilder(
+ @Nonnull final Class<? extends LispAddressFamily> eidAddressType,
+ final int vni) {
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.EidBuilder()
+ .setAddressType(eidAddressType)
+ .setVirtualNetworkId(new InstanceIdType(Long.valueOf(vni)));
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java
index dcf9a7e27..7bc99e5f2 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java
@@ -24,9 +24,13 @@ import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsD
import io.fd.honeycomb.translate.vpp.util.AddressTranslator;
import java.util.Arrays;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4Afi;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6Afi;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
@@ -35,16 +39,15 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.addres
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid;
/**
* Trait providing converting logic for eid's
*/
-public interface EidTranslator extends AddressTranslator {
+public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
default byte getPrefixLength(LocalEid address) {
@@ -61,12 +64,12 @@ public interface EidTranslator extends AddressTranslator {
}
default byte getPrefixLength(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid address) {
return resolverPrefixLength(address.getAddress());
}
default byte getPrefixLength(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid address) {
return resolverPrefixLength(address.getAddress());
}
@@ -84,21 +87,21 @@ public interface EidTranslator extends AddressTranslator {
}
}
- default Eid getArrayAsEidLocal(EidType type, byte[] address) {
+ default Eid getArrayAsEidLocal(@Nonnull final EidType type, final byte[] address, final int vni) {
switch (type) {
case IPV4: {
- return new EidBuilder().setAddress(
+ return newLocalEidBuilder(Ipv4Afi.class, vni).setAddress(
new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address)).build())
.build();
}
case IPV6: {
- return new EidBuilder().setAddress(
+ return newLocalEidBuilder(Ipv6Afi.class, vni).setAddress(
new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address)).build())
.build();
}
case MAC: {
- return new EidBuilder().setAddress(
+ return newLocalEidBuilder(MacAfi.class, vni).setAddress(
new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address)))
.build()).build();
}
@@ -108,26 +111,26 @@ public interface EidTranslator extends AddressTranslator {
}
}
- default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid getArrayAsEidRemote(
- EidType type, byte[] address) {
+ default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid getArrayAsEidRemote(
+ @Nonnull final EidType type, final byte[] address, final int vni) {
switch (type) {
case IPV4: {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ return newRemoteEidBuilder(Ipv4Afi.class, vni)
.setAddress(
new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address))
.build())
.build();
}
case IPV6: {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ return newRemoteEidBuilder(Ipv6Afi.class, vni)
.setAddress(
new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address))
.build())
.build();
}
case MAC: {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ return newRemoteEidBuilder(MacAfi.class, vni)
.setAddress(
new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address)))
.build()).build();
@@ -166,7 +169,7 @@ public interface EidTranslator extends AddressTranslator {
}
default EidType getEidType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid address) {
checkNotNull(address, "SimpleAddress cannot be null");
return resolveType(address.getAddress());
@@ -174,7 +177,7 @@ public interface EidTranslator extends AddressTranslator {
default EidType getEidType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid address) {
checkNotNull(address, "Address cannot be null");
return resolveType(address.getAddress());
@@ -215,14 +218,14 @@ public interface EidTranslator extends AddressTranslator {
}
default byte[] getEidAsByteArray(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
default byte[] getEidAsByteArray(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
@@ -279,6 +282,6 @@ public interface EidTranslator extends AddressTranslator {
return ((Mac) firstAddress).getMac().getValue().equals(((Mac) secondAddress).getMac().getValue());
}
- throw new IllegalArgumentException("Unsupported eid type " + firstAddress.getClass());
+ return false;
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
index 9cd276741..89f398d4d 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
@@ -18,9 +18,10 @@ package io.fd.honeycomb.lisp.translate.write;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Preconditions.checkNotNull;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
@@ -28,23 +29,33 @@ import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.LispAddDelAdjacency;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.LispAddDelAdjacency;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-
public class AdjacencyCustomizer extends FutureJVppCustomizer
implements ListWriterCustomizer<Adjacency, AdjacencyKey>, ByteDataTranslator, EidTranslator,
JvppReplyConsumer {
- public AdjacencyCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ private final EidMappingContext localEidsMappingContext;
+ private final EidMappingContext remoteEidsMappingContext;
+
+ public AdjacencyCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull EidMappingContext localEidsMappingContext,
+ @Nonnull EidMappingContext remoteEidsMappingContext) {
super(futureJvpp);
+ this.localEidsMappingContext =
+ checkNotNull(localEidsMappingContext, "Eid context for local eid's cannot be null");
+ this.remoteEidsMappingContext =
+ checkNotNull(remoteEidsMappingContext, "Eid context for remote eid's cannot be null");
}
@Override
@@ -53,7 +64,7 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer
throws WriteFailedException {
try {
- addDelAdjacency(true, id, dataAfter);
+ addDelAdjacency(true, id, dataAfter, writeContext);
} catch (TimeoutException | VppBaseCallException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
@@ -71,20 +82,31 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer
@Nonnull final Adjacency dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
try {
- addDelAdjacency(false, id, dataBefore);
+ addDelAdjacency(false, id, dataBefore, writeContext);
} catch (TimeoutException | VppBaseCallException e) {
throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
}
}
- private void addDelAdjacency(boolean add, final InstanceIdentifier<Adjacency> id, Adjacency data)
+ private void addDelAdjacency(boolean add, final InstanceIdentifier<Adjacency> id, final Adjacency data,
+ final WriteContext writeContext)
throws TimeoutException, VppBaseCallException {
- checkState(id.firstKeyOf(VniTable.class) != null, "Unable to find parent VNI for {}", id);
- final int vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue();
-
- EidType localEidType = getEidType(data.getLocalEid());
- EidType remoteEidType = getEidType(data.getRemoteEid());
+ final int vni = checkNotNull(id.firstKeyOf(VniTable.class), "Unable to find parent VNI for {}", id)
+ .getVirtualNetworkIdentifier().intValue();
+
+ // both local and remote eids must be referenced to have respective mapping,
+ // if there is an attempt to add adjacency.
+ // In our case its enough to check if local/remote mapping exist for respective eid,
+ // because such mappings are created while creating mappings
+ final LocalEid localEid = add
+ ? verifiedLocalEid(data.getLocalEid(), writeContext)
+ : data.getLocalEid();
+ final RemoteEid remoteEid = add
+ ? verifiedRemoteEid(data.getRemoteEid(), writeContext)
+ : data.getRemoteEid();
+ final EidType localEidType = getEidType(localEid);
+ final EidType remoteEidType = getEidType(data.getRemoteEid());
checkArgument(localEidType ==
remoteEidType, "Local[%s] and Remote[%s] eid types must be the same", localEidType, remoteEidType);
@@ -92,13 +114,43 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer
LispAddDelAdjacency request = new LispAddDelAdjacency();
request.isAdd = booleanToByte(add);
- request.leid = getEidAsByteArray(data.getLocalEid());
- request.leidLen = getPrefixLength(data.getLocalEid());
- request.reid = getEidAsByteArray(data.getRemoteEid());
- request.reidLen = getPrefixLength(data.getRemoteEid());
+ request.leid = getEidAsByteArray(localEid);
+ request.leidLen = getPrefixLength(localEid);
+ request.reid = getEidAsByteArray(remoteEid);
+ request.reidLen = getPrefixLength(remoteEid);
request.eidType = (byte) localEidType.getValue();
request.vni = vni;
getReply(getFutureJVpp().lispAddDelAdjacency(request).toCompletableFuture());
}
+
+ private LocalEid verifiedLocalEid(final LocalEid localEid, final WriteContext writeContext) {
+ if (localEidsMappingContext.containsId(toLocalEid(localEid), writeContext.getMappingContext())) {
+ return localEid;
+ }
+ throw new IllegalStateException(
+ "Referenced Local Eid[" + localEid +
+ "] doesn't have local mapping defined, therefore it can't be used in adjacency");
+ }
+
+ private RemoteEid verifiedRemoteEid(final RemoteEid remoteEid, final WriteContext writeContext) {
+ if (remoteEidsMappingContext.containsId(toRemoteEid(remoteEid), writeContext.getMappingContext())) {
+ return remoteEid;
+ }
+ throw new IllegalStateException(
+ "Referenced Remote Eid[" + remoteEid +
+ "] doesn't have remote mapping defined, therefore it can't be used in adjacency");
+ }
+
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid toRemoteEid(
+ final RemoteEid remoteEid) {
+ return newRemoteEidBuilder(remoteEid.getAddressType(), remoteEid.getVirtualNetworkId().getValue().intValue())
+ .setAddress(remoteEid.getAddress()).build();
+ }
+
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid toLocalEid(
+ LocalEid localEid) {
+ return newLocalEidBuilder(localEid.getAddressType(), localEid.getVirtualNetworkId().getValue().intValue())
+ .setAddress(localEid.getAddress()).build();
+ }
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/BridgeDomainSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/BridgeDomainSubtableCustomizer.java
new file mode 100644
index 000000000..d86957b37
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/BridgeDomainSubtableCustomizer.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import io.fd.honeycomb.lisp.translate.write.trait.SubtableWriter;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.vpp.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BridgeDomainSubtableCustomizer extends FutureJVppCustomizer
+ implements WriterCustomizer<BridgeDomainSubtable>, SubtableWriter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainSubtableCustomizer.class);
+
+ private final NamingContext bridgeDomainContext;
+
+ public BridgeDomainSubtableCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final NamingContext bridgeDomainContext) {
+ super(futureJvpp);
+ this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomainSubtable> id,
+ @Nonnull final BridgeDomainSubtable dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ LOG.debug("Writing Id {} ", id);
+
+ try {
+ addDelSubtableMapping(getFutureJVpp(), true, extractVni(id),
+ extractBridgeDomainId(dataAfter.getBridgeDomainRef(), writeContext.getMappingContext()), true, LOG);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ LOG.debug("{} successfully written", id);
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomainSubtable> id,
+ @Nonnull final BridgeDomainSubtable dataBefore,
+ @Nonnull final BridgeDomainSubtable dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomainSubtable> id,
+ @Nonnull final BridgeDomainSubtable dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ LOG.debug("Removing Id {}", id);
+
+ try {
+ addDelSubtableMapping(getFutureJVpp(), false, extractVni(id),
+ extractBridgeDomainId(dataBefore.getBridgeDomainRef(), writeContext.getMappingContext()), true,
+ LOG);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+
+ LOG.debug("{} successfully removed", id);
+ }
+
+ private int extractBridgeDomainId(final String bridgeDomainName, final MappingContext mappingContext) {
+ checkState(bridgeDomainContext.containsIndex(bridgeDomainName, mappingContext),
+ "No mapping for bridge domain name %s", bridgeDomainName);
+ return bridgeDomainContext.getIndex(bridgeDomainName, mappingContext);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java
new file mode 100644
index 000000000..f57601af0
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapRequestItrRlocs;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer implements
+ WriterCustomizer<ItrRemoteLocatorSet>, ByteDataTranslator, JvppReplyConsumer {
+
+ public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
+ super(futureJVppCore);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id,
+ @Nonnull final ItrRemoteLocatorSet dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ try {
+ addDelItrRemoteLocatorSet(true, dataAfter);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id,
+ @Nonnull final ItrRemoteLocatorSet dataBefore,
+ @Nonnull final ItrRemoteLocatorSet dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
+ new UnsupportedOperationException("Operation not supported"));
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id,
+ @Nonnull final ItrRemoteLocatorSet dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ try {
+ addDelItrRemoteLocatorSet(false, dataBefore);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+ }
+
+ private void addDelItrRemoteLocatorSet(final boolean add, @Nonnull final ItrRemoteLocatorSet data)
+ throws TimeoutException, VppBaseCallException {
+
+ LispAddDelMapRequestItrRlocs request = new LispAddDelMapRequestItrRlocs();
+ request.isAdd = booleanToByte(add);
+ request.locatorSetName = data.getRemoteLocatorSetName().getBytes(StandardCharsets.UTF_8);
+
+ getReply(getFutureJVpp().lispAddDelMapRequestItrRlocs(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
index b5256db06..e181b9a20 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
@@ -23,6 +23,7 @@ import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsD
import static java.nio.charset.StandardCharsets.UTF_8;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.trait.MappingProducer;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
@@ -34,9 +35,9 @@ import java.io.UnsupportedEncodingException;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMappingKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEid;
@@ -48,7 +49,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
*/
public class LocalMappingCustomizer extends FutureJVppCustomizer
implements ListWriterCustomizer<LocalMapping, LocalMappingKey>, ByteDataTranslator, EidTranslator,
- JvppReplyConsumer {
+ JvppReplyConsumer, MappingProducer {
private final EidMappingContext localMappingsContext;
@@ -64,9 +65,10 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer
checkNotNull(dataAfter.getEid(), "Eid is null");
checkNotNull(dataAfter.getLocatorSet(), "Locator set is null");
checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+ checkAllowedCombination(id, dataAfter);
//checks whether value with specified mapping-id does not exist in mapping allready
- MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
+ final MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
checkState(!localMappingsContext
.containsEid(mappingId, writeContext.getMappingContext()),
"Local mapping with id %s already defined", id);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
index ed30623d8..32d0fd3a4 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
@@ -39,6 +39,8 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
public class PitrCfgCustomizer extends FutureJVppCustomizer
implements WriterCustomizer<PitrCfg>, JvppReplyConsumer, ByteDataTranslator {
+ private static final String DEFAULT_LOCATOR_SET_NAME = "N/A";
+
public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
super(futureJvpp);
}
@@ -85,6 +87,13 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer
private void addDelPitrSetLocatorSetAndReply(boolean add, PitrCfg data)
throws VppBaseCallException, TimeoutException {
+ if (DEFAULT_LOCATOR_SET_NAME.equals(data.getLocatorSet())) {
+ // ignores attempts to write default locator set
+ // therefore even while its loaded to config data of honeycomb while starting
+ // you can still enable/disable Lisp without having to define N/A as default pitr-set
+ return;
+ }
+
LispPitrSetLocatorSet request = new LispPitrSetLocatorSet();
request.isAdd = booleanToByte(add);
request.lsName = data.getLocatorSet().getBytes(UTF_8);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
index 01c8548d5..9f51977ab 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
@@ -25,6 +25,7 @@ import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.Locat
import com.google.common.base.Preconditions;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.trait.MappingProducer;
import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.vpp.util.AddressTranslator;
@@ -43,14 +44,14 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.LocatorList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.NegativeMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.PositiveMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.LocatorList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.NegativeMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.PositiveMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.LispAddDelRemoteMapping;
@@ -62,7 +63,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
*/
public class RemoteMappingCustomizer extends FutureJVppCustomizer
implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey>, EidTranslator,
- AddressTranslator, JvppReplyConsumer {
+ AddressTranslator, JvppReplyConsumer, MappingProducer {
private final EidMappingContext remoteMappingContext;
@@ -78,6 +79,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
checkNotNull(dataAfter, "Mapping is null");
checkNotNull(dataAfter.getEid(), "Eid is null");
checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+ checkAllowedCombination(id, dataAfter);
//checks whether mapping not already contains such key
MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
@@ -167,7 +169,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
Preconditions.checkArgument(NEGATIVE.equals(resolveType(locatorList)),
"Action can be extracted only from Negative Mapping");
- return ((NegativeMapping) locatorList).getMapReplyAction();
+ return ((NegativeMapping) locatorList).getMapReply().getMapReplyAction();
}
private static Rlocs extractRemoteLocators(LocatorList locatorList) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
index 7ad8f24c0..92a1564c0 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
@@ -16,30 +16,28 @@
package io.fd.honeycomb.lisp.translate.write;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import com.google.common.base.Optional;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
-import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.util.RWUtils;
+
import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.TimeoutException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMap;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Customizer for {@code TableId}
+ * This customizer serves only as a check if user is not trying to define VniTable <br>
+ * without mapping to vrf/bd
*/
-public class VniTableCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<VniTable, VniTableKey>, ByteDataTranslator, JvppReplyConsumer {
+public class VniTableCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
@@ -50,19 +48,7 @@ public class VniTableCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataAfter, WriteContext writeContext)
throws WriteFailedException {
-
- checkNotNull(dataAfter.getTableId(), "VRF cannot be null");
- checkNotNull(dataAfter.getVirtualNetworkIdentifier(), "VNI cannot be null");
-
- LOG.debug("Writing {}", id);
-
- try {
- addDelMap(true, dataAfter.getVirtualNetworkIdentifier().intValue(), dataAfter.getTableId().intValue());
- } catch (TimeoutException | VppBaseCallException e) {
- throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
- }
-
- LOG.debug("Write of {} successful", id);
+ checkAtLeastOnChildExists(id, writeContext, false);
}
@Override
@@ -74,29 +60,24 @@ public class VniTableCustomizer extends FutureJVppCustomizer
@Override
public void deleteCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataBefore, WriteContext writeContext)
throws WriteFailedException {
- checkNotNull(dataBefore.getTableId(), "VRF cannot be null");
- checkNotNull(dataBefore.getVirtualNetworkIdentifier(), "VNI cannot be null");
-
- LOG.debug("Removing {}", id);
-
- try {
- addDelMap(false, dataBefore.getVirtualNetworkIdentifier().intValue(), dataBefore.getTableId().intValue());
- } catch (TimeoutException | VppBaseCallException e) {
- throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
- }
-
- LOG.debug("Remove of {} successful", id);
+ checkAtLeastOnChildExists(id, writeContext, true);
}
- private void addDelMap(boolean isAdd, int vni, int vrf) throws TimeoutException, VppBaseCallException {
+ private void checkAtLeastOnChildExists(final InstanceIdentifier<VniTable> id, final WriteContext writeContext,
+ final boolean before) {
- LispEidTableAddDelMap request = new LispEidTableAddDelMap();
+ Optional<VniTable> optData;
+ final InstanceIdentifier<VniTable> trimmedId = RWUtils.cutId(id, InstanceIdentifier.create(VniTable.class));
+ if (before) {
+ optData = writeContext.readBefore(trimmedId);
+ } else {
+ optData = writeContext.readAfter(trimmedId);
+ }
- request.isAdd = booleanToByte(isAdd);
- request.vni = vni;
- request.dpTable = vrf;
- request.isL2 = 0;
+ checkState(optData.isPresent(), "Illegal after-write state");
- getReply(getFutureJVpp().lispEidTableAddDelMap(request).toCompletableFuture());
+ final VniTable dataAfter = optData.get();
+ checkState(dataAfter.getVrfSubtable() != null || dataAfter.getBridgeDomainSubtable() != null,
+ "At least one of VrfSubtable/BridgeDomainSubtable must be defined");
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VrfSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VrfSubtableCustomizer.java
new file mode 100644
index 000000000..a48ec6e22
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VrfSubtableCustomizer.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import io.fd.honeycomb.lisp.translate.write.trait.SubtableWriter;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VrfSubtableCustomizer extends FutureJVppCustomizer
+ implements WriterCustomizer<VrfSubtable>, SubtableWriter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VrfSubtableCustomizer.class);
+
+ public VrfSubtableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
+ @Nonnull final VrfSubtable dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ LOG.debug("Writing Id[{}]/Data[{}]", id, dataAfter);
+
+ try {
+ addDelSubtableMapping(getFutureJVpp(), true, extractVni(id), dataAfter.getTableId().intValue(), false, LOG);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ LOG.debug("{} successfully written", id);
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
+ @Nonnull final VrfSubtable dataBefore, @Nonnull final VrfSubtable dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
+ @Nonnull final VrfSubtable dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ LOG.debug("Removing Id[{}]/Data[{}]", id, dataBefore);
+
+ try {
+ addDelSubtableMapping(getFutureJVpp(), false, extractVni(id), dataBefore.getTableId().intValue(), false,
+ LOG);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+
+ LOG.debug("{} successfully removed", id);
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java
index aa839ba49..4021cc70c 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java
@@ -17,6 +17,7 @@
package io.fd.honeycomb.lisp.translate.write.factory;
+import static com.google.common.base.Preconditions.checkNotNull;
import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
@@ -31,11 +32,12 @@ import io.fd.honeycomb.translate.impl.write.GenericWriter;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
@@ -43,26 +45,32 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
*/
public final class LispWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+ private final NamingContext bridgeDomainContext;
+
@Inject
public LispWriterFactory(final FutureJVppCore vppApi,
@Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
@Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
+ @Named("bridge-domain-context") final NamingContext bridgeDomainContext,
@Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
@Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext) {
super(InstanceIdentifier.create(Lisp.class), vppApi, interfaceContext, locatorSetContext, localMappingContext,
remoteMappingContext);
+ this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
}
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
registry.add(new GenericWriter<>(lispInstanceIdentifier, new LispCustomizer(vppApi)));
- VniTableWriterFactory.newInstance(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext)
+ VniTableWriterFactory.newInstance(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext,
+ bridgeDomainContext)
.init(registry);
LocatorSetsWriterFactory.newInstance(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext)
.init(registry);
MapResolversWriterFactory.newInstance(lispInstanceIdentifier, vppApi).init(registry);
- registry.add(new GenericWriter<>(lispInstanceIdentifier.child(PitrCfg.class), new PitrCfgCustomizer(vppApi)));
+ registry.add(new GenericWriter<>(lispInstanceIdentifier.child(LispFeatureData.class).child(PitrCfg.class),
+ new PitrCfgCustomizer(vppApi)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
index d2f70dfda..4ebae0c0f 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
@@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
@@ -54,7 +55,7 @@ final class LocatorSetsWriterFactory extends AbstractLispWriterFactoryBase imple
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
InstanceIdentifier<LocatorSet> locatorSetId =
- lispInstanceIdentifier.child(LocatorSets.class).child(LocatorSet.class);
+ lispInstanceIdentifier.child(LispFeatureData.class).child(LocatorSets.class).child(LocatorSet.class);
registry.add(new GenericListWriter<>(locatorSetId, new LocatorSetCustomizer(vppApi, locatorSetContext)));
registry.add(new GenericListWriter<>(locatorSetId.child(Interface.class),
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
index 6bd251d5b..a4250fb2d 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
@@ -23,6 +23,7 @@ import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -47,7 +48,8 @@ final class MapResolversWriterFactory extends AbstractLispWriterFactoryBase impl
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
- registry.add(new GenericListWriter<>(lispInstanceIdentifier.child(MapResolvers.class).child(MapResolver.class),
+ registry.add(new GenericListWriter<>(
+ lispInstanceIdentifier.child(LispFeatureData.class).child(MapResolvers.class).child(MapResolver.class),
new MapResolverCustomizer(vppApi)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
index 5fc29845a..4d43b77df 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
@@ -16,31 +16,41 @@
package io.fd.honeycomb.lisp.translate.write.factory;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableSet;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.write.AdjacencyCustomizer;
+import io.fd.honeycomb.lisp.translate.write.BridgeDomainSubtableCustomizer;
import io.fd.honeycomb.lisp.translate.write.LocalMappingCustomizer;
import io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer;
import io.fd.honeycomb.lisp.translate.write.VniTableCustomizer;
+import io.fd.honeycomb.lisp.translate.write.VrfSubtableCustomizer;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.impl.write.GenericWriter;
+import io.fd.honeycomb.translate.vpp.util.NamingContext;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
@@ -48,47 +58,91 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
*/
final class VniTableWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+ private final NamingContext bridgeDomainContext;
+
private VniTableWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
final FutureJVppCore vppApi,
final EidMappingContext localMappingContext,
- final EidMappingContext remoteMappingContext) {
+ final EidMappingContext remoteMappingContext,
+ final NamingContext bridgeDomainContext) {
super(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
+ this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
}
public static VniTableWriterFactory newInstance(
@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
@Nonnull final FutureJVppCore vppApi,
@Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext) {
- return new VniTableWriterFactory(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
+ @Nonnull final EidMappingContext remoteMappingContext,
+ @Nonnull final NamingContext bridgeDomainContext) {
+ return new VniTableWriterFactory(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext,
+ bridgeDomainContext);
}
@Override
public void init(final ModifiableWriterRegistryBuilder registry) {
final InstanceIdentifier<VniTable> vniTableId =
- lispInstanceIdentifier.child(EidTable.class).child(VniTable.class);
+ lispInstanceIdentifier.child(LispFeatureData.class).child(EidTable.class).child(VniTable.class);
+
+ final InstanceIdentifier<VrfSubtable> vrfSubtableId = vniTableId.child(VrfSubtable.class);
+ final InstanceIdentifier<BridgeDomainSubtable> bridgeDomainSubtableId =
+ vniTableId.child(BridgeDomainSubtable.class);
registry.add(new GenericListWriter<>(vniTableId, new VniTableCustomizer(vppApi)));
+ registry.add(new GenericWriter<>(vrfSubtableId, new VrfSubtableCustomizer(vppApi)));
+ registry.add(new GenericWriter<>(bridgeDomainSubtableId,
+ new BridgeDomainSubtableCustomizer(vppApi, bridgeDomainContext)));
+ //VniTable - > VrfSubtable -> LocalMappings - > LocalMapping
final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid.class)),
- new GenericListWriter<>(vniTableId.child(LocalMappings.class).child(LocalMapping.class),
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
+ new GenericListWriter<>(
+ vrfSubtableId.child(LocalMappings.class).child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, localMappingContext)));
+ //VniTable - > BridgeDomainSubtable -> LocalMappings - > LocalMapping
+ registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
+ new GenericListWriter<>(bridgeDomainSubtableId.child(LocalMappings.class)
+ .child(LocalMapping.class),
new LocalMappingCustomizer(vppApi, localMappingContext)));
+ //VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping
final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid.class),
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class)),
+ new GenericListWriter<>(
+ vrfSubtableId.child(RemoteMappings.class).child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+ //VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping
+ registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
remoteMappingSubtreeId.child(Rlocs.class),
- remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class)),
- new GenericListWriter<>(vniTableId.child(RemoteMappings.class).child(RemoteMapping.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class)),
+ new GenericListWriter<>(bridgeDomainSubtableId.child(RemoteMappings.class)
+ .child(RemoteMapping.class),
new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+ //VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
registry.subtreeAdd(ImmutableSet.of(adjacencySubtreeId
.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListWriter<>(vniTableId.child(Adjacencies.class).child(Adjacency.class),
- new AdjacencyCustomizer(vppApi)));
+ new GenericListWriter<>(
+ vrfSubtableId.child(RemoteMappings.class).child(RemoteMapping.class)
+ .child(Adjacencies.class).child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext)));
+ //VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
+ registry.subtreeAdd(ImmutableSet.of(adjacencySubtreeId
+ .child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
+ new GenericListWriter<>(
+ bridgeDomainSubtableId.child(RemoteMappings.class)
+ .child(RemoteMapping.class)
+ .child(Adjacencies.class).child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/trait/SubtableWriter.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/trait/SubtableWriter.java
new file mode 100644
index 000000000..d7f46ad9b
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/trait/SubtableWriter.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.trait;
+
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMap;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+
+/**
+ * Trait providing logic for writing subtables
+ */
+public interface SubtableWriter extends ByteDataTranslator, JvppReplyConsumer {
+ int DEFAULT_VNI = 0;
+
+ /**
+ * Writes mapping from {@link VniTable}
+ * to {@link VrfSubtable} or
+ * {@link BridgeDomainSubtable}
+ *
+ * @param addDel true if add,delete otherwise
+ * @param vni {@link VniTable} ID
+ * @param tableId if <b>isL2</b> is true, than bridge domain subtable id,else vrf subtable id
+ * @param isL2 indicates whether (false) writing to L3 vrfSubtrable of (true) L2 bridgeDomainSubtrable
+ */
+ default void addDelSubtableMapping(@Nonnull final FutureJVppCore vppApi, final boolean addDel, final int vni,
+ final int tableId,
+ final boolean isL2,
+ final Logger logger) throws TimeoutException, VppBaseCallException {
+
+ if (vni == DEFAULT_VNI) {
+ // attempt to write subtable with default vni mapping(it does'nt make sense and it should'nt be possible)
+ // also allows to enable lisp without defining default mapping in request
+ logger.info("An attempt to write subtable[id = {}] with default vni {} was detected, ignoring write",
+ tableId, DEFAULT_VNI);
+ return;
+ }
+
+ checkNotNull(vppApi, "VPP Api refference cannot be null");
+
+ LispEidTableAddDelMap request = new LispEidTableAddDelMap();
+
+ request.isAdd = booleanToByte(addDel);
+ request.vni = vni;
+ request.dpTable = tableId;
+ request.isL2 = booleanToByte(isL2);
+
+ getReply(vppApi.lispEidTableAddDelMap(request).toCompletableFuture());
+ }
+
+ default int extractVni(@Nonnull final InstanceIdentifier<? extends ChildOf<VniTable>> id) {
+ return checkNotNull(
+ checkNotNull(id, "Identifier cannot be null").firstKeyOf(VniTable.class),
+ "Parent VNI id not defined").getVirtualNetworkIdentifier().intValue();
+ }
+}