diff options
author | baude <bbaude@redhat.com> | 2019-02-24 09:51:56 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-02-25 16:14:06 -0600 |
commit | 0416b3afc42fb9471c1fdb4555931dba86900e97 (patch) | |
tree | 3bb0ba69a66ae2665ca50a153593cb6fe4768ec3 /cmd/podman/pod_pause.go | |
parent | cf521449e5d11813571c5e9b86668fbefdd5aa99 (diff) | |
download | podman-0416b3afc42fb9471c1fdb4555931dba86900e97.tar.gz podman-0416b3afc42fb9471c1fdb4555931dba86900e97.tar.bz2 podman-0416b3afc42fb9471c1fdb4555931dba86900e97.zip |
podman-remote pod pause|unpause|restart
enable the ability for the remote client to pause, unpause, and
restart pods.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/pod_pause.go')
-rw-r--r-- | cmd/podman/pod_pause.go | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/cmd/podman/pod_pause.go b/cmd/podman/pod_pause.go index e01d73c9b..284740d22 100644 --- a/cmd/podman/pod_pause.go +++ b/cmd/podman/pod_pause.go @@ -3,7 +3,7 @@ package main import ( "fmt" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/pkg/adapter" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -40,37 +40,33 @@ func init() { } func podPauseCmd(c *cliconfig.PodPauseValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + var lastError error + runtime, err := adapter.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } defer runtime.Shutdown(false) - // getPodsFromContext returns an error when a requested pod - // isn't found. The only fatal error scenerio is when there are no pods - // in which case the following loop will be skipped. - pods, lastError := getPodsFromContext(&c.PodmanCommand, runtime) + pauseIDs, conErrors, pauseErrors := runtime.PausePods(c) - for _, pod := range pods { - ctr_errs, err := pod.Pause() - if ctr_errs != nil { - for ctr, err := range ctr_errs { - if lastError != nil { - logrus.Errorf("%q", lastError) - } - lastError = errors.Wrapf(err, "unable to pause container %q on pod %q", ctr, pod.ID()) - } - continue - } - if err != nil { + for _, p := range pauseIDs { + fmt.Println(p) + } + if conErrors != nil && len(conErrors) > 0 { + for ctr, err := range conErrors { if lastError != nil { logrus.Errorf("%q", lastError) } - lastError = errors.Wrapf(err, "unable to pause pod %q", pod.ID()) - continue + lastError = errors.Wrapf(err, "unable to pause container %s", ctr) } - fmt.Println(pod.ID()) } - + if len(pauseErrors) > 0 { + lastError = pauseErrors[len(pauseErrors)-1] + // Remove the last error from the error slice + pauseErrors = pauseErrors[:len(pauseErrors)-1] + } + for _, err := range pauseErrors { + logrus.Errorf("%q", err) + } return lastError } |