summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-18 14:17:41 -0700
committerGitHub <noreply@github.com>2019-04-18 14:17:41 -0700
commite4947e5fd699f584cb815a4f4fd92f22b62f2c8a (patch)
tree525468fc942fcf473ad1df3722bbf05ea03f3c7b /pkg/varlinkapi
parent4d45f5180f778bf3a298bf061ca2c0dba0d4bfad (diff)
parent55e630e7876557ebd2a44e81fa357aab9efbb793 (diff)
downloadpodman-e4947e5fd699f584cb815a4f4fd92f22b62f2c8a.tar.gz
podman-e4947e5fd699f584cb815a4f4fd92f22b62f2c8a.tar.bz2
podman-e4947e5fd699f584cb815a4f4fd92f22b62f2c8a.zip
Merge pull request #2948 from baude/remotepause
podman-remote pause|unpause
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r--pkg/varlinkapi/containers.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go
index 17792ccfe..237407050 100644
--- a/pkg/varlinkapi/containers.go
+++ b/pkg/varlinkapi/containers.go
@@ -128,6 +128,37 @@ func (i *LibpodAPI) GetContainersByContext(call iopodman.VarlinkCall, all, lates
return call.ReplyGetContainersByContext(ids)
}
+// GetContainersByStatus returns a slice of containers filtered by a libpod status
+func (i *LibpodAPI) GetContainersByStatus(call iopodman.VarlinkCall, statuses []string) error {
+ var (
+ filterFuncs []libpod.ContainerFilter
+ containers []iopodman.Container
+ )
+ for _, status := range statuses {
+ lpstatus, err := libpod.StringToContainerStatus(status)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
+ state, _ := c.State()
+ return state == lpstatus
+ })
+ }
+ filteredContainers, err := i.Runtime.GetContainers(filterFuncs...)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ opts := shared.PsOptions{Size: true, Namespace: true}
+ for _, ctr := range filteredContainers {
+ batchInfo, err := shared.BatchContainerOp(ctr, opts)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ containers = append(containers, makeListContainer(ctr.ID(), batchInfo))
+ }
+ return call.ReplyGetContainersByStatus(containers)
+}
+
// InspectContainer ...
func (i *LibpodAPI) InspectContainer(call iopodman.VarlinkCall, name string) error {
ctr, err := i.Runtime.LookupContainer(name)