summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/pods.go
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-04-15 15:44:32 -0400
committerPeter Hunt <pehunt@redhat.com>2019-04-16 11:23:18 -0400
commit4319552cf89e72925a80c63f427e5ef0a6376046 (patch)
tree5a0e38e63a41fdafe7f5d08daf496a0d68341aae /pkg/varlinkapi/pods.go
parent0b34b4a59cf090a47a2a13cc4814954c497b3d49 (diff)
downloadpodman-4319552cf89e72925a80c63f427e5ef0a6376046.tar.gz
podman-4319552cf89e72925a80c63f427e5ef0a6376046.tar.bz2
podman-4319552cf89e72925a80c63f427e5ef0a6376046.zip
Added remote pod prune
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/pods.go')
-rw-r--r--pkg/varlinkapi/pods.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/varlinkapi/pods.go b/pkg/varlinkapi/pods.go
index ac8e24747..f34375bf5 100644
--- a/pkg/varlinkapi/pods.go
+++ b/pkg/varlinkapi/pods.go
@@ -101,6 +101,28 @@ func (i *LibpodAPI) GetPod(call iopodman.VarlinkCall, name string) error {
return call.ReplyGetPod(listPod)
}
+// GetPodsByStatus returns a slice of pods filtered by a libpod status
+func (i *LibpodAPI) GetPodsByStatus(call iopodman.VarlinkCall, statuses []string) error {
+ filterFuncs := func(p *libpod.Pod) bool {
+ state, _ := shared.GetPodStatus(p)
+ for _, status := range statuses {
+ if state == status {
+ return true
+ }
+ }
+ return false
+ }
+ filteredPods, err := i.Runtime.Pods(filterFuncs)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ podIDs := make([]string, 0, len(filteredPods))
+ for _, p := range filteredPods {
+ podIDs = append(podIDs, p.ID())
+ }
+ return call.ReplyGetPodsByStatus(podIDs)
+}
+
// InspectPod ...
func (i *LibpodAPI) InspectPod(call iopodman.VarlinkCall, name string) error {
pod, err := i.Runtime.LookupPod(name)