diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2017-12-13 09:36:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 09:36:14 -0500 |
commit | e456c07813c5ccc6ccc81ad9a103e46e1b59b50c (patch) | |
tree | 06d6976ab80d77d19393f81344ef092fa9e51a3f /libpod/container_inspect.go | |
parent | cfb4e15e430e63b17420e80c0f6030a12fa1fb4a (diff) | |
parent | 74ee579375654c79fa710f13b7c2ee3810366f82 (diff) | |
download | podman-e456c07813c5ccc6ccc81ad9a103e46e1b59b50c.tar.gz podman-e456c07813c5ccc6ccc81ad9a103e46e1b59b50c.tar.bz2 podman-e456c07813c5ccc6ccc81ad9a103e46e1b59b50c.zip |
Merge pull request #106 from umohnani8/kpod_inspect
Update kpod inspect to use the new container state
Diffstat (limited to 'libpod/container_inspect.go')
-rw-r--r-- | libpod/container_inspect.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go new file mode 100644 index 000000000..5f29a231e --- /dev/null +++ b/libpod/container_inspect.go @@ -0,0 +1,70 @@ +package libpod + +import ( + "github.com/projectatomic/libpod/libpod/driver" + "github.com/sirupsen/logrus" +) + +func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) (*ContainerInspectData, error) { + config := c.config + runtimeInfo := c.state + spec := c.config.Spec + + args := config.Spec.Process.Args + var path string + if len(args) > 0 { + path = args[0] + } + if len(args) > 1 { + args = args[1:] + } + + data := &ContainerInspectData{ + ID: config.ID, + Created: config.CreatedTime, + Path: path, + Args: args, + State: &ContainerInspectState{ + OciVersion: spec.Version, + Status: runtimeInfo.State.String(), + Running: runtimeInfo.State == ContainerStateRunning, + Paused: runtimeInfo.State == ContainerStatePaused, + OOMKilled: runtimeInfo.OOMKilled, + Dead: runtimeInfo.State.String() == "bad state", + Pid: runtimeInfo.PID, + ExitCode: runtimeInfo.ExitCode, + Error: "", // can't get yet + StartedAt: runtimeInfo.StartedTime, + FinishedAt: runtimeInfo.FinishedTime, + }, + ImageID: config.RootfsImageID, + ImageName: config.RootfsImageName, + ResolvConfPath: "", // TODO get from networking path + HostnamePath: spec.Annotations["io.kubernetes.cri-o.HostnamePath"], // not sure + HostsPath: "", // can't get yet + StaticDir: config.StaticDir, + LogPath: c.LogPath(), + Name: config.Name, + Driver: driverData.Name, + MountLabel: config.MountLabel, + ProcessLabel: spec.Process.SelinuxLabel, + AppArmorProfile: spec.Process.ApparmorProfile, + ExecIDs: []string{}, //TODO + GraphDriver: driverData, + Mounts: spec.Mounts, + NetworkSettings: &NetworkSettings{}, // TODO from networking patch + } + if size { + rootFsSize, err := c.rootFsSize() + if err != nil { + logrus.Errorf("error getting rootfs size %q: %v", config.ID, err) + } + rwSize, err := c.rwSize() + if err != nil { + logrus.Errorf("error getting rw size %q: %v", config.ID, err) + } + data.SizeRootFs = rootFsSize + data.SizeRw = rwSize + } + return data, nil +} |