summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-05-17 09:10:39 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-05-23 09:24:12 +0000
commit799ee62f15dff07534beaf98a3ac551deffade38 (patch)
treea47c4696cf6ecff4fbb83c161c5d8e7e6b8af3c8 /v3po/v3po2vpp/src/main/java/io/fd/honeycomb
parentf19306a9263cb8dd8c10a4867633fbbe14db2e4c (diff)
HONEYCOMB-61: Add BA broker for context data tree
With broker, context data can be accessed in a transactional manner, same as config data + Renamed data-api concepts to not include DataTree + Renamed context related concepts to better distinguish between them + Now passing full ReadContext to read customizers + Naming context is backed by context data broker Change-Id: I0b2876dd74a31a9ced7d9b5145672868e12f8b82 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java18
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java29
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java9
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java17
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java20
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizer.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java9
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java21
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java6
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizer.java6
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java21
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java4
21 files changed, 136 insertions, 125 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
index e6ed62acf..eb6426241 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
@@ -57,7 +57,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
throws WriteFailedException {
try {
- setInterface(id, dataAfter);
+ setInterface(id, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of VppInterfaceAugment failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -72,7 +72,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
throws WriteFailedException.UpdateFailedException {
try {
- updateInterface(id, dataBefore, dataAfter);
+ updateInterface(id, dataBefore, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of VppInterfaceAugment failed", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -95,25 +95,25 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
}
- private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf)
+ private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf,
+ final WriteContext writeContext)
throws VppApiInvocationException, WriteFailedException {
LOG.debug("Setting interface: {} to: {}", id, swIf);
- setInterfaceAttributes(swIf, swIf.getName());
+ setInterfaceAttributes(swIf, swIf.getName(), writeContext);
}
- private void setInterfaceAttributes(final Interface swIf, final String swIfName)
+ private void setInterfaceAttributes(final Interface swIf, final String swIfName, final WriteContext writeContext)
throws VppApiInvocationException {
- setInterfaceFlags(swIfName, interfaceContext.getIndex(swIfName),
+ setInterfaceFlags(swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()),
swIf.isEnabled() ? (byte) 1 : (byte) 0);
}
private void updateInterface(final InstanceIdentifier<Interface> id,
final Interface dataBefore,
- final Interface dataAfter) throws VppApiInvocationException {
+ final Interface dataAfter, final WriteContext writeContext) throws VppApiInvocationException {
LOG.debug("Updating interface:{} to: {}", id, dataAfter);
-
- setInterfaceAttributes(dataAfter, dataAfter.getName());
+ setInterfaceAttributes(dataAfter, dataAfter.getName(), writeContext);
}
private void setInterfaceFlags(final String swIfName, final int swIfIndex, final byte enabled)
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
index fc43cdb7e..5aea5de2b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
@@ -69,9 +69,9 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
- final int swIfc = interfaceContext.getIndex(ifcName);
+ final int swIfc = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
try {
- setL2(id, swIfc, ifcName, dataAfter);
+ setL2(id, swIfc, ifcName, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Write of L2 failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -84,10 +84,10 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
- final int swIfc = interfaceContext.getIndex(ifcName);
+ final int swIfc = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
// TODO handle update properly (if possible)
try {
- setL2(id, swIfc, ifcName, dataAfter);
+ setL2(id, swIfc, ifcName, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of L2 failed", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -100,21 +100,22 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
// TODO implement delete (if possible)
}
- private void setL2(final InstanceIdentifier<L2> id, final int swIfIndex, final String ifcName, final L2 vppL2)
+ private void setL2(final InstanceIdentifier<L2> id, final int swIfIndex, final String ifcName, final L2 vppL2,
+ final WriteContext writeContext)
throws VppApiInvocationException, WriteFailedException {
LOG.debug("Setting L2 for interface: {}", ifcName);
// Nothing besides interconnection here
- setInterconnection(id, swIfIndex, ifcName, vppL2);
+ setInterconnection(id, swIfIndex, ifcName, vppL2, writeContext);
}
private void setInterconnection(final InstanceIdentifier<L2> id, final int swIfIndex, final String ifcName,
- final L2 vppL2)
+ final L2 vppL2, final WriteContext writeContext)
throws VppApiInvocationException, WriteFailedException {
Interconnection ic = vppL2.getInterconnection();
if (ic instanceof XconnectBased) {
- setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic);
+ setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic, writeContext);
} else if (ic instanceof BridgeBased) {
- setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic);
+ setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic, writeContext);
} else {
// FIXME how does choice extensibility work
// FIXME it is not even possible to create a dedicated customizer for Interconnection, since it's not a DataObject
@@ -125,7 +126,8 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
}
}
- private void setBridgeBasedL2(final int swIfIndex, final String ifcName, final BridgeBased bb)
+ private void setBridgeBasedL2(final int swIfIndex, final String ifcName, final BridgeBased bb,
+ final WriteContext writeContext)
throws VppApiInvocationException {
LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}",
@@ -133,7 +135,7 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
String bdName = bb.getBridgeDomain();
- int bdId = bridgeDomainContext.getIndex(bdName);
+ int bdId = bridgeDomainContext.getIndex(bdName, writeContext.getMappingContext());
checkArgument(bdId > 0, "Unable to set Interconnection for Interface: %s, bridge domain: %s does not exist",
ifcName, bdName);
@@ -168,14 +170,15 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
return swInterfaceSetL2Bridge;
}
- private void setXconnectBasedL2(final int swIfIndex, final String ifcName, final XconnectBased ic)
+ private void setXconnectBasedL2(final int swIfIndex, final String ifcName, final XconnectBased ic,
+ final WriteContext writeContext)
throws VppApiInvocationException {
String outSwIfName = ic.getXconnectOutgoingInterface();
LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName,
ifcName);
- int outSwIfIndex = interfaceContext.getIndex(outSwIfName);
+ int outSwIfIndex = interfaceContext.getIndex(outSwIfName, writeContext.getMappingContext());
checkArgument(outSwIfIndex > 0,
"Unable to set Interconnection for Interface: %s, outgoing interface: %s does not exist",
ifcName, outSwIfIndex);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
index 4d17ba098..bf355e479 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
@@ -60,7 +60,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
throws WriteFailedException.CreateFailedException {
try {
- setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of Routing failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -75,7 +75,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
try {
// TODO handle updates properly
- setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of Routing failed", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -88,8 +88,8 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
// TODO implement delete
}
- private void setRouting(final String name, final Routing rt) throws VppApiInvocationException {
- final int swIfc = interfaceContext.getIndex(name);
+ private void setRouting(final String name, final Routing rt, final WriteContext writeContext) throws VppApiInvocationException {
+ final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
LOG.debug("Setting routing for interface: {}, {}. Routing: {}", name, swIfc, rt);
int vrfId = (rt != null)
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
index ecf2337e8..fb47b6a9f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
@@ -75,15 +75,16 @@ public class SubInterfaceCustomizer extends AbstractInterfaceTypeCustomizer<SubI
@Nonnull final SubInterface dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
try {
- createSubInterface(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ createSubInterface(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void createSubInterface(final String swIfName, final SubInterface subInterface) throws VppApiInvocationException {
+ private void createSubInterface(final String swIfName, final SubInterface subInterface,
+ final WriteContext writeContext) throws VppApiInvocationException {
final String superIfName = subInterface.getSuperInterface();
- final int swIfIndex = interfaceContext.getIndex(superIfName);
+ final int swIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext());
LOG.debug("Creating sub interface of {}(id={}): name={}, subInterface={}", superIfName, swIfIndex, swIfName, subInterface);
final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage =
getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, swIfIndex));
@@ -96,7 +97,7 @@ public class SubInterfaceCustomizer extends AbstractInterfaceTypeCustomizer<SubI
} else {
LOG.debug("Sub interface created successfully for: {}, subInterface: {}", swIfName, subInterface);
// Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName);
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
index 72679fe12..bafe788ad 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
@@ -69,7 +69,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
try {
- createTap(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ createTap(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Write of Tap failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -84,7 +84,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
final int index;
try {
- index = interfaceContext.getIndex(ifcName);
+ index = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
} catch (IllegalArgumentException e) {
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
@@ -105,20 +105,20 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
final int index;
try {
- index = interfaceContext.getIndex(ifcName);
+ index = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
} catch (IllegalArgumentException e) {
throw new WriteFailedException.DeleteFailedException(id, e);
}
try {
- deleteTap(ifcName, index, dataBefore);
+ deleteTap(ifcName, index, dataBefore, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Delete of Tap failed", e);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createTap(final String swIfName, final Tap tap) throws VppApiInvocationException {
+ private void createTap(final String swIfName, final Tap tap, final WriteContext writeContext) throws VppApiInvocationException {
LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapConnectReply> tapConnectFuture =
getFutureJVpp().tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
@@ -130,7 +130,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
} else {
LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
// Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName);
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
}
@@ -148,7 +148,8 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
}
}
- private void deleteTap(final String swIfName, final int index, final Tap dataBefore)
+ private void deleteTap(final String swIfName, final int index, final Tap dataBefore,
+ final WriteContext writeContext)
throws VppApiInvocationException {
LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore);
final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage =
@@ -161,7 +162,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
} else {
LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore);
// Remove deleted interface from interface context
- interfaceContext.removeName(swIfName);
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
index ebefff34a..5f7d626e8 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
@@ -73,13 +73,13 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
try {
- createVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ createVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException | IllegalInterfaceTypeException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void createVhostUserIf(final String swIfName, final VhostUser vhostUser) throws VppApiInvocationException {
+ private void createVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage =
getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser));
@@ -92,7 +92,7 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
} else {
LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName);
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
}
@@ -118,17 +118,17 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
}
try {
- modifyVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ modifyVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
- private void modifyVhostUserIf(final String swIfName, final VhostUser vhostUser) throws VppApiInvocationException {
+ private void modifyVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage =
getFutureJVpp()
- .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, interfaceContext.getIndex(swIfName)));
+ .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
final ModifyVhostUserIfReply reply =
V3poUtils.getReply(modifyVhostUserIfReplyCompletionStage.toCompletableFuture());
@@ -155,16 +155,16 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Nonnull final VhostUser dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
try {
- deleteVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataBefore);
+ deleteVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataBefore, writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void deleteVhostUserIf(final String swIfName, final VhostUser vhostUser) throws VppApiInvocationException {
+ private void deleteVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage =
- getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName)));
+ getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
final DeleteVhostUserIfReply reply =
V3poUtils.getReply(deleteVhostUserIfReplyCompletionStage.toCompletableFuture());
@@ -174,7 +174,7 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
} else {
LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Remove interface from our interface context
- interfaceContext.removeName(swIfName);
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizer.java
index 7e7e319eb..d1e55a0a0 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizer.java
@@ -70,14 +70,15 @@ public class VlanTagRewriteCustomizer extends FutureJVppCustomizer implements Ch
@Nonnull final VlanTagRewrite dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
try {
- setTagRewrite(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ setTagRewrite(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void setTagRewrite(final String ifname, final VlanTagRewrite cfg) throws VppApiInvocationException {
- final int swIfIndex = interfaceContext.getIndex(ifname);
+ private void setTagRewrite(final String ifname, final VlanTagRewrite cfg, final WriteContext writeContext)
+ throws VppApiInvocationException {
+ final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext());
LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, cfg);
final CompletionStage<L2InterfaceVlanTagRewriteReply> replyCompletionStage =
@@ -121,7 +122,7 @@ public class VlanTagRewriteCustomizer extends FutureJVppCustomizer implements Ch
return;
}
try {
- setTagRewrite(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ setTagRewrite(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
@@ -135,7 +136,7 @@ public class VlanTagRewriteCustomizer extends FutureJVppCustomizer implements Ch
// disable tag rewrite
final VlanTagRewriteBuilder builder = new VlanTagRewriteBuilder();
builder.setRewriteOperation(TagRewriteOperation.Disabled);
- setTagRewrite(id.firstKeyOf(Interface.class).getName(), builder.build());
+ setTagRewrite(id.firstKeyOf(Interface.class).getName(), builder.build(), writeContext);
} catch (VppApiInvocationException e) {
throw new WriteFailedException.DeleteFailedException(id, e);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
index 9d11b59b1..3edd531c6 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
@@ -71,7 +71,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
try {
- createVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataAfter);
+ createVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
} catch (VppApiInvocationException | IllegalInterfaceTypeException e) {
LOG.warn("Write of Vxlan failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -95,14 +95,14 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
try {
- deleteVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataBefore);
+ deleteVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataBefore, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Delete of Vxlan tunnel failed", e);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createVxlanTunnel(final String swIfName, final Vxlan vxlan) throws VppApiInvocationException {
+ private void createVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppApiInvocationException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -123,7 +123,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
} else {
LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan);
// Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName);
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
}
@@ -143,7 +143,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
}
- private void deleteVxlanTunnel(final String swIfName, final Vxlan vxlan) throws VppApiInvocationException {
+ private void deleteVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppApiInvocationException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -164,7 +164,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
} else {
LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
// Remove interface from our interface context
- interfaceContext.removeName(swIfName);
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
index a54f6c5e3..4deb38f52 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
@@ -68,7 +68,7 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
throws WriteFailedException {
try {
final String ifcName = id.firstKeyOf(Interface.class).getName();
- setIpv4(id, ifcName, dataAfter);
+ setIpv4(id, ifcName, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Create of Ipv4 failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -84,7 +84,7 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
// TODO handle update in a better way
try {
- setIpv4(id, ifcName, dataAfter);
+ setIpv4(id, ifcName, dataAfter, writeContext);
} catch (VppApiInvocationException e) {
LOG.warn("Update of Ipv4 failed", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -97,9 +97,10 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
// TODO implement delete
}
- private void setIpv4(final InstanceIdentifier<Ipv4> id, final String name, final Ipv4 ipv4)
+ private void setIpv4(final InstanceIdentifier<Ipv4> id, final String name, final Ipv4 ipv4,
+ final WriteContext writeContext)
throws WriteFailedException, VppApiInvocationException {
- final int swIfc = interfaceContext.getIndex(name);
+ final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
for (Address ipv4Addr : ipv4.getAddress()) {
Subnet subnet = ipv4Addr.getSubnet();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
index 74ea45c11..8173b67ba 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
@@ -16,7 +16,9 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import io.fd.honeycomb.v3po.translate.Context;
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
+
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -64,11 +66,11 @@ public class EthernetCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Ethernet> id,
@Nonnull final EthernetBuilder builder,
- @Nonnull final Context ctx) throws ReadFailedException {
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key,
- interfaceContext.getIndex(key.getName()), ctx);
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
builder.setMtu((int) iface.linkMtu);
switch (iface.linkDuplex) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
index 51d4022d7..87c62f48f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
@@ -16,7 +16,8 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -69,13 +70,13 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Interface> id, @Nonnull InterfaceBuilder builder,
- @Nonnull Context ctx) throws ReadFailedException {
+ @Nonnull ReadContext ctx) throws ReadFailedException {
LOG.debug("Reading attributes for interface: {}", id);
final InterfaceKey key = id.firstKeyOf(id.getTargetType());
// Pass cached details from getAllIds to getDetails to avoid additional dumps
final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key,
- interfaceContext.getIndex(key.getName()), ctx);
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", key.getName(), iface);
builder.setName(key.getName());
@@ -94,7 +95,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
@Nonnull
@SuppressWarnings("unchecked")
- public static Map<Integer, SwInterfaceDetails> getCachedInterfaceDump(final @Nonnull Context ctx) {
+ public static Map<Integer, SwInterfaceDetails> getCachedInterfaceDump(final @Nonnull ModificationCache ctx) {
return ctx.get(DUMPED_IFCS_CONTEXT_KEY) == null
? new HashMap<>() // allow customizers to update the cache
: (Map<Integer, SwInterfaceDetails>) ctx.get(DUMPED_IFCS_CONTEXT_KEY);
@@ -103,7 +104,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
@Nonnull
@Override
public List<InterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<Interface> id,
- @Nonnull final Context context) throws ReadFailedException {
+ @Nonnull final ReadContext context) throws ReadFailedException {
LOG.trace("Dumping all interfaces to get all IDs");
final SwInterfaceDump request = new SwInterfaceDump();
@@ -120,20 +121,20 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
}
// Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
.collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
final List<InterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
.filter(elt -> elt != null)
.map((elt) -> {
// Store interface name from VPP in context if not yet present
- if (!interfaceContext.containsName(elt.swIfIndex)) {
- interfaceContext.addName(elt.swIfIndex, V3poUtils.toString(elt.interfaceName));
+ if (!interfaceContext.containsName(elt.swIfIndex, context.getMappingContext())) {
+ interfaceContext.addName(elt.swIfIndex, V3poUtils.toString(elt.interfaceName), context.getMappingContext());
}
LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
- interfaceContext.getName(elt.swIfIndex), elt.interfaceName, elt.swIfIndex);
+ interfaceContext.getName(elt.swIfIndex, context.getMappingContext()), elt.interfaceName, elt.swIfIndex);
- return new InterfaceKey(interfaceContext.getName(elt.swIfIndex));
+ return new InterfaceKey(interfaceContext.getName(elt.swIfIndex, context.getMappingContext()));
})
.collect(Collectors.toList());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
index a6c887336..ee66aef1f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
@@ -21,7 +21,7 @@ import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCusto
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.ModificationCache;
import io.fd.honeycomb.v3po.translate.v3po.utils.V3poUtils;
import java.math.BigInteger;
import java.util.Map;
@@ -158,7 +158,7 @@ public final class InterfaceUtils {
@Nonnull
public static SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVpp futureJvpp,
@Nonnull InterfaceKey key, final int index,
- @Nonnull final Context ctx) {
+ @Nonnull final ModificationCache ctx) {
final SwInterfaceDump request = new SwInterfaceDump();
request.nameFilter = key.getName().getBytes();
request.nameFilterValid = 1;
@@ -225,7 +225,7 @@ public final class InterfaceUtils {
return EthernetCsmacd.class;
}
- static boolean isInterfaceOfType(final Context ctx, final int index,
+ static boolean isInterfaceOfType(final ModificationCache ctx, final int index,
final Class<? extends InterfaceType> ifcType) {
final SwInterfaceDetails cachedDetails =
checkNotNull(getCachedInterfaceDump(ctx).get(index),
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
index 099d4c195..1bc9c2b3a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
@@ -17,7 +17,7 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -74,20 +74,20 @@ public class L2Customizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2> id, @Nonnull final L2Builder builder,
- @Nonnull final Context ctx) throws ReadFailedException {
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
LOG.debug("Reading attributes for L2: {}", id);
final InterfaceKey key = id.firstKeyOf(Interface.class);
- final int ifaceId = interfaceContext.getIndex(key.getName());
+ final int ifaceId = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key,
- ifaceId, ctx);
+ ifaceId, ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", key.getName(), iface);
final Optional<BridgeDomainSwIfDetails> bdForInterface = getBridgeDomainForInterface(ifaceId);
if (bdForInterface.isPresent()) {
final BridgeDomainSwIfDetails bdSwIfDetails = bdForInterface.get();
final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder();
- bbBuilder.setBridgeDomain(bridgeDomainContext.getName(bdSwIfDetails.bdId));
+ bbBuilder.setBridgeDomain(bridgeDomainContext.getName(bdSwIfDetails.bdId, ctx.getMappingContext()));
// bbBuilder.setBridgedVirtualInterface // TODO where to find that value?
if (bdSwIfDetails.shg != 0) {
bbBuilder.setSplitHorizonGroup((short)bdSwIfDetails.shg);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
index b68acbfa3..ebd1cff40 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -19,7 +19,7 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -70,18 +70,18 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
- @Nonnull final SubInterfaceBuilder builder, @Nonnull final Context ctx)
+ @Nonnull final SubInterfaceBuilder builder, @Nonnull final ReadContext ctx)
throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
// Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
// to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName());
- if (!isInterfaceOfType(ctx, index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.SubInterface.class)) {
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.SubInterface.class)) {
return;
}
LOG.debug("Reading attributes for sub interface: {}", id);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key, index, ctx);
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key, index, ctx.getModificationCache());
LOG.debug("VPP interface details: {}", ReflectionToStringBuilder.toString(iface));
if (iface.subId == 0) {
@@ -90,7 +90,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
}
builder.setIdentifier(Long.valueOf(iface.subId));
- builder.setSuperInterface(interfaceContext.getName(iface.supSwIfIndex));
+ builder.setSuperInterface(interfaceContext.getName(iface.supSwIfIndex, ctx.getMappingContext()));
builder.setNumberOfTags(Short.valueOf(iface.subNumberOfTags));
builder.setVlanType(iface.subDot1Ad == 1 ? VlanType._802dot1q : VlanType._802dot1ad);
if (iface.subExactMatch == 1) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
index e7cd560bb..358e9149a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
@@ -18,7 +18,7 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -72,12 +72,12 @@ public class TapCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id,
@Nonnull final TapBuilder builder,
- @Nonnull final Context ctx) throws ReadFailedException {
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
// Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
// to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName());
- if (!isInterfaceOfType(ctx, index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
return;
}
@@ -85,7 +85,7 @@ public class TapCustomizer extends FutureJVppCustomizer
@SuppressWarnings("unchecked")
Map<Integer, SwInterfaceTapDetails> mappedTaps =
- (Map<Integer, SwInterfaceTapDetails>) ctx.get(DUMPED_TAPS_CONTEXT_KEY);
+ (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
if(mappedTaps == null) {
// Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
@@ -104,7 +104,7 @@ public class TapCustomizer extends FutureJVppCustomizer
.collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
}
- ctx.put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
+ ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
}
final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
index 70a6da1cc..d5ae8faf3 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
@@ -18,7 +18,7 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -74,12 +74,12 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUserBuilder builder,
- @Nonnull final Context ctx) throws ReadFailedException {
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
// Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
// to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName());
- if (!isInterfaceOfType(ctx, index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
return;
}
@@ -87,7 +87,7 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
@SuppressWarnings("unchecked")
Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
- (Map<Integer, SwInterfaceVhostUserDetails>) ctx.get(DUMPED_VHOST_USERS_CONTEXT_KEY);
+ (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
if(mappedVhostUsers == null) {
// Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
@@ -106,7 +106,7 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
.collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
}
- ctx.put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
+ ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
}
// Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizer.java
index d7404e6d5..d05e089a2 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizer.java
@@ -17,7 +17,7 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -68,13 +68,13 @@ public class VlanTagRewriteCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VlanTagRewrite> id,
- @Nonnull final VlanTagRewriteBuilder builder, @Nonnull final Context ctx)
+ @Nonnull final VlanTagRewriteBuilder builder, @Nonnull final ReadContext ctx)
throws ReadFailedException {
LOG.debug("Reading attributes for sub interface: {}", id);
final InterfaceKey key = id.firstKeyOf(Interface.class);
final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key,
- interfaceContext.getIndex(key.getName()), ctx);
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
builder.setFirstPushed(iface.subDot1Ad == 1 ? VlanType._802dot1q : VlanType._802dot1ad);
builder.setRewriteOperation(TagRewriteOperation.forValue(iface.vtrOp));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
index 829416034..81ba34062 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
@@ -18,7 +18,7 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -74,12 +74,12 @@ public class VxlanCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id,
@Nonnull final VxlanBuilder builder,
- @Nonnull final Context ctx) throws ReadFailedException {
+ @Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
// Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
// to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName());
- if (!InterfaceUtils.isInterfaceOfType(ctx, index, VxlanTunnel.class)) {
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanTunnel.class)) {
return;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
index 672a05f4e..6e94461a6 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
@@ -96,11 +96,11 @@ public class BridgeDomainCustomizer
// FIXME we need the bd index to be returned by VPP or we should have a counter field (maybe in context similar to artificial name)
// Here we assign the next available ID from bdContext's perspective
int index = 1;
- while(bdContext.containsName(index)) {
+ while(bdContext.containsName(index, ctx.getMappingContext())) {
index++;
}
addOrUpdateBridgeDomain(index, dataBefore);
- bdContext.addName(index, bdName);
+ bdContext.addName(index, bdName, ctx.getMappingContext());
} catch (VppApiInvocationException e) {
LOG.warn("Failed to create bridge domain", e);
throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
@@ -120,7 +120,7 @@ public class BridgeDomainCustomizer
LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx);
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
- int bdId = bdContext.getIndex(bdName);
+ int bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
@@ -154,7 +154,7 @@ public class BridgeDomainCustomizer
"BridgeDomain name changed. It should be deleted and then created.");
try {
- addOrUpdateBridgeDomain(bdContext.getIndex(bdName), dataAfter);
+ addOrUpdateBridgeDomain(bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
} catch (VppApiInvocationException e) {
LOG.warn("Failed to create bridge domain", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
index 1a3855ced..ac16c610f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
@@ -20,7 +20,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.primitives.Longs;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -70,7 +70,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
- @Nonnull final BridgeDomainBuilder builder, @Nonnull final Context context)
+ @Nonnull final BridgeDomainBuilder builder, @Nonnull final ReadContext context)
throws ReadFailedException {
LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}",
id, builder, context);
@@ -78,13 +78,13 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
final BridgeDomainKey key = id.firstKeyOf(id.getTargetType());
LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key);
- final int bdId = bdContext.getIndex(key.getName());
+ final int bdId = bdContext.getIndex(key.getName(), context.getMappingContext());
LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: bdId={}", bdId);
BridgeDomainDetailsReplyDump reply;
BridgeDomainDetails bridgeDomainDetails;
final BridgeDomainDump request = new BridgeDomainDump();
- request.bdId = bdContext.getIndex(key.getName());
+ request.bdId = bdContext.getIndex(key.getName(), context.getMappingContext());
try {
reply = getFutureJVpp().bridgeDomainDump(request).toCompletableFuture().get();
bridgeDomainDetails = Iterables.getOnlyElement(reply.bridgeDomainDetails);
@@ -102,7 +102,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
builder.setLearn(byteToBoolean(bridgeDomainDetails.learn));
builder.setUnknownUnicastFlood(byteToBoolean(bridgeDomainDetails.uuFlood));
- builder.setInterface(getIfcs(bridgeDomainDetails, reply.bridgeDomainSwIfDetails));
+ builder.setInterface(getIfcs(bridgeDomainDetails, reply.bridgeDomainSwIfDetails, context));
final L2FibTableDump l2FibRequest = new L2FibTableDump();
l2FibRequest.bdId = bdId;
@@ -124,7 +124,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
? L2Fib.Action.Filter
: L2Fib.Action.Forward))
.setBridgedVirtualInterface(byteToBoolean(entry.bviMac))
- .setOutgoingInterface(interfaceContext.getName(entry.swIfIndex))
+ .setOutgoingInterface(interfaceContext.getName(entry.swIfIndex, context.getMappingContext()))
.setStaticConfig(byteToBoolean(entry.staticMac))
.setPhysAddress(address)
.setKey(new L2FibKey(address))
@@ -175,10 +175,11 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
}
private List<Interface> getIfcs(final BridgeDomainDetails bridgeDomainDetails,
- final List<BridgeDomainSwIfDetails> bridgeDomainSwIfDetails) {
+ final List<BridgeDomainSwIfDetails> bridgeDomainSwIfDetails,
+ final ReadContext context) {
final List<Interface> ifcs = new ArrayList<>(bridgeDomainSwIfDetails.size());
for (BridgeDomainSwIfDetails anInterface : bridgeDomainSwIfDetails) {
- final String interfaceName = interfaceContext.getName(anInterface.swIfIndex);
+ final String interfaceName = interfaceContext.getName(anInterface.swIfIndex, context.getMappingContext());
if (anInterface.bdId == bridgeDomainDetails.bdId) {
ifcs.add(new InterfaceBuilder()
.setBridgedVirtualInterface(bridgeDomainDetails.bviSwIfIndex == anInterface.swIfIndex)
@@ -202,7 +203,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
@Nonnull
@Override
public List<BridgeDomainKey> getAllIds(@Nonnull final InstanceIdentifier<BridgeDomain> id,
- @Nonnull final Context context) {
+ @Nonnull final ReadContext context) {
final BridgeDomainDump request = new BridgeDomainDump();
request.bdId = -1; // dump call
@@ -228,7 +229,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
for (BridgeDomainDetails detail : reply.bridgeDomainDetails) {
logBridgeDomainDetails(detail);
- final String bName = bdContext.getName(detail.bdId);
+ final String bName = bdContext.getName(detail.bdId, context.getMappingContext());
LOG.debug("vppstate.BridgeDomainCustomizer.getAllIds: bName={}", bName);
allIds.add(new BridgeDomainKey(bName));
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
index 1db8217f9..4ad4a6e91 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
@@ -16,7 +16,7 @@
package io.fd.honeycomb.v3po.translate.v3po.vppstate;
-import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
@@ -53,7 +53,7 @@ public final class VersionCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder,
- @Nonnull final Context context) throws ReadFailedException {
+ @Nonnull final ReadContext context) throws ReadFailedException {
ShowVersionReply reply;
try {