From 2846cc0d4665a0735d6ebf349e5bc3a6f680d3d4 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 31 Oct 2016 14:37:57 +0100 Subject: HONEYCOMB-70: add control ping to vpp-state Change-Id: I7f02841d899465fd2156db0bb79fcc490cd4929f Signed-off-by: Marek Gradzki --- v3po/api/src/main/yang/v3po.yang | 8 +++++++- .../translate/v3po/vppstate/VersionCustomizer.java | 14 +++++++++++++- .../translate/v3po/vppstate/VersionCustomizerTest.java | 8 ++++++-- .../fd/honeycomb/translate/v3po/vppstate/VppStateTest.java | 5 +++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/v3po/api/src/main/yang/v3po.yang b/v3po/api/src/main/yang/v3po.yang index 6d6d58df9..d3869abaf 100644 --- a/v3po/api/src/main/yang/v3po.yang +++ b/v3po/api/src/main/yang/v3po.yang @@ -8,7 +8,8 @@ module v3po { "This revision adds the following new features: - ingress/egress ACLs support - moved ACL definitions to vpp-acl module - - updated l2 container constraint (permit IP address on BVI interface)"; + - updated l2 container constraint (permit IP address on BVI interface) + - added PID of vpp process to vpp-state"; } revision "2015-01-05" { @@ -639,6 +640,11 @@ module v3po { leaf branch { type string; } + leaf pid { + type uint32; + description + "PID of the vpp process"; + } description "vlib version info"; } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java index 71826dcb4..dfa0f9632 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java @@ -16,6 +16,7 @@ package io.fd.honeycomb.translate.v3po.vppstate; +import com.google.common.primitives.UnsignedInts; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; @@ -25,6 +26,9 @@ import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.vpp.jvpp.core.dto.ShowVersion; import io.fd.vpp.jvpp.core.dto.ShowVersionReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import io.fd.vpp.jvpp.dto.ControlPing; +import io.fd.vpp.jvpp.dto.ControlPingReply; +import io.fd.vpp.jvpp.dto.JVppReply; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppStateBuilder; @@ -54,7 +58,7 @@ public final class VersionCustomizer } @Override - public void readCurrentAttributes(@Nonnull InstanceIdentifier id, @Nonnull final VersionBuilder builder, + public void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final VersionBuilder builder, @Nonnull final ReadContext context) throws ReadFailedException { // Execute with timeout @@ -65,6 +69,14 @@ public final class VersionCustomizer builder.setName(toString(reply.program)); builder.setBuildDate(toString(reply.buildDate)); builder.setBuildDirectory(toString(reply.buildDirectory)); + builder.setPid(getPid(id)); } + private Long getPid(@Nonnull final InstanceIdentifier id) throws ReadFailedException { + final CompletionStage> request = getFutureJVpp().send(new ControlPing()); + final ControlPingReply reply = (ControlPingReply)getReplyForRead(request.toCompletableFuture(), id); + return UnsignedInts.toLong(reply.vpePid); + } + + } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java index 0b0378755..ab35bb330 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java @@ -22,13 +22,15 @@ import static org.mockito.Mockito.when; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; +import io.fd.vpp.jvpp.core.dto.ShowVersion; +import io.fd.vpp.jvpp.core.dto.ShowVersionReply; +import io.fd.vpp.jvpp.dto.ControlPing; +import io.fd.vpp.jvpp.dto.ControlPingReply; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppStateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.Version; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.VersionBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.ShowVersion; -import io.fd.vpp.jvpp.core.dto.ShowVersionReply; public class VersionCustomizerTest extends ReaderCustomizerTest { @@ -50,7 +52,9 @@ public class VersionCustomizerTest extends ReaderCustomizerTest entryList) { -- cgit 1.2.3-korg