summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java
diff options
context:
space:
mode:
authorTibor Král <tibor.kral@pantheon.tech>2019-05-14 12:19:44 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-05-27 08:25:05 +0200
commit5c416ebacf4baad25de6213661c3cdfff31c0482 (patch)
treed2fe4889f01e4adbdeb50ea83b47aa44102a5f49 /v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java
parent83206cb1b6b0a6a3bbe45d646ed69a5f2b587fed (diff)
HC2VPP-381: Validation support for V3PO module
Change-Id: If288d97dce15bcc6924d4dd65c640a20920f094d Signed-off-by: Tibor Král <tibor.kral@pantheon.tech>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java66
1 files changed, 45 insertions, 21 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java
index 3fbdb9f64..4e9f7b9cc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java
@@ -22,20 +22,35 @@ import com.google.inject.name.Named;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
import io.fd.hc2vpp.v3po.interfaces.AfPacketCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.AfPacketValidator;
import io.fd.hc2vpp.v3po.interfaces.EthernetCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.EthernetValidator;
import io.fd.hc2vpp.v3po.interfaces.GreCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.GreValidator;
import io.fd.hc2vpp.v3po.interfaces.InterfaceCustomizer;
import io.fd.hc2vpp.v3po.interfaces.InterfaceRoutingCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.InterfaceRoutingValidator;
import io.fd.hc2vpp.v3po.interfaces.InterfaceUnnumberedCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.InterfaceUnnumberedValidator;
+import io.fd.hc2vpp.v3po.interfaces.InterfaceValidator;
import io.fd.hc2vpp.v3po.interfaces.InterfacesStatisticsCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.InterfacesStatisticsValidator;
import io.fd.hc2vpp.v3po.interfaces.L2Customizer;
+import io.fd.hc2vpp.v3po.interfaces.L2Validator;
import io.fd.hc2vpp.v3po.interfaces.LoopbackCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.LoopbackValidator;
import io.fd.hc2vpp.v3po.interfaces.TapV2Customizer;
+import io.fd.hc2vpp.v3po.interfaces.TapV2Validator;
import io.fd.hc2vpp.v3po.interfaces.VhostUserCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.VhostUserValidator;
import io.fd.hc2vpp.v3po.interfaces.VxlanCustomizer;
import io.fd.hc2vpp.v3po.interfaces.VxlanGpeCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.VxlanGpeValidator;
+import io.fd.hc2vpp.v3po.interfaces.VxlanValidator;
import io.fd.hc2vpp.v3po.interfaces.pbb.PbbRewriteCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.pbb.PbbRewriteValidator;
import io.fd.hc2vpp.v3po.interfaces.span.MirroredInterfaceCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.span.MirroredInterfaceValidator;
import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceStatisticsManager;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.impl.write.GenericWriter;
@@ -98,9 +113,11 @@ public final class InterfacesWriterFactory implements WriterFactory {
public void init(final ModifiableWriterRegistryBuilder registry) {
// Interfaces
registry.add(new GenericWriter<>(IFCS_ID.augmentation(VppInterfacesStatsAugmentation.class)
- .child(Statistics.class), new InterfacesStatisticsCustomizer(statisticsManager)));
+ .child(Statistics.class), new InterfacesStatisticsCustomizer(statisticsManager),
+ new InterfacesStatisticsValidator(statisticsManager)));
// Interface =
- registry.add(new GenericListWriter<>(IFC_ID, new InterfaceCustomizer(jvpp, ifcNamingContext)));
+ registry.add(new GenericListWriter<>(IFC_ID, new InterfaceCustomizer(jvpp, ifcNamingContext),
+ new InterfaceValidator(ifcNamingContext)));
// VppInterfaceAugmentation
addVppInterfaceAgmentationWriters(IFC_ID, registry);
@@ -111,47 +128,51 @@ public final class InterfacesWriterFactory implements WriterFactory {
final ModifiableWriterRegistryBuilder registry) {
// VhostUser(Needs to be executed before Interface customizer) =
final InstanceIdentifier<VhostUser> vhostId = VPP_IFC_AUG_ID.child(VhostUser.class);
- registry.addBefore(new GenericWriter<>(vhostId, new VhostUserCustomizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addBefore(new GenericWriter<>(vhostId, new VhostUserCustomizer(jvpp, ifcNamingContext),
+ new VhostUserValidator(ifcNamingContext)), ifcId);
// AfPacket(Needs to be executed before Interface customizer) =
final InstanceIdentifier<AfPacket> afpacketId = VPP_IFC_AUG_ID.child(AfPacket.class);
- registry.addBefore(new GenericWriter<>(afpacketId, new AfPacketCustomizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addBefore(new GenericWriter<>(afpacketId, new AfPacketCustomizer(jvpp, ifcNamingContext),
+ new AfPacketValidator(ifcNamingContext)), ifcId);
// Vxlan(Needs to be executed before Interface customizer) =
final InstanceIdentifier<Vxlan> vxlanId = VPP_IFC_AUG_ID.child(Vxlan.class);
- registry.addBefore(new GenericWriter<>(vxlanId, new VxlanCustomizer(jvpp, ifcNamingContext, ifcDisableContext)),
+ registry.addBefore(new GenericWriter<>(vxlanId, new VxlanCustomizer(jvpp, ifcNamingContext, ifcDisableContext),
+ new VxlanValidator(ifcNamingContext, ifcDisableContext)),
ifcId);
// VxlanGpe(Needs to be executed before Interface customizer) =
final InstanceIdentifier<VxlanGpe> vxlanGpeId = VPP_IFC_AUG_ID.child(VxlanGpe.class);
registry.addBefore(new GenericWriter<>(vxlanGpeId,
- new VxlanGpeCustomizer(jvpp, ifcNamingContext, ifcDisableContext)), ifcId);
+ new VxlanGpeCustomizer(jvpp, ifcNamingContext, ifcDisableContext),
+ new VxlanGpeValidator(ifcNamingContext, ifcDisableContext)), ifcId);
// TapV2(Needs to be executed before Interface customizer) =
final InstanceIdentifier<TapV2> tapV2Id = VPP_IFC_AUG_ID.child(TapV2.class);
- registry.addBefore(new GenericWriter<>(tapV2Id, new TapV2Customizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addBefore(new GenericWriter<>(tapV2Id, new TapV2Customizer(jvpp, ifcNamingContext),
+ new TapV2Validator(ifcNamingContext)), ifcId);
// Loopback(Needs to be executed before Interface customizer) =
final InstanceIdentifier<Loopback> loopbackId = VPP_IFC_AUG_ID.child(Loopback.class);
- registry.addBefore(new GenericWriter<>(loopbackId, new LoopbackCustomizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addBefore(new GenericWriter<>(loopbackId, new LoopbackCustomizer(jvpp, ifcNamingContext),
+ new LoopbackValidator(ifcNamingContext)), ifcId);
// Gre(Needs to be executed before Interface customizer) =
final InstanceIdentifier<Gre> greId = VPP_IFC_AUG_ID.child(Gre.class);
- registry.addBefore(new GenericWriter<>(greId, new GreCustomizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addBefore(new GenericWriter<>(greId, new GreCustomizer(jvpp, ifcNamingContext),
+ new GreValidator(ifcNamingContext)), ifcId);
final Set<InstanceIdentifier<?>> specificIfcTypes =
Sets.newHashSet(vhostId, afpacketId, vxlanId, vxlanGpeId, tapV2Id, loopbackId);
// Ethernet =
registry.add(new GenericWriter<>(VPP_IFC_AUG_ID.child(Ethernet.class),
- new EthernetCustomizer(jvpp, ifcNamingContext)));
+ new EthernetCustomizer(jvpp, ifcNamingContext), new EthernetValidator(ifcNamingContext)));
// Routing(Execute only after specific interface customizers) =
registry.addAfter(
new GenericWriter<>(VPP_IFC_AUG_ID.child(Routing.class),
- new InterfaceRoutingCustomizer(jvpp, ifcNamingContext)),
+ new InterfaceRoutingCustomizer(jvpp, ifcNamingContext),
+ new InterfaceRoutingValidator(ifcNamingContext)),
specificIfcTypes);
// L2(Execute only after subinterface (and all other ifc types) =
- registry.addAfter(new GenericWriter<>(L2_ID, new L2Customizer(jvpp, ifcNamingContext, bdNamingContext)),
+ registry.addAfter(new GenericWriter<>(L2_ID, new L2Customizer(jvpp, ifcNamingContext, bdNamingContext),
+ new L2Validator(ifcNamingContext, bdNamingContext)),
SubinterfaceAugmentationWriterFactory.SUB_IFC_ID);
// Span writers
@@ -161,13 +182,15 @@ public final class InterfacesWriterFactory implements WriterFactory {
.child(MirroredInterfaces.class)
.child(MirroredInterface.class);
registry.addAfter(new GenericWriter<>(mirroredIfcId, new MirroredInterfaceCustomizer(jvpp, ifcNamingContext,
- id -> id.firstKeyOf(Interface.class).getName())), ifcId);
+ id -> id.firstKeyOf(Interface.class).getName()),
+ new MirroredInterfaceValidator(ifcNamingContext, id -> id.firstKeyOf(Interface.class).getName())),
+ ifcId);
// Unnumbered =
final InstanceIdentifier<Unnumbered> unnumberedId =
IFC_ID.augmentation(InterfaceUnnumberedAugmentation.class).child(Unnumbered.class);
- registry.addAfter(new GenericWriter<>(unnumberedId, new InterfaceUnnumberedCustomizer(jvpp, ifcNamingContext)),
- ifcId);
+ registry.addAfter(new GenericWriter<>(unnumberedId, new InterfaceUnnumberedCustomizer(jvpp, ifcNamingContext),
+ new InterfaceUnnumberedValidator(ifcNamingContext)), ifcId);
}
private void addPbbAugmentationWriters(final InstanceIdentifier<Interface> ifcId,
@@ -175,6 +198,7 @@ public final class InterfacesWriterFactory implements WriterFactory {
final InstanceIdentifier<PbbRewrite> pbbRewriteId =
ifcId.augmentation(PbbRewriteInterfaceAugmentation.class).child(PbbRewrite.class);
- registry.add(new GenericWriter<>(pbbRewriteId, new PbbRewriteCustomizer(jvpp, ifcNamingContext)));
+ registry.add(new GenericWriter<>(pbbRewriteId, new PbbRewriteCustomizer(jvpp, ifcNamingContext),
+ new PbbRewriteValidator(ifcNamingContext)));
}
}