diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-05-04 10:17:39 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-05-05 08:41:23 +0200 |
commit | f187ae2f6a363616442a8968db1450977ce69078 (patch) | |
tree | 7e3c8799f931a47edbbf3a6ec40494a75a2a7d7f /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VppInterfaceStateCustomizer.java | |
parent | fd5c022142f871c78d29708c89afc941518acbd0 (diff) |
HONEYCOMB-10: Porting v3po2vpp to the new Java API
Change-Id: Ic7166b0f578442165595aa44a587ebbc5db0e75c
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
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); |