From 55e630e7876557ebd2a44e81fa357aab9efbb793 Mon Sep 17 00:00:00 2001
From: baude <bbaude@redhat.com>
Date: Mon, 15 Apr 2019 09:03:18 -0500
Subject: podman-remote pause|unpause

Add the ability to pause and unpause containers with the remote client.

Also turned on the pause tests!

Signed-off-by: baude <bbaude@redhat.com>
---
 pkg/varlinkapi/containers.go | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

(limited to 'pkg/varlinkapi')

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)
-- 
cgit v1.2.3-54-g00ecf