summaryrefslogtreecommitdiff
path: root/libpod/runtime_ctr.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2017-12-04 15:06:06 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-13 21:15:09 +0000
commit9cc0c8ae143070c4d4ee691cab6a0fd0ebcaa538 (patch)
tree9736c47af7246c93e2e2b6d6d246653ca57cc316 /libpod/runtime_ctr.go
parent61f606e192ad67b4819a909a6f1b18c41e33db2d (diff)
downloadpodman-9cc0c8ae143070c4d4ee691cab6a0fd0ebcaa538.tar.gz
podman-9cc0c8ae143070c4d4ee691cab6a0fd0ebcaa538.tar.bz2
podman-9cc0c8ae143070c4d4ee691cab6a0fd0ebcaa538.zip
kpod stats
Move kpod stats to the libpod backend. Signed-off-by: baude <bbaude@redhat.com> Closes: #113 Approved by: baude
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r--libpod/runtime_ctr.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index f314b302f..320821b38 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -232,3 +232,31 @@ func (r *Runtime) GetContainers(filters ...ContainerFilter) ([]*Container, error
return ctrsFiltered, nil
}
+
+// GetAllContainers is a helper function for GetContainers
+func (r *Runtime) GetAllContainers() ([]*Container, error) {
+ return r.state.AllContainers()
+}
+
+// GetRunningContainers is a helper function for GetContainers
+func (r *Runtime) GetRunningContainers() ([]*Container, error) {
+ running := func(c *Container) bool {
+ state, _ := c.State()
+ return state == ContainerStateRunning
+ }
+ return r.GetContainers(running)
+}
+
+// GetContainersByList is a helper function for GetContainers
+// which takes a []string of container IDs or names
+func (r *Runtime) GetContainersByList(containers []string) ([]*Container, error) {
+ var ctrs []*Container
+ for _, inputContainer := range containers {
+ ctr, err := r.LookupContainer(inputContainer)
+ if err != nil {
+ return ctrs, errors.Wrapf(err, "unable to lookup container %s", inputContainer)
+ }
+ ctrs = append(ctrs, ctr)
+ }
+ return ctrs, nil
+}