HC2VPP-392: skip init mtu for non-ethernet interfaces 73/19873/3
authorMichal Cmarada <[email protected]>
Wed, 29 May 2019 10:50:46 +0000 (12:50 +0200)
committerMichal Cmarada <[email protected]>
Wed, 29 May 2019 10:54:24 +0000 (12:54 +0200)
when honeycomb is started all interfaces are loaded with
additional Ethernet container. This then sometimes causes
wrong identification of interfaces.

Change-Id: Icd8833e611172094e4241a746d104f0057cb6581
Signed-off-by: Michal Cmarada <[email protected]>
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/EthernetCustomizer.java

index 62687c7..b98c15f 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.VppInt
 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.VppInterfaceAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.Ethernet;
 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.EthernetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev180703.EthernetCsmacd;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
 import org.opendaylight.yangtools.concepts.Builder;
@@ -86,20 +87,18 @@ public class EthernetCustomizer
     }
 
     @Override
-    public Initialized<org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.Ethernet> init(
-            @Nonnull final InstanceIdentifier<Ethernet> id,
-            @Nonnull final Ethernet readValue,
-            @Nonnull final ReadContext ctx) {
-        return Initialized.create(getCfgId(id),
-                new org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.EthernetBuilder()
-                        .setMtu(readValue.getMtu())
-                        .build());
+    public Initialized<Ethernet> init(@Nonnull final InstanceIdentifier<Ethernet> id, @Nonnull final Ethernet readValue,
+                                      @Nonnull final ReadContext ctx) {
+        if (EthernetCsmacd.class.equals(getInterfaceType(id.firstKeyOf(Interface.class).getName()))) {
+            return Initialized.create(getCfgId(id), new EthernetBuilder().setMtu(readValue.getMtu()).build());
+        } else {
+            return Initialized.create(getCfgId(id), new EthernetBuilder().build());
+        }
     }
 
-    private InstanceIdentifier<org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.Ethernet> getCfgId(
-            final InstanceIdentifier<Ethernet> id) {
+    private InstanceIdentifier<Ethernet> getCfgId(final InstanceIdentifier<Ethernet> id) {
         return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class))
                 .augmentation(VppInterfaceAugmentation.class)
-                .child(org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.interfaces._interface.Ethernet.class);
+                .child(Ethernet.class);
     }
 }