summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write')
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java101
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java120
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java95
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java137
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java161
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java97
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java94
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java231
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java100
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java94
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java68
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java63
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java53
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java94
14 files changed, 1508 insertions, 0 deletions
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
new file mode 100755
index 000000000..d321510be
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
@@ -0,0 +1,101 @@
+/*
+ * 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.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+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.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 org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelAdjacency;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Adjacency, AdjacencyKey> {
+
+ public AdjacencyCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ try {
+ addDelAdjacency(true, id, dataAfter);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataBefore, @Nonnull final Adjacency dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ addDelAdjacency(false, id, dataBefore);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelAdjacency(boolean add, final InstanceIdentifier<Adjacency> id, Adjacency data)
+ 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 = EidConverter.getEidType(data.getLocalEid());
+ EidType remoteEidType = EidConverter.getEidType(data.getRemoteEid());
+
+ checkArgument(localEidType ==
+ remoteEidType, "Local[%s] and Remote[%s] eid types must be the same", localEidType, remoteEidType);
+
+ LispAddDelAdjacency request = new LispAddDelAdjacency();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.seid = EidConverter.getEidAsByteArray(data.getLocalEid());
+ request.seidLen = (byte) request.seid.length;
+ request.deid = EidConverter.getEidAsByteArray(data.getRemoteEid());
+ request.seidLen = (byte) request.deid.length;
+ request.eidType = (byte) localEidType.getValue();
+ request.vni = vni;
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelAdjacency(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
new file mode 100755
index 000000000..c26bbf377
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
@@ -0,0 +1,120 @@
+/*
+ * 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 static java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocator;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for updating {@link Interface}
+ *
+ * @see Interface
+ */
+public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Interface, InterfaceKey> {
+
+ private final NamingContext interfaceContext;
+
+ public InterfaceCustomizer(@Nonnull FutureJVppCore futureJvpp, @Nonnull NamingContext interfaceContext) {
+ super(futureJvpp);
+ this.interfaceContext = checkNotNull(interfaceContext, "Naming context is null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter, "Interface is null");
+ checkNotNull(dataAfter.getPriority(), "Priority is null");
+ checkNotNull(dataAfter.getWeight(), "Weight is null");
+ checkState(id.firstKeyOf(Interface.class) != null, "Parent interface not found");
+ checkState(id.firstKeyOf(LocatorSet.class) != null, "Parent locator set not found");
+
+ String interfaceName = id.firstKeyOf(Interface.class).getInterfaceRef();
+ String locatorSetName = id.firstKeyOf(LocatorSet.class).getName();
+
+ checkState(interfaceContext.containsIndex(interfaceName, writeContext.getMappingContext()),
+ "No mapping stored for interface %s", interfaceName);
+
+ try {
+ addDelInterfaceAndReply(true, dataAfter,
+ interfaceContext.getIndex(interfaceName, writeContext.getMappingContext()), locatorSetName);
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataBefore, Interface dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Interface is null");
+ checkNotNull(dataBefore.getPriority(), "Priority is null");
+ checkNotNull(dataBefore.getWeight(), "Weight is null");
+ checkState(id.firstKeyOf(Interface.class) != null, "Parent interface not found");
+ checkState(id.firstKeyOf(LocatorSet.class) != null, "Parent locator set not found");
+
+ String interfaceName = id.firstKeyOf(Interface.class).getInterfaceRef();
+ String locatorSetName = id.firstKeyOf(LocatorSet.class).getName();
+
+ checkState(interfaceContext.containsIndex(interfaceName, writeContext.getMappingContext()),
+ "No mapping stored for interface %s", interfaceName);
+ try {
+ addDelInterfaceAndReply(false, dataBefore,
+ interfaceContext.getIndex(interfaceName, writeContext.getMappingContext()), locatorSetName);
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+ }
+
+ private void addDelInterfaceAndReply(boolean add, Interface data, int interfaceIndex, String locatorSetName)
+ throws VppBaseCallException, TimeoutException, UnsupportedEncodingException {
+ LispAddDelLocator request = new LispAddDelLocator();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.priority = data.getPriority().byteValue();
+ request.weight = data.getWeight().byteValue();
+ request.swIfIndex = interfaceIndex;
+ request.locatorSetName = locatorSetName.getBytes(UTF_8);
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelLocator(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
new file mode 100755
index 000000000..05c162d0c
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
@@ -0,0 +1,95 @@
+/*
+ * 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 com.google.common.base.Preconditions;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispEnableDisable;
+import org.openvpp.jvpp.core.dto.LispEnableDisableReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Handles updates of {@link Lisp} node. Takes care of LISP enable/disable
+ */
+public class LispCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Lisp> {
+
+ public LispCustomizer(final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ Preconditions.checkNotNull(dataAfter, "Lisp is null");
+
+ try {
+ enableDisableLisp(dataAfter.isEnable());
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataBefore,
+ @Nonnull final Lisp dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ Preconditions.checkNotNull(dataAfter, "Lisp is null");
+
+ try {
+ enableDisableLisp(dataAfter.isEnable());
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ Preconditions.checkNotNull(dataBefore, "Lisp is null");
+
+ try {
+ enableDisableLisp(false);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ }
+
+
+ private void enableDisableLisp(final boolean enable) throws VppBaseCallException, TimeoutException {
+ final CompletionStage<LispEnableDisableReply> lispEnableDisableReplyCompletionStage =
+ getFutureJVpp().lispEnableDisable(getRequest(enable));
+ TranslateUtils.getReply(lispEnableDisableReplyCompletionStage.toCompletableFuture());
+ }
+
+ private LispEnableDisable getRequest(final boolean enable) {
+ final LispEnableDisable lispEnableDisable = new LispEnableDisable();
+ lispEnableDisable.isEn = TranslateUtils.booleanToByte(enable);
+ return lispEnableDisable;
+ }
+}
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
new file mode 100755
index 000000000..eec4b8269
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
@@ -0,0 +1,137 @@
+/*
+ * 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 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 java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+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.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 org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocalEid;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer that writes changes for {@link LocalMapping}
+ */
+public class LocalMappingCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<LocalMapping, LocalMappingKey> {
+
+ private final EidMappingContext localMappingsContext;
+
+ public LocalMappingCustomizer(@Nonnull FutureJVppCore futureJvpp, @Nonnull EidMappingContext localMappingsContext) {
+ super(futureJvpp);
+ this.localMappingsContext = checkNotNull(localMappingsContext, "No local mappings context defined");
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "Mapping is null");
+ checkNotNull(dataAfter.getEid(), "Eid is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether value with specified mapping-id does not exist in mapping allready
+ MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
+ checkState(!localMappingsContext
+ .containsEid(mappingId, writeContext.getMappingContext()),
+ "Local mapping with id %s already defined", id);
+
+
+ try {
+ addDelMappingAndReply(true, dataAfter,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //adds mapping for id and eid
+ localMappingsContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataBefore,
+ LocalMapping dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Mapping is null");
+ checkNotNull(dataBefore.getEid(), "Eid is null");
+ checkNotNull(dataBefore.getLocatorSet(), "LocatorSet is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether value with specified mapping-id does exist in mapping,so there is something to delete
+ MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
+ checkState(localMappingsContext
+ .containsEid(mappingId, writeContext.getMappingContext()),
+ "Local mapping with id %s not present in mapping", id);
+
+ try {
+ addDelMappingAndReply(false, dataBefore,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //removes value also from mapping
+ localMappingsContext.removeEid(mappingId, writeContext.getMappingContext());
+ }
+
+ private void addDelMappingAndReply(boolean add, LocalMapping data, int vni) throws VppBaseCallException,
+ TimeoutException, UnsupportedEncodingException {
+
+ LispAddDelLocalEid request = new LispAddDelLocalEid();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.eid = EidConverter.getEidAsByteArray(data.getEid());
+ request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
+ request.locatorSetName = data.getLocatorSet().getBytes(UTF_8);
+ request.vni = vni;
+
+ //default prefixes
+ if (request.eidType == IPV4.getValue()) {
+ request.prefixLen = 32;
+ } else if (request.eidType == IPV6.getValue()) {
+ request.prefixLen = (byte) 128;
+ }
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelLocalEid(request).toCompletableFuture());
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
new file mode 100755
index 000000000..c2db3b845
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
@@ -0,0 +1,161 @@
+/*
+ * 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 io.fd.honeycomb.translate.v3po.util.TranslateUtils.getReply;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.check.LocatorSetsDumpCheck;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.LocatorSetsDumpExecutor;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+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.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.LocatorSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocatorSet;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@link LocatorSet} entity
+ *
+ * @see LocatorSet
+ */
+public class LocatorSetCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<LocatorSet, LocatorSetKey> {
+
+ private final NamingContext locatorSetContext;
+ private final DumpCacheManager<LispLocatorSetDetailsReplyDump, Void> dumpManager;
+
+ public LocatorSetCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final NamingContext locatorSetContext) {
+ super(futureJvpp);
+ this.locatorSetContext = checkNotNull(locatorSetContext, "Locator set context cannot be null");
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorSetDetailsReplyDump, Void>()
+ .withExecutor(new LocatorSetsDumpExecutor(futureJvpp))
+ .withNonEmptyPredicate(new LocatorSetsDumpCheck())
+ .build();
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+
+ checkNotNull(dataAfter, "LocatorSet is null");
+
+ final String locatorSetName = dataAfter.getName();
+ checkNotNull(locatorSetName, "LocatorSet name is null");
+
+ //TODO check and fill mapping when api returns index of created locator set
+ // checkState(!locatorSetContext.containsIndex(locatorSetName, writeContext.getMappingContext()),
+ // "Locator set with name %s allready defined", locatorSetName);
+
+ try {
+ addDelLocatorSetAndReply(true, dataAfter.getName());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //TODO - REMOVE FROM MASTER AFTER VPP-323
+ try {
+ locatorSetContext
+ .addName(getLocatorSetIndex(locatorSetName, writeContext.getModificationCache()), locatorSetName,
+ writeContext.getMappingContext());
+ } catch (DumpExecutionFailedException e) {
+ throw new WriteFailedException(id,
+ new IllegalStateException("Unable to create mapping for locator set " + locatorSetName, e));
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataBefore,
+ @Nonnull LocatorSet dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataBefore,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+
+ checkNotNull(dataBefore, "LocatorSet is null");
+
+ final String locatorSetName = dataBefore.getName();
+ checkNotNull(locatorSetName, "LocatorSet name is null");
+
+ try {
+ addDelLocatorSetAndReply(false, dataBefore.getName());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //removes mapping after successful delete
+ locatorSetContext.removeName(locatorSetName, writeContext.getMappingContext());
+ }
+
+ private void addDelLocatorSetAndReply(boolean add, String name)
+ throws VppBaseCallException, TimeoutException, UnsupportedEncodingException {
+
+ LispAddDelLocatorSet addDelSet = new LispAddDelLocatorSet();
+
+ addDelSet.isAdd = TranslateUtils.booleanToByte(add);
+ addDelSet.locatorSetName = name.getBytes(UTF_8);
+
+
+ getReply(getFutureJVpp().lispAddDelLocatorSet(addDelSet).toCompletableFuture());
+ }
+
+ //TODO - REMOVE FROM MASTER AFTER VPP-323
+ // total hack
+ public int getLocatorSetIndex(final String name, final ModificationCache cache)
+ throws DumpExecutionFailedException {
+
+ Optional<LispLocatorSetDetailsReplyDump> reply = dumpManager
+ .getDump(io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer.LOCATOR_SETS_CACHE_ID, cache,
+ EntityDumpExecutor.NO_PARAMS);
+
+ if (reply.isPresent()) {
+ return reply.get().lispLocatorSetDetails.stream()
+ .filter(a -> name.equals(TranslateUtils.toString(a.locatorSetName)))
+ .collect(RWUtils.singleItemCollector())
+ .locatorSetIndex;
+ } else {
+ throw new IllegalStateException("Unable to find index of locator set " + name);
+ }
+ }
+
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
new file mode 100755
index 000000000..02c9f4255
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.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 io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+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.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Handles updates of {@link MapResolver} list
+ */
+public class MapResolverCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<MapResolver, MapResolverKey> {
+
+ public MapResolverCustomizer(final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter, "Data is null");
+ checkNotNull(dataAfter.getIpAddress(), "Address is null");
+
+ try {
+ addDelMapResolverAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataBefore, @Nonnull final MapResolver dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataBefore, "Data is null");
+ checkNotNull(dataBefore.getIpAddress(), "Address is null");
+
+ try {
+ addDelMapResolverAndReply(false, dataBefore);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelMapResolverAndReply(boolean add, MapResolver data) throws VppBaseCallException,
+ TimeoutException {
+
+ LispAddDelMapResolver request = new LispAddDelMapResolver();
+ request.isAdd = TranslateUtils.booleanToByte(add);
+
+
+ boolean ipv6 = TranslateUtils.isIpv6(data.getIpAddress());
+
+ request.isIpv6 = TranslateUtils.booleanToByte(ipv6);
+ request.ipAddress = TranslateUtils.ipAddressToArray(ipv6, data.getIpAddress());
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelMapResolver(request).toCompletableFuture());
+ }
+}
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
new file mode 100755
index 000000000..ab3be2add
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
@@ -0,0 +1,94 @@
+/*
+ * 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 java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+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 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 org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSet;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@code PitrCfg}
+ */
+public class PitrCfgCustomizer extends FutureJVppCustomizer implements WriterCustomizer<PitrCfg> {
+
+ public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ checkNotNull(dataAfter, "PitrCfg is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, PitrCfg dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "PitrCfg is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, WriteContext writeContext)
+ throws WriteFailedException {
+ checkNotNull(dataBefore, "PitrCfg is null");
+ checkNotNull(dataBefore.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(false, dataBefore);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelPitrSetLocatorSetAndReply(boolean add, PitrCfg data)
+ throws VppBaseCallException, TimeoutException {
+
+ LispPitrSetLocatorSet request = new LispPitrSetLocatorSet();
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.lsName = data.getLocatorSet().getBytes(UTF_8);
+
+ TranslateUtils.getReply(getFutureJVpp().lispPitrSetLocatorSet(request).toCompletableFuture());
+ }
+
+}
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
new file mode 100755
index 000000000..e8e37969e
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
@@ -0,0 +1,231 @@
+/*
+ * 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.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.LocatorListType.NEGATIVE;
+import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.LocatorListType.POSITIVE;
+
+import com.google.common.base.Preconditions;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+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.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.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 org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@link RemoteMapping}
+ */
+public class RemoteMappingCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey> {
+
+ private final EidMappingContext remoteMappingContext;
+
+ public RemoteMappingCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ super(futureJvpp);
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "Mapping is null");
+ checkNotNull(dataAfter.getEid(), "Eid is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether mapping not already contains such key
+ MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
+ checkState(!remoteMappingContext.containsEid(mappingId, writeContext.getMappingContext()),
+ "Mapping for id %s already defined", mappingId);
+
+ try {
+ addDelRemoteMappingAndReply(true, dataAfter,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | IOException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //after successfull adition adds mapping
+ remoteMappingContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataBefore,
+ RemoteMapping dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Mapping is null");
+ checkNotNull(dataBefore.getEid(), "Eid is null");
+
+ //checks whether mapping already contains such key
+ MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
+ checkState(remoteMappingContext.containsEid(mappingId, writeContext.getMappingContext()),
+ "Mapping for id %s is not existing,nothing to remove", mappingId);
+
+ try {
+ addDelRemoteMappingAndReply(false, dataBefore,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | IOException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //remote mapping after successfull remove of data
+ remoteMappingContext.removeEid(mappingId, writeContext.getMappingContext());
+ }
+
+ private void addDelRemoteMappingAndReply(boolean add, RemoteMapping data, int vni)
+ throws VppBaseCallException, TimeoutException, IOException {
+
+ LispAddDelRemoteMapping request = new LispAddDelRemoteMapping();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.vni = vni;
+ request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
+ request.eid = EidConverter.getEidAsByteArray(data.getEid());
+
+ //this is not length of eid array,but prefix length(bad naming by vpp)
+ request.eidLen = EidConverter.getPrefixLength(data.getEid());
+
+ if (LocatorListType.NEGATIVE
+ .equals(resolveType(data.getLocatorList()))) {
+ request.action = (byte) extractAction(data.getLocatorList()).getIntValue();
+ } else {
+ Rlocs rlocs = extractRemoteLocators(data.getLocatorList());
+
+ checkArgument(rlocs != null, "No remote locators set for Positive mapping");
+
+ request.rlocs = locatorsToBinaryData(rlocs.getLocator());
+ request.rlocNum = Integer.valueOf(rlocs.getLocator().size()).byteValue();
+ }
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelRemoteMapping(request).toCompletableFuture());
+ }
+
+ private static LocatorListType resolveType(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+
+ if (locatorList instanceof PositiveMapping) {
+ return POSITIVE;
+ } else {
+ return NEGATIVE;
+ }
+ }
+
+ private static MapReplyAction extractAction(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+ Preconditions.checkArgument(NEGATIVE.equals(resolveType(locatorList)),
+ "Action can be extracted only from Negative Mapping");
+
+ return ((NegativeMapping) locatorList).getMapReplyAction();
+ }
+
+ private static Rlocs extractRemoteLocators(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+ Preconditions.checkArgument(POSITIVE.equals(resolveType(locatorList)),
+ "RLocs can be extracted only from Positive Mapping");
+
+ return ((PositiveMapping) locatorList).getRlocs();
+ }
+
+ private static byte[] locatorsToBinaryData(List<Locator> locators) throws IOException {
+ checkNotNull(locators, "Cannot convert null list");
+
+ ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+
+ DataOutputStream out = new DataOutputStream(byteArrayOut);
+
+
+ for (Locator locator : locators) {
+ boolean isIpv4;
+ byte[] address;
+
+ //first byte says that its v4/v6
+ isIpv4 = !TranslateUtils.isIpv6(locator.getAddress());
+ out.writeByte(TranslateUtils.booleanToByte(isIpv4));
+
+ //then writes priority
+ out.write(locator.getPriority());
+
+ //and weight
+ out.write(locator.getWeight());
+
+ if (isIpv4) {
+ //vpp in this case needs address as 16 byte array,regardless if it is ivp4 or ipv6
+ address = Arrays.copyOf(
+ TranslateUtils
+ .ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(locator.getAddress().getIpv4Address())),
+ 16);
+
+ out.write(address);
+ } else {
+ out.write(TranslateUtils
+ .ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(locator.getAddress().getIpv6Address())));
+ }
+ }
+
+ return byteArrayOut.toByteArray();
+ }
+
+ public enum LocatorListType {
+
+ /**
+ * Represents locator list as negative mapping
+ */
+ NEGATIVE,
+
+ /**
+ * Represents locator list as positive mapping
+ */
+ POSITIVE
+ }
+
+}
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
new file mode 100755
index 000000000..ad1d41de9
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
@@ -0,0 +1,100 @@
+/*
+ * 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 io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+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 org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+import org.openvpp.jvpp.core.dto.LispEidTableAddDelMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Customizer for {@code TableId}
+ */
+public class VniTableCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
+
+ public VniTableCustomizer(FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @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);
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataBefore, VniTable dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @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);
+ }
+
+ private void addDelMap(boolean isAdd, int vni, int vrf) throws TimeoutException, VppBaseCallException {
+
+ LispEidTableAddDelMap request = new LispEidTableAddDelMap();
+
+ request.isAdd = TranslateUtils.booleanToByte(isAdd);
+ request.vni = vni;
+ request.dpTable = vrf;
+ request.isL2 = 0;
+
+ TranslateUtils.getReply(getFutureJVpp().lispEidTableAddDelMap(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
new file mode 100644
index 000000000..fed1cf64d
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
@@ -0,0 +1,94 @@
+/*
+ * 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.factory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Basic attributes for lisp writer factories
+ */
+abstract class AbstractLispWriterFactoryBase {
+
+ protected final InstanceIdentifier<Lisp> lispInstanceIdentifier;
+ protected final FutureJVppCore vppApi;
+ protected NamingContext interfaceContext;
+ protected NamingContext locatorSetContext;
+ protected EidMappingContext localMappingContext;
+ protected EidMappingContext remoteMappingContext;
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ NamingContext locatorSetContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.locatorSetContext = locatorSetContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ NamingContext locatorSetContext,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.locatorSetContext = locatorSetContext;
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+}
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
new file mode 100755
index 000000000..ec95afc5e
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.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.write.factory;
+
+
+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;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.write.LispCustomizer;
+import io.fd.honeycomb.lisp.translate.write.PitrCfgCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericWriter;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+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.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Initialize writers for {@link Lisp}
+ */
+public final class LispWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ @Inject
+ public LispWriterFactory(final FutureJVppCore vppApi,
+ @Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
+ @Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
+ @Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
+ @Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext) {
+ super(InstanceIdentifier.create(Lisp.class), vppApi, interfaceContext, locatorSetContext, localMappingContext,
+ remoteMappingContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ registry.add(new GenericWriter<>(lispInstanceIdentifier, new LispCustomizer(vppApi)));
+
+ VniTableWriterFactory.newInstance(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext)
+ .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)));
+ }
+}
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
new file mode 100755
index 000000000..2139eaf26
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
@@ -0,0 +1,63 @@
+/*
+ * 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.factory;
+
+import io.fd.honeycomb.lisp.translate.write.InterfaceCustomizer;
+import io.fd.honeycomb.lisp.translate.write.LocatorSetCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+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.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;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory producing writers for {@code LocatorSets}
+ */
+final class LocatorSetsWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private LocatorSetsWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi,
+ final NamingContext interfaceContext,
+ final NamingContext locatorSetContext) {
+ super(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
+ }
+
+ public static LocatorSetsWriterFactory newInstance(
+ @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext) {
+ return new LocatorSetsWriterFactory(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ InstanceIdentifier<LocatorSet> locatorSetId =
+ lispInstanceIdentifier.child(LocatorSets.class).child(LocatorSet.class);
+
+ registry.add(new GenericListWriter<>(locatorSetId, new LocatorSetCustomizer(vppApi, locatorSetContext)));
+ registry.add(new GenericListWriter<>(locatorSetId.child(Interface.class),
+ new InterfaceCustomizer(vppApi, interfaceContext)));
+ }
+}
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
new file mode 100755
index 000000000..00fa959d5
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
@@ -0,0 +1,53 @@
+/*
+ * 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.factory;
+
+
+import io.fd.honeycomb.lisp.translate.write.MapResolverCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+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.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;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory responsible for producing writers for {@code MapResolvers}
+ */
+final class MapResolversWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private MapResolversWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi) {
+ super(lispInstanceIdentifier, vppApi, null);
+ }
+
+ public static MapResolversWriterFactory newInstance(
+ @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi) {
+ return new MapResolversWriterFactory(lispInstanceIdentifier, vppApi);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ registry.add(new GenericListWriter<>(lispInstanceIdentifier.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
new file mode 100755
index 000000000..4a78fb819
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
@@ -0,0 +1,94 @@
+/*
+ * 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.factory;
+
+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.LocalMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.write.VniTableCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+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.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.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory for producing writers for {@code EidTable}
+ */
+final class VniTableWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private VniTableWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi,
+ final EidMappingContext localMappingContext,
+ final EidMappingContext remoteMappingContext) {
+ super(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
+ }
+
+ 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);
+ }
+
+ @Override
+ public void init(final ModifiableWriterRegistryBuilder registry) {
+ final InstanceIdentifier<VniTable> vniTableId =
+ lispInstanceIdentifier.child(EidTable.class).child(VniTable.class);
+
+ registry.add(new GenericListWriter<>(vniTableId, new VniTableCustomizer(vppApi)));
+
+
+ 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),
+ new LocalMappingCustomizer(vppApi, localMappingContext)));
+
+ 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),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class)),
+ new GenericListWriter<>(vniTableId.child(RemoteMappings.class).child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+
+ 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)));
+ }
+}