diff options
Diffstat (limited to 'cmd/podman/pod_ps.go')
-rw-r--r-- | cmd/podman/pod_ps.go | 64 |
1 files changed, 9 insertions, 55 deletions
diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go index 0f5c7a51d..20beae53a 100644 --- a/cmd/podman/pod_ps.go +++ b/cmd/podman/pod_ps.go @@ -7,13 +7,13 @@ import ( "strings" "time" + "github.com/containers/libpod/cmd/podman/formats" + "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/cmd/podman/shared" + "github.com/containers/libpod/libpod" + "github.com/containers/libpod/pkg/util" "github.com/docker/go-units" "github.com/pkg/errors" - "github.com/projectatomic/libpod/cmd/podman/batchcontainer" - "github.com/projectatomic/libpod/cmd/podman/formats" - "github.com/projectatomic/libpod/cmd/podman/libpodruntime" - "github.com/projectatomic/libpod/libpod" - "github.com/projectatomic/libpod/pkg/util" "github.com/urfave/cli" ) @@ -28,7 +28,7 @@ const ( ) var ( - bc_opts batchcontainer.PsOptions + bc_opts shared.PsOptions ) type podPsCtrInfo struct { @@ -324,7 +324,7 @@ func generatePodFilterFuncs(filter, filterValue string, runtime *libpod.Runtime) return nil, errors.Errorf("%s is not a valid pod status", filterValue) } return func(p *libpod.Pod) bool { - status, err := getPodStatus(p) + status, err := shared.GetPodStatus(p) if err != nil { return false } @@ -460,52 +460,6 @@ func getPodTemplateOutput(psParams []podPsJSONParams, opts podPsOptions) ([]podP return psOutput, nil } -func getPodStatus(pod *libpod.Pod) (string, error) { - ctr_statuses, err := pod.Status() - if err != nil { - return ERROR, err - } - ctrNum := len(ctr_statuses) - if ctrNum == 0 { - return CREATED, nil - } - statuses := map[string]int{ - STOPPED: 0, - RUNNING: 0, - PAUSED: 0, - CREATED: 0, - ERROR: 0, - } - for _, ctr_status := range ctr_statuses { - switch ctr_status { - case libpod.ContainerStateStopped: - statuses[STOPPED]++ - case libpod.ContainerStateRunning: - statuses[RUNNING]++ - case libpod.ContainerStatePaused: - statuses[PAUSED]++ - case libpod.ContainerStateCreated, libpod.ContainerStateConfigured: - statuses[CREATED]++ - default: - statuses[ERROR]++ - } - } - - if statuses[RUNNING] > 0 { - return RUNNING, nil - } else if statuses[PAUSED] == ctrNum { - return PAUSED, nil - } else if statuses[STOPPED] == ctrNum { - return EXITED, nil - } else if statuses[STOPPED] > 0 { - return STOPPED, nil - } else if statuses[ERROR] > 0 { - return ERROR, nil - } else { - return CREATED, nil - } -} - // getAndSortPodJSONOutput returns the container info in its raw, sorted form func getAndSortPodJSONParams(pods []*libpod.Pod, opts podPsOptions, runtime *libpod.Runtime) ([]podPsJSONParams, error) { var ( @@ -519,13 +473,13 @@ func getAndSortPodJSONParams(pods []*libpod.Pod, opts podPsOptions, runtime *lib return nil, err } ctrNum := len(ctrs) - status, err := getPodStatus(pod) + status, err := shared.GetPodStatus(pod) if err != nil { return nil, err } for _, ctr := range ctrs { - batchInfo, err := batchcontainer.BatchContainerOp(ctr, bc_opts) + batchInfo, err := shared.BatchContainerOp(ctr, bc_opts) if err != nil { return nil, err } |