summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java25
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java27
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java26
3 files changed, 40 insertions, 38 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
index 92eb396a8..4042dfac8 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
@@ -16,13 +16,13 @@
package io.fd.honeycomb.translate.v3po.vpp;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
-
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -46,7 +46,8 @@ import org.slf4j.LoggerFactory;
* VPP.<br> Equivalent of invoking {@code vppctl set bridge-domain arp term} command.
*/
public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<ArpTerminationTableEntry, ArpTerminationTableEntryKey> {
+ implements ListWriterCustomizer<ArpTerminationTableEntry, ArpTerminationTableEntryKey>, ByteDataTranslator,
+ AddressTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ArpTerminationTableEntryCustomizer.class);
@@ -62,7 +63,7 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Creating ARP termination table entry: {} {}", id, dataAfter);
bdIpMacAddDel(id, dataAfter, writeContext, true);
@@ -79,14 +80,14 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
@Nonnull final ArpTerminationTableEntry dataAfter,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
throw new UnsupportedOperationException(
- "ARP termination table entry update is not supported. It has to be deleted and then created.");
+ "ARP termination table entry update is not supported. It has to be deleted and then created.");
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Deleting ARP termination table entry entry: {} {}", id, dataBefore);
bdIpMacAddDel(id, dataBefore, writeContext, false);
@@ -100,23 +101,23 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
private void bdIpMacAddDel(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry entry,
final WriteContext writeContext, boolean isAdd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext());
final BdIpMacAddDel request = createRequest(entry, bdId, isAdd);
LOG.debug("Sending l2FibAddDel request: {}", request);
final CompletionStage<BdIpMacAddDelReply> replyCompletionStage =
- getFutureJVpp().bdIpMacAddDel(request);
+ getFutureJVpp().bdIpMacAddDel(request);
- TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
}
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) {
final BdIpMacAddDel request = new BdIpMacAddDel();
request.bdId = bdId;
request.isAdd = booleanToByte(isAdd);
- request.macAddress = TranslateUtils.parseMac(entry.getPhysAddress().getValue());
+ request.macAddress = parseMac(entry.getPhysAddress().getValue());
final IpAddress ipAddress = entry.getIpAddress();
if (ipAddress.getIpv6Address() != null) {
@@ -124,7 +125,7 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
throw new UnsupportedOperationException("IPv6 address for ARP termination table is not supported yet");
}
- request.ipAddress = TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address()));
+ request.ipAddress = ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address()));
return request;
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
index 83be3c62c..45d0e6460 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
@@ -18,13 +18,13 @@ package io.fd.honeycomb.translate.v3po.vpp;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -41,8 +41,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BridgeDomainCustomizer
- extends FutureJVppCustomizer
- implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> {
+ extends FutureJVppCustomizer
+ implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class);
@@ -51,14 +51,15 @@ public class BridgeDomainCustomizer
@GuardedBy("this")
private int bridgeDomainIndexCounter = 1;
- public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext bdContext) {
+ public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext bdContext) {
super(futureJVppCore);
this.bdContext = Preconditions.checkNotNull(bdContext, "bdContext should not be null");
}
private BridgeDomainAddDelReply addOrUpdateBridgeDomain(@Nonnull final InstanceIdentifier<BridgeDomain> id,
final int bdId, @Nonnull final BridgeDomain bd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final BridgeDomainAddDelReply reply;
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
@@ -69,7 +70,7 @@ public class BridgeDomainCustomizer
request.arpTerm = booleanToByte(bd.isArpTermination());
request.isAdd = ADD_OR_UPDATE_BD;
- reply = TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
+ reply = getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
return reply;
}
@@ -78,7 +79,7 @@ public class BridgeDomainCustomizer
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("writeCurrentAttributes: id={}, current={}, ctx={}", id, dataBefore, ctx);
final String bdName = dataBefore.getName();
@@ -113,7 +114,7 @@ public class BridgeDomainCustomizer
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx);
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
int bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
@@ -122,7 +123,7 @@ public class BridgeDomainCustomizer
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
- TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
+ getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId);
} catch (VppBaseCallException e) {
LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId);
@@ -134,13 +135,13 @@ public class BridgeDomainCustomizer
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore, @Nonnull final BridgeDomain dataAfter,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("updateCurrentAttributes: id={}, dataBefore={}, dataAfter={}, ctx={}", id, dataBefore, dataAfter,
- ctx);
+ ctx);
final String bdName = checkNotNull(dataAfter.getName());
checkArgument(bdName.equals(dataBefore.getName()),
- "BridgeDomain name changed. It should be deleted and then created.");
+ "BridgeDomain name changed. It should be deleted and then created.");
try {
addOrUpdateBridgeDomain(id, bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
index d72d95493..29b4b939f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
@@ -16,15 +16,14 @@
package io.fd.honeycomb.translate.v3po.vpp;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.parseMac;
-
import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.v3po.util.MacTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -47,7 +46,8 @@ import org.slf4j.LoggerFactory;
* VPP.<br> Equivalent of invoking {@code vppctl l2fib add/del} command.
*/
public class L2FibEntryCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey> {
+ implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey>, ByteDataTranslator, MacTranslator,
+ JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class);
@@ -64,7 +64,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntry dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter);
l2FibAddDel(id, dataAfter, writeContext, true);
@@ -80,13 +80,13 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
@Nonnull final L2FibEntry dataBefore, @Nonnull final L2FibEntry dataAfter,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
throw new UnsupportedOperationException(
- "L2 FIB entry update is not supported. It has to be deleted and then created.");
+ "L2 FIB entry update is not supported. It has to be deleted and then created.");
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntry dataBefore, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore);
l2FibAddDel(id, dataBefore, writeContext, false);
@@ -99,7 +99,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
private void l2FibAddDel(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry entry,
final WriteContext writeContext, boolean isAdd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext());
@@ -112,9 +112,9 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
final L2FibAddDel l2FibRequest = createL2FibRequest(entry, bdId, swIfIndex, isAdd);
LOG.debug("Sending l2FibAddDel request: {}", l2FibRequest);
final CompletionStage<L2FibAddDelReply> l2FibAddDelReplyCompletionStage =
- getFutureJVpp().l2FibAddDel(l2FibRequest);
+ getFutureJVpp().l2FibAddDel(l2FibRequest);
- TranslateUtils.getReplyForWrite(l2FibAddDelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(l2FibAddDelReplyCompletionStage.toCompletableFuture(), id);
}
private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) {
@@ -132,9 +132,9 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
// mac address is string of the form: 11:22:33:44:55:66
// but VPP expects long value in the format 11:22:33:44:55:66:XX:XX
- private static long macToLong(final String macAddress) {
+ private long macToLong(final String macAddress) {
final byte[] mac = parseMac(macAddress);
return Longs.fromBytes(mac[0], mac[1], mac[2], mac[3],
- mac[4], mac[5], (byte) 0, (byte) 0);
+ mac[4], mac[5], (byte) 0, (byte) 0);
}
}