summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-06-02 13:23:39 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-06-06 12:52:33 +0000
commit303c10fd52abfbeeeb17a94b3b502d539e9197ac (patch)
tree41bc38400138a6e956e34428f48d8dfe22db0d4d /v3po/v3po2vpp/src/main/java/io/fd/honeycomb
parent64c12426da9aaf583a0262783b8bc5a1674f7081 (diff)
Intializers for the new vlan model
Change-Id: I513f0b190e9d9e669663a9a216e7c72b1ebeb10d Signed-off-by: Marek Gradzki <mgradzki@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/initializers/InterfacesInitializer.java66
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java66
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java25
3 files changed, 91 insertions, 66 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/InterfacesInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/InterfacesInitializer.java
index a41a6e87b..5a0e35dbd 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/InterfacesInitializer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/InterfacesInitializer.java
@@ -16,6 +16,8 @@
package io.fd.honeycomb.v3po.translate.v3po.initializers;
+import static io.fd.honeycomb.v3po.translate.v3po.initializers.SubInterfaceInitializationUtils.initializeSubinterfaceStateAugmentation;
+
import com.google.common.collect.Lists;
import io.fd.honeycomb.v3po.vpp.data.init.AbstractDataTreeConverter;
import javax.annotation.Nonnull;
@@ -34,20 +36,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeVni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.EthernetBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.L2Builder;
-// import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.SubInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.TapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUserBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpeBuilder;
-// import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.l2.VlanTagRewriteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Ethernet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.L2;
-// import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.SubInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Tap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VhostUser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe;
-// import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.l2.VlanTagRewrite;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBased;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder;
@@ -89,10 +87,19 @@ public class InterfacesInitializer extends AbstractDataTreeConverter<InterfacesS
builder.setName(input.getName());
builder.setType(input.getType());
builder.setEnabled(AdminStatus.Up.equals(input.getAdminStatus()));
- // builder.setLinkUpDownTrapEnable(); not present in interfaces-state
+ // builder.setLinkUpDownTrapEnable(); TODO not present in interfaces-state
+
+ initializeVppInterfaceStateAugmentation(input, builder);
+ initializeSubinterfaceStateAugmentation(input, builder);
+
+ return builder.build();
+ }
+ private static void initializeVppInterfaceStateAugmentation(
+ final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface input,
+ final InterfaceBuilder builder) {
final VppInterfaceStateAugmentation vppIfcAugmentation =
- input.getAugmentation(VppInterfaceStateAugmentation.class);
+ input.getAugmentation(VppInterfaceStateAugmentation.class);
if(vppIfcAugmentation != null) {
final VppInterfaceAugmentationBuilder augmentBuilder = new VppInterfaceAugmentationBuilder();
builder.setDescription(vppIfcAugmentation.getDescription());
@@ -122,12 +129,6 @@ public class InterfacesInitializer extends AbstractDataTreeConverter<InterfacesS
setL2(augmentBuilder, l2);
}
- // FIXME new vlan model
-// final SubInterface subInterface = vppIfcAugmentation.getSubInterface();
-// if(subInterface != null) {
-// setSubinterface(augmentBuilder, subInterface);
-// }
-
final Ethernet ethernet = vppIfcAugmentation.getEthernet();
if(ethernet != null) {
setEthernet(augmentBuilder, ethernet);
@@ -137,38 +138,8 @@ public class InterfacesInitializer extends AbstractDataTreeConverter<InterfacesS
builder.addAugmentation(VppInterfaceAugmentation.class, augmentBuilder.build());
}
-
- return builder.build();
}
- // FIXME vlan new modele
-// private static void setSubinterface(final VppInterfaceAugmentationBuilder augmentBuilder,
-// final SubInterface subInterface) {
-// final SubInterfaceBuilder subIfcBuilder = new SubInterfaceBuilder();
-//
-// if(subInterface.isDefaultSubif() != null) {
-// subIfcBuilder.setDefaultSubif(subInterface.isDefaultSubif());
-// }
-// if(subInterface.isExactMatch() != null) {
-// subIfcBuilder.setExactMatch(subInterface.isExactMatch());
-// }
-// if(subInterface.isMatchAnyInnerId() != null) {
-// subIfcBuilder.setMatchAnyInnerId(subInterface.isMatchAnyInnerId());
-// }
-// if(subInterface.isMatchAnyOuterId() != null) {
-// subIfcBuilder.setMatchAnyOuterId(subInterface.isMatchAnyOuterId());
-// }
-//
-// subIfcBuilder.setIdentifier(subInterface.getIdentifier());
-// subIfcBuilder.setInnerId(subInterface.getInnerId());
-// subIfcBuilder.setNumberOfTags(subInterface.getNumberOfTags());
-// subIfcBuilder.setOuterId(subInterface.getOuterId());
-// subIfcBuilder.setSuperInterface(subInterface.getSuperInterface());
-// subIfcBuilder.setVlanType(subInterface.getVlanType());
-//
-// augmentBuilder.setSubInterface(subIfcBuilder.build());
-// }
-
private static void setEthernet(final VppInterfaceAugmentationBuilder augmentBuilder, final Ethernet ethernet) {
final EthernetBuilder ethernetBuilder = new EthernetBuilder();
ethernetBuilder.setMtu(ethernet.getMtu());
@@ -195,17 +166,6 @@ public class InterfacesInitializer extends AbstractDataTreeConverter<InterfacesS
}
}
- // FIXME new vlan model
-// final VlanTagRewrite vlanTagRewrite = l2.getVlanTagRewrite();
-// if(vlanTagRewrite != null) {
-// final VlanTagRewriteBuilder vlanTagRewriteBuilder = new VlanTagRewriteBuilder();
-// vlanTagRewriteBuilder.setFirstPushed(vlanTagRewrite.getFirstPushed());
-// vlanTagRewriteBuilder.setRewriteOperation(vlanTagRewrite.getRewriteOperation());
-// vlanTagRewriteBuilder.setTag1(vlanTagRewrite.getTag1());
-// vlanTagRewriteBuilder.setTag2(vlanTagRewrite.getTag2());
-// l2Builder.setVlanTagRewrite(vlanTagRewriteBuilder.build());
-// }
-
augmentBuilder.setL2(l2Builder.build());
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java
new file mode 100644
index 000000000..3975bf3dc
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java
@@ -0,0 +1,66 @@
+package io.fd.honeycomb.v3po.translate.v3po.initializers;
+
+import com.google.common.collect.Lists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface;
+
+/**
+ * Utility class for sub interface initialization
+ */
+final class SubInterfaceInitializationUtils {
+
+ private SubInterfaceInitializationUtils() {
+ throw new UnsupportedOperationException("Utility class cannot be instantiated");
+ }
+
+ static void initializeSubinterfaceStateAugmentation(
+ final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface input,
+ final InterfaceBuilder builder) {
+ final SubinterfaceStateAugmentation subIfcAugmentation =
+ input.getAugmentation(SubinterfaceStateAugmentation.class);
+ if (subIfcAugmentation != null) {
+ final SubinterfaceAugmentationBuilder augmentBuilder = new SubinterfaceAugmentationBuilder();
+
+ final SubInterfaces subInterfaces = subIfcAugmentation.getSubInterfaces();
+ if (subInterfaces != null) {
+ setSubInterfaces(augmentBuilder, subInterfaces);
+ }
+
+ builder.addAugmentation(SubinterfaceAugmentation.class, augmentBuilder.build());
+ }
+ }
+
+ private static void setSubInterfaces(final SubinterfaceAugmentationBuilder augmentBuilder,
+ final SubInterfaces operationalData) {
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfacesBuilder
+ subInterfacesCfgBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfacesBuilder();
+ subInterfacesCfgBuilder.setSubInterface(Lists.transform(operationalData.getSubInterface(),
+ SubInterfaceInitializationUtils::convertSubInterface));
+ augmentBuilder.setSubInterfaces(subInterfacesCfgBuilder.build());
+ }
+
+ private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface convertSubInterface(
+ final SubInterface operationalData) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceBuilder subInterfaceCfgBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceBuilder();
+
+ subInterfaceCfgBuilder.setEnabled(Interface.AdminStatus.Up.equals(operationalData.getAdminStatus()));
+ subInterfaceCfgBuilder.setIdentifier(operationalData.getIdentifier());
+ subInterfaceCfgBuilder.setKey(new SubInterfaceKey(operationalData.getIdentifier()));
+ subInterfaceCfgBuilder.setL2(operationalData.getL2());
+ subInterfaceCfgBuilder.setMatch(operationalData.getMatch());
+ subInterfaceCfgBuilder.setTags(operationalData.getTags());
+ subInterfaceCfgBuilder.setVlanType(operationalData.getVlanType());
+
+ return subInterfaceCfgBuilder.build();
+ }
+
+}
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 e0bae975f..756b298bd 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
@@ -19,14 +19,15 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkNotNull;
import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
import static java.util.Objects.requireNonNull;
-import static java.util.stream.Collectors.toList;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.util.RWUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import java.math.BigInteger;
import java.util.Map;
import java.util.concurrent.CompletionStage;
+import java.util.stream.Collector;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
@@ -59,6 +60,9 @@ public final class InterfaceUtils {
private static final int PHYSICAL_ADDRESS_LENGTH = 6;
+ private static final Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR =
+ RWUtils.singleItemCollector();
+
private InterfaceUtils() {
throw new UnsupportedOperationException("This utility class cannot be instantiated");
}
@@ -147,11 +151,11 @@ public final class InterfaceUtils {
/**
* Queries VPP for interface description given interface key.
*
- * @param futureJvpp VPP Java Future API
- * @param name interface name
- * @param index VPP index of the interface
- * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
- * available or outdated, another dump will be performed.
+ * @param futureJvpp VPP Java Future API
+ * @param name interface name
+ * @param index VPP index of the interface
+ * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
+ * available or outdated, another dump will be performed.
* @return SwInterfaceDetails DTO or null if interface was not found
* @throws IllegalArgumentException If interface cannot be found
*/
@@ -198,13 +202,8 @@ public final class InterfaceUtils {
}
// SwInterfaceDump's name filter does prefix match, so we need additional filtering:
- final SwInterfaceDetails iface = ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(
- Collectors.collectingAndThen(toList(), l -> {
- if (l.size() == 1) {
- return l.get(0);
- }
- throw new RuntimeException();
- }));
+ final SwInterfaceDetails iface =
+ ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR);
allInterfaces.put(index, iface); // update the cache
return iface;
}