diff options
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java index 8e5cc8932..2bc8beaaa 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java @@ -16,11 +16,10 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate; -import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.getVppInterfaceDetails; - import io.fd.honeycomb.v3po.translate.Context; 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; import javax.annotation.Nonnull; 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.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder; @@ -32,28 +31,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.openvpp.vppjapi.vppInterfaceDetails; +import org.openvpp.jvpp.dto.SwInterfaceDetails; +import org.openvpp.jvpp.future.FutureJVpp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class VppInterfaceStateCustomizer extends io.fd.honeycomb.v3po.translate.v3po.util.VppApiCustomizer +public class VppInterfaceStateCustomizer extends FutureJVppCustomizer implements ChildReaderCustomizer<VppInterfaceStateAugmentation, VppInterfaceStateAugmentationBuilder> { private static final Logger LOG = LoggerFactory.getLogger(VppInterfaceStateCustomizer.class); - public VppInterfaceStateCustomizer(org.openvpp.vppjapi.vppApi vppApi) { - super(vppApi); + public VppInterfaceStateCustomizer(@Nonnull final FutureJVpp jvpp) { + super(jvpp); } @Override - public void merge(@Nonnull Builder<? extends DataObject> parentBuilder, @Nonnull VppInterfaceStateAugmentation readValue) { + public void merge(@Nonnull Builder<? extends DataObject> parentBuilder, + @Nonnull VppInterfaceStateAugmentation readValue) { ((InterfaceBuilder) parentBuilder).addAugmentation(VppInterfaceStateAugmentation.class, readValue); } @Nonnull @Override - public VppInterfaceStateAugmentationBuilder getBuilder(@Nonnull InstanceIdentifier<VppInterfaceStateAugmentation> id) { + public VppInterfaceStateAugmentationBuilder getBuilder( + @Nonnull InstanceIdentifier<VppInterfaceStateAugmentation> id) { return new VppInterfaceStateAugmentationBuilder(); } @@ -63,15 +65,15 @@ public class VppInterfaceStateCustomizer extends io.fd.honeycomb.v3po.translate. @Nonnull final Context ctx) throws ReadFailedException { final InterfaceKey key = id.firstKeyOf(Interface.class); - vppInterfaceDetails[] ifaces = getVppInterfaceDetails(getVppApi(), true, key.getName()); - if (null == ifaces || ifaces.length != 1) { - return; + final SwInterfaceDetails iface; + try { + iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key); + } catch (Exception e) { + throw new ReadFailedException(id, e); } - final vppInterfaceDetails iface = ifaces[0]; final EthernetBuilder ethernet = new EthernetBuilder(); - - ethernet.setMtu(iface.linkMtu); + ethernet.setMtu((int) iface.linkMtu); switch (iface.linkDuplex) { case 1: ethernet.setDuplex(Ethernet.Duplex.Half); |