varlink info

The varlinfo info returns the same information as podman info but always includes
the so-called debug information.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #745
Approved by: baude
This commit is contained in:
baude 2018-05-10 13:41:23 -05:00 committed by Atomic Bot
parent f97de48be4
commit 834f1f641e
4 changed files with 1595 additions and 1252 deletions

91
API.md
View File

@ -33,6 +33,8 @@ in the [API.md](https://github.com/projectatomic/libpod/blob/master/API.md) file
[func ImportImage(source: string, reference: string, message: string, changes: []string) string](#ImportImage)
[func Info() PodmanInfo](#Info)
[func InspectContainer(name: string) string](#InspectContainer)
[func InspectImage(name: string) string](#InspectImage)
@ -94,10 +96,20 @@ in the [API.md](https://github.com/projectatomic/libpod/blob/master/API.md) file
[type ImageSearch](#ImageSearch)
[type InfoGraphStatus](#InfoGraphStatus)
[type InfoHost](#InfoHost)
[type InfoPodmanBinary](#InfoPodmanBinary)
[type InfoStore](#InfoStore)
[type ListContainerData](#ListContainerData)
[type NotImplemented](#NotImplemented)
[type PodmanInfo](#PodmanInfo)
[type StringResponse](#StringResponse)
[type Version](#Version)
@ -225,6 +237,12 @@ history is in the form of an array of ImageHistory structures. If the image can
method ImportImage(source: [string](https://godoc.org/builtin#string), reference: [string](https://godoc.org/builtin#string), message: [string](https://godoc.org/builtin#string), changes: [[]string](#[]string)) [string](https://godoc.org/builtin#string)</div>
ImportImage imports an image from a source (like tarball) into local storage. The image can have additional
descriptions added to it using the message and changes options. See also [ExportImage](ExportImage).
### <a name="Info"></a>func Info
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
method Info() [PodmanInfo](#PodmanInfo)</div>
Info returns a [PodmanInfo](#PodmanInfo) struct that describes podman and its host such as storage stats,
build information of Podman, and system-wide registries.
### <a name="InspectContainer"></a>func InspectContainer
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@ -555,6 +573,66 @@ is_automated [bool](https://godoc.org/builtin#bool)
name [string](https://godoc.org/builtin#string)
star_count [int](https://godoc.org/builtin#int)
### <a name="InfoGraphStatus"></a>type InfoGraphStatus
InfoGraphStatus describes the detailed status of the graphc
backing_filesystem [string](https://godoc.org/builtin#string)
native_overlay_diff [string](https://godoc.org/builtin#string)
supports_d_type [string](https://godoc.org/builtin#string)
### <a name="InfoHost"></a>type InfoHost
InfoHost describes the host stats portion of PodmanInfo
mem_free [int](https://godoc.org/builtin#int)
mem_total [int](https://godoc.org/builtin#int)
swap_free [int](https://godoc.org/builtin#int)
swap_total [int](https://godoc.org/builtin#int)
arch [string](https://godoc.org/builtin#string)
cpus [int](https://godoc.org/builtin#int)
hostname [string](https://godoc.org/builtin#string)
kernel [string](https://godoc.org/builtin#string)
os [string](https://godoc.org/builtin#string)
uptime [string](https://godoc.org/builtin#string)
### <a name="InfoPodmanBinary"></a>type InfoPodmanBinary
InfoPodman provides details on the podman binary
compiler [string](https://godoc.org/builtin#string)
go_version [string](https://godoc.org/builtin#string)
podman_version [string](https://godoc.org/builtin#string)
git_commit [string](https://godoc.org/builtin#string)
### <a name="InfoStore"></a>type InfoStore
InfoStore describes the host's storage informatoin
containers [int](https://godoc.org/builtin#int)
images [int](https://godoc.org/builtin#int)
graph_driver_name [string](https://godoc.org/builtin#string)
graph_driver_options [string](https://godoc.org/builtin#string)
graph_root [string](https://godoc.org/builtin#string)
graph_status [InfoGraphStatus](#InfoGraphStatus)
run_root [string](https://godoc.org/builtin#string)
### <a name="ListContainerData"></a>type ListContainerData
ListContainer is the returned struct for an individual container
@ -593,6 +671,19 @@ namespaces [ContainerNameSpace](#ContainerNameSpace)
comment [string](https://godoc.org/builtin#string)
### <a name="PodmanInfo"></a>type PodmanInfo
PodmanInfo describes the Podman host and build
host [InfoHost](#InfoHost)
registries [[]string](#[]string)
insecure_registries [[]string](#[]string)
store [InfoStore](#InfoStore)
podman [InfoPodmanBinary](#InfoPodmanBinary)
### <a name="StringResponse"></a>type StringResponse

View File

@ -124,6 +124,55 @@ type ContainerNameSpace (
ipc: string
)
# InfoHost describes the host stats portion of PodmanInfo
type InfoHost (
mem_free: int,
mem_total: int,
swap_free: int,
swap_total: int,
arch: string,
cpus: int,
hostname: string,
kernel: string,
os: string,
uptime: string
)
# InfoGraphStatus describes the detailed status of the graph
type InfoGraphStatus (
backing_filesystem: string,
native_overlay_diff: string,
supports_d_type: string
)
# InfoStore describes the host's storage informatoin
type InfoStore (
containers: int,
images: int,
graph_driver_name: string,
graph_driver_options: string,
graph_root: string,
graph_status: InfoGraphStatus,
run_root: string
)
# InfoPodman provides details on the podman binary
type InfoPodmanBinary (
compiler: string,
go_version: string,
podman_version: string,
git_commit: string
)
# PodmanInfo describes the Podman host and build
type PodmanInfo (
host: InfoHost,
registries: []string,
insecure_registries: []string,
store: InfoStore,
podman: InfoPodmanBinary
)
# Ping provides a response for developers to ensure their varlink setup is working.
# #### Example
# ~~~
@ -140,6 +189,9 @@ method Ping() -> (ping: StringResponse)
# system.
method GetVersion() -> (version: Version)
# GetInfo returns a [PodmanInfo](#PodmanInfo) struct that describes podman and its host such as storage stats,
# build information of Podman, and system-wide registries.
method GetInfo() -> (info: PodmanInfo)
# ListContainers returns a list of containers in no particular order. There are
# returned as an array of ListContainerData structs. See also [GetContainer](#GetContainer).

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,10 @@
package varlinkapi
import (
goruntime "runtime"
"strings"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/projectatomic/libpod/cmd/podman/varlink"
"github.com/projectatomic/libpod/libpod"
)
@ -28,3 +32,56 @@ func (i *LibpodAPI) Ping(call ioprojectatomicpodman.VarlinkCall) error {
Message: "OK",
})
}
// GetInfo returns details about the podman host and its stores
func (i *LibpodAPI) GetInfo(call ioprojectatomicpodman.VarlinkCall) error {
podmanInfo := ioprojectatomicpodman.PodmanInfo{}
runtime, err := libpodruntime.GetRuntime(i.Cli)
if err != nil {
return call.ReplyRuntimeError(err.Error())
}
info, err := runtime.Info()
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
host := info[0].Data
infoHost := ioprojectatomicpodman.InfoHost{
Mem_free: host["MemFree"].(int64),
Mem_total: host["MemTotal"].(int64),
Swap_free: host["SwapFree"].(int64),
Arch: host["arch"].(string),
Cpus: int64(host["cpus"].(int)),
Hostname: host["hostname"].(string),
Kernel: host["kernel"].(string),
Os: host["os"].(string),
Uptime: host["uptime"].(string),
}
podmanInfo.Host = infoHost
store := info[1].Data
pmaninfo := ioprojectatomicpodman.InfoPodmanBinary{
Compiler: goruntime.Compiler,
Go_version: goruntime.Version(),
// TODO : How are we going to get this here?
//Podman_version:
Git_commit: libpod.GitCommit,
}
graphStatus := ioprojectatomicpodman.InfoGraphStatus{
Backing_filesystem: store["GraphStatus"].(map[string]string)["Backing Filesystem"],
Native_overlay_diff: store["GraphStatus"].(map[string]string)["Native Overlay Diff"],
Supports_d_type: store["GraphStatus"].(map[string]string)["Supports d_type"],
}
infoStore := ioprojectatomicpodman.InfoStore{
Graph_driver_name: store["GraphDriverName"].(string),
Containers: int64(store["ContainerStore"].(map[string]interface{})["number"].(int)),
Images: int64(store["ImageStore"].(map[string]interface{})["number"].(int)),
Run_root: store["RunRoot"].(string),
Graph_root: store["GraphRoot"].(string),
Graph_driver_options: strings.Join(store["GraphOptions"].([]string), ", "),
Graph_status: graphStatus,
}
podmanInfo.Store = infoStore
podmanInfo.Podman = pmaninfo
return call.ReplyGetInfo(podmanInfo)
}