Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/podman/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Pods are a group of one or more containers sharing the same network, pid and ipc
podSubCommands = []cli.Command{
podCreateCommand,
podKillCommand,
podPauseCommand,
podPsCommand,
podRestartCommand,
podRmCommand,
podStartCommand,
podStopCommand,
podUnpauseCommand,
}
podCommand = cli.Command{
Name: "pod",
Expand Down
73 changes: 73 additions & 0 deletions cmd/podman/pod_pause.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package main

import (
"fmt"

"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)

var (
podPauseFlags = []cli.Flag{
cli.BoolFlag{
Name: "all, a",
Usage: "pause all running pods",
},
LatestPodFlag,
}
podPauseDescription = `
Pauses one or more pods. The pod name or ID can be used.
`

podPauseCommand = cli.Command{
Name: "pause",
Usage: "Pause one or more pods",
Description: podPauseDescription,
Flags: podPauseFlags,
Action: podPauseCmd,
ArgsUsage: "POD-NAME|POD-ID [POD-NAME|POD-ID ...]",
UseShortOptionHandling: true,
}
)

func podPauseCmd(c *cli.Context) error {
if err := checkMutuallyExclusiveFlags(c); err != nil {
return err
}

runtime, err := libpodruntime.GetRuntime(c)
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, runtime)

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 {
if lastError != nil {
logrus.Errorf("%q", lastError)
}
lastError = errors.Wrapf(err, "unable to pause pod %q", pod.ID())
continue
}
fmt.Println(pod.ID())
}

return lastError
}
73 changes: 73 additions & 0 deletions cmd/podman/pod_unpause.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package main

import (
"fmt"

"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)

var (
podUnpauseFlags = []cli.Flag{
cli.BoolFlag{
Name: "all, a",
Usage: "unpause all paused pods",
},
LatestPodFlag,
}
podUnpauseDescription = `
Unpauses one or more pods. The pod name or ID can be used.
`

podUnpauseCommand = cli.Command{
Name: "unpause",
Usage: "Unpause one or more pods",
Description: podUnpauseDescription,
Flags: podUnpauseFlags,
Action: podUnpauseCmd,
ArgsUsage: "POD-NAME|POD-ID [POD-NAME|POD-ID ...]",
UseShortOptionHandling: true,
}
)

func podUnpauseCmd(c *cli.Context) error {
if err := checkMutuallyExclusiveFlags(c); err != nil {
return err
}

runtime, err := libpodruntime.GetRuntime(c)
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, runtime)

for _, pod := range pods {
ctr_errs, err := pod.Unpause()
if ctr_errs != nil {
for ctr, err := range ctr_errs {
if lastError != nil {
logrus.Errorf("%q", lastError)
}
lastError = errors.Wrapf(err, "unable to unpause container %q on pod %q", ctr, pod.ID())
}
continue
}
if err != nil {
if lastError != nil {
logrus.Errorf("%q", lastError)
}
lastError = errors.Wrapf(err, "unable to unpause pod %q", pod.ID())
continue
}
fmt.Println(pod.ID())
}

return lastError
}
2 changes: 2 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
| [podman-pod-create(1)](/docs/podman-pod-create.1.md) | Create a new pod ||
| [podman-pod-kill(1)](podman-pod-kill.1.md) | Kill the main process of each container in pod. ||
| [podman-pod-ps(1)](/docs/podman-pod-ps.1.md) | List the pods on the system ||
| [podman-pod-pause(1)](podman-pod-pause.1.md) | Pause one or more pods. ||
| [podman-pod-restart](/docs/podman-pod-restart.1.md) | Restart one or more pods ||
| [podman-pod-rm(1)](/docs/podman-pod-rm.1.md) | Remove one or more pods ||
| [podman-pod-start(1)](/docs/podman-pod-start.1.md) | Start one or more pods ||
| [podman-pod-stop(1)](/docs/podman-pod-stop.1.md) | Stop one or more pods ||
| [podman-pod-unpause(1)](podman-pod-unpause.1.md) | Unpause one or more pods. ||
| [podman-port(1)](/docs/podman-port.1.md) | List port mappings for running containers |[![...](/docs/play.png)]()|
| [podman-ps(1)](/docs/podman-ps.1.md) | Prints out information about containers |[![...](/docs/play.png)](https://asciinema.org/a/bbT41kac6CwZ5giESmZLIaTLR)|
| [podman-pull(1)](/docs/podman-pull.1.md) | Pull an image from a registry |[![...](/docs/play.png)](https://asciinema.org/a/lr4zfoynHJOUNu1KaXa1dwG2X)|
Expand Down
62 changes: 53 additions & 9 deletions completions/bash/podman
Original file line number Diff line number Diff line change
Expand Up @@ -2193,10 +2193,10 @@ _podman_pod_start() {
"

local boolean_options="
all
a
latest
l
--all
-a
--latest
-l
"
_complete_ "$options_with_args" "$boolean_options"
case "$cur" in
Expand All @@ -2214,11 +2214,53 @@ _podman_pod_stop() {
"

local boolean_options="
all
a
cleanup
latest
l
--all
-a
--cleanup
--latest
-l
"
_complete_ "$options_with_args" "$boolean_options"
case "$cur" in
-*)
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
;;
*)
__podman_complete_pod_names
;;
esac
}

_podman_pod_pause() {
local options_with_args="
"

local boolean_options="
--all
-a
--latest
-l
"
_complete_ "$options_with_args" "$boolean_options"
case "$cur" in
-*)
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
;;
*)
__podman_complete_pod_names
;;
esac
}

_podman_pod_unpause() {
local options_with_args="
"

local boolean_options="
--all
-a
--latest
-l
"
_complete_ "$options_with_args" "$boolean_options"
case "$cur" in
Expand All @@ -2244,6 +2286,8 @@ _podman_pod() {
rm
start
stop
pause
unpause
"
local aliases="
list
Expand Down
32 changes: 32 additions & 0 deletions docs/podman-pod-pause.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
% podman-pod-pause "1"

## NAME
podman\-pod\-pause - Pause one or more pods

## SYNOPSIS
**podman pod pause** [*options*] *pod* ...

## DESCRIPTION
Pauses all the running processes in the containers of one or more pods. You may use pod IDs or names as input.

## OPTIONS

**--all, a**

Pause all pods.

**--latest, -l**

Instead of providing the pod name or ID, pause the last created pod.

## EXAMPLE

podman pod pause mywebserverpod

podman pod pause 860a4b23

## SEE ALSO
podman-pod(1), podman-pod-unpause(1), podman-pause(1)

## HISTORY
July 2018, Originally compiled by Peter Hunt <pehunt@redhat.com>
32 changes: 32 additions & 0 deletions docs/podman-pod-unpause.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
% podman-pod-unpause "1"

## NAME
podman\-pod\-unpause - Unpause one or more pods

## SYNOPSIS
**podman pod unpause** [*options*] *pod* ...

## DESCRIPTION
Unpauses all the paused processes in the containers of one or more pods. You may use pod IDs or names as input.

## OPTIONS

**--all, a**

Unpause all pods.

**--latest, -l**

Instead of providing the pod name or ID, unpause the last created pod.

## EXAMPLE

podman pod unpause mywebserverpod

podman pod unpause 860a4b23

## SEE ALSO
podman-pod(1), podman-pod-pause(1), podman-unpause(1)

## HISTORY
July 2018, Originally compiled by Peter Hunt <pehunt@redhat.com>
2 changes: 2 additions & 0 deletions docs/podman-pod.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ podman pod is a set of subcommands that manage pods, or groups of containers.
| ------------------------------------------------- | ------------------------------------------------------------------------------ |
| [podman-pod-create(1)](podman-pod-create.1.md) | Create a new pod. |
| [podman-pod-kill(1)](podman-pod-kill.1.md) | Kill the main process of each container in pod. |
| [podman-pod-pause(1)](podman-pod-pause.1.md) | Pause one or more pods. |
| [podman-pod-ps(1)](podman-pod-ps.1.md) | Prints out information about pods. |
| [podman-pod-rm(1)](podman-pod-rm.1.md) | Remove one or more pods. |
| [podman-pod-start(1)](podman-pod-start.1.md) | Start one or more pods. |
| [podman-pod-stop(1)](podman-pod-stop.1.md) | Stop one or more pods. |
| [podman-pod-unpause(1)](podman-pod-unpause.1.md) | Unpause one or more pods. |

## HISTORY
July 2018, Originally compiled by Peter Hunt <pehunt@redhat.com>
Loading