diff options
author | haircommander <pehunt@redhat.com> | 2018-08-14 13:24:21 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-16 20:31:50 +0000 |
commit | 0059989783851ec536faf8a290eea863148dcb6c (patch) | |
tree | cece1412a11936cd49f70fcb6fb7876f44e001b1 /pkg/varlinkapi/util.go | |
parent | edffded1fbecff2f22ec0a388789e8c2edab0153 (diff) | |
download | podman-0059989783851ec536faf8a290eea863148dcb6c.tar.gz podman-0059989783851ec536faf8a290eea863148dcb6c.tar.bz2 podman-0059989783851ec536faf8a290eea863148dcb6c.zip |
Add Pod API to varlink.
Including: GetPod, StartPod, StopPod, RestartPod, KillPod, PausePod, UnpausePod, CreatePod, RemovePod, and InspectPod
Signed-off-by: haircommander <pehunt@redhat.com>
Closes: #1275
Approved by: mheon
Diffstat (limited to 'pkg/varlinkapi/util.go')
-rw-r--r-- | pkg/varlinkapi/util.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/varlinkapi/util.go b/pkg/varlinkapi/util.go index b33e43f96..74afabd0f 100644 --- a/pkg/varlinkapi/util.go +++ b/pkg/varlinkapi/util.go @@ -77,3 +77,43 @@ func makeListContainer(containerID string, batchInfo batchcontainer.BatchContain } return lc } + +func makeListPodContainers(containerID string, batchInfo batchcontainer.BatchContainerStruct) iopodman.ListPodContainerInfo { + lc := iopodman.ListPodContainerInfo{ + Id: containerID, + Status: batchInfo.ConState.String(), + Name: batchInfo.ConConfig.Name, + } + return lc +} + +func makeListPod(pod *libpod.Pod, batchInfo batchcontainer.PsOptions) (iopodman.ListPodData, error) { + var listPodsContainers []iopodman.ListPodContainerInfo + var errPodData = iopodman.ListPodData{} + status, err := pod.Status() + if err != nil { + return errPodData, err + } + containers, err := pod.AllContainers() + if err != nil { + return errPodData, err + } + for _, ctr := range containers { + batchInfo, err := batchcontainer.BatchContainerOp(ctr, batchInfo) + if err != nil { + return errPodData, err + } + + listPodsContainers = append(listPodsContainers, makeListPodContainers(ctr.ID(), batchInfo)) + } + listPod := iopodman.ListPodData{ + Createdat: pod.CreatedTime().String(), + Id: pod.ID(), + Name: pod.Name(), + Status: status, + Cgroup: pod.CgroupParent(), + Numberofcontainers: strconv.Itoa(len(listPodsContainers)), + Containersinfo: listPodsContainers, + } + return listPod, nil +} |