summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-24 15:57:37 -0500
committerbaude <bbaude@redhat.com>2019-04-25 14:44:14 -0500
commitc4dd7c5813078acbe871aae37644bfff3163d160 (patch)
tree779caad2670afddd36621cbee9198a913d4b7c3f /cmd/podman
parenta01c62fcbde1afdc77aa05b71c3c84ddacf7fc55 (diff)
downloadpodman-c4dd7c5813078acbe871aae37644bfff3163d160.tar.gz
podman-c4dd7c5813078acbe871aae37644bfff3163d160.tar.bz2
podman-c4dd7c5813078acbe871aae37644bfff3163d160.zip
enable podman remote top
add the ability for the remote client to display a container's running processes. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/commands.go2
-rw-r--r--cmd/podman/container.go1
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/top.go28
-rw-r--r--cmd/podman/varlink/io.podman.varlink2
5 files changed, 7 insertions, 27 deletions
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 7680d6df2..c43ecec5c 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -21,7 +21,6 @@ func getMainCommands() []*cobra.Command {
_refreshCommand,
_searchCommand,
_statsCommand,
- _topCommand,
}
if len(_varlinkCommand.Use) > 0 {
@@ -53,7 +52,6 @@ func getContainerSubCommands() []*cobra.Command {
_runlabelCommand,
_statsCommand,
_stopCommand,
- _topCommand,
_umountCommand,
}
}
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index 28e0f0e4a..52152d50e 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -64,6 +64,7 @@ var (
_runCommand,
_rmCommand,
_startCommand,
+ _topCommand,
_unpauseCommand,
_waitCommand,
}
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 392dfe542..a0f1cf401 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -57,6 +57,7 @@ var mainCommands = []*cobra.Command{
_saveCommand,
_stopCommand,
_tagCommand,
+ _topCommand,
_umountCommand,
_unpauseCommand,
_versionCommand,
diff --git a/cmd/podman/top.go b/cmd/podman/top.go
index 0b7da64a8..f1f594ebf 100644
--- a/cmd/podman/top.go
+++ b/cmd/podman/top.go
@@ -7,8 +7,8 @@ import (
"text/tabwriter"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -60,7 +60,6 @@ func init() {
}
func topCmd(c *cliconfig.TopValues) error {
- var container *libpod.Container
var err error
args := c.InputArgs
@@ -77,37 +76,16 @@ func topCmd(c *cliconfig.TopValues) error {
return errors.Errorf("you must provide the name or id of a running container")
}
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- var descriptors []string
- if c.Latest {
- descriptors = args
- container, err = runtime.GetLatestContainer()
- } else {
- descriptors = args[1:]
- container, err = runtime.LookupContainer(args[0])
- }
-
- if err != nil {
- return errors.Wrapf(err, "unable to lookup requested container")
- }
-
- conStat, err := container.State()
- if err != nil {
- return errors.Wrapf(err, "unable to look up state for %s", args[0])
- }
- if conStat != libpod.ContainerStateRunning {
- return errors.Errorf("top can only be used on running containers")
- }
- psOutput, err := container.GetContainerPidInformation(descriptors)
+ psOutput, err := runtime.Top(c)
if err != nil {
return err
}
-
w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
for _, proc := range psOutput {
fmt.Fprintln(w, proc)
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 1fde72164..17179d665 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -524,6 +524,8 @@ method Ps(opts: PsOpts) -> (containers: []PsContainer)
method GetContainersByStatus(status: []string) -> (containerS: []Container)
+method Top (nameOrID: string, descriptors: []string) -> (top: []string)
+
# GetContainer returns information about a single container. If a container
# with the given id doesn't exist, a [ContainerNotFound](#ContainerNotFound)
# error will be returned. See also [ListContainers](ListContainers) and