summaryrefslogtreecommitdiff
path: root/pkg/adapter/info_remote.go
blob: 549b01f549575b8654c7d009f27eace472b4c705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// +build remoteclient

package adapter

import (
	"github.com/containers/libpod/libpod/define"
	iopodman "github.com/containers/libpod/pkg/varlink"
)

// Info returns information for the host system and its components
func (r RemoteRuntime) Info() (*define.Info, error) {
	// TODO the varlink implementation for info should be updated to match the output for regular info
	var (
		reply define.Info
	)

	info, err := iopodman.GetInfo().Call(r.Conn)
	if err != nil {
		return nil, err
	}
	hostInfo := define.HostInfo{
		Arch:           info.Host.Arch,
		BuildahVersion: info.Host.Buildah_version,
		CPUs:           int(info.Host.Cpus),
		Distribution: define.DistributionInfo{
			Distribution: info.Host.Distribution.Distribution,
			Version:      info.Host.Distribution.Version,
		},
		EventLogger: info.Host.Eventlogger,
		Hostname:    info.Host.Hostname,
		Kernel:      info.Host.Kernel,
		MemFree:     info.Host.Mem_free,
		MemTotal:    info.Host.Mem_total,
		OS:          info.Host.Os,
		SwapFree:    info.Host.Swap_free,
		SwapTotal:   info.Host.Swap_total,
		Uptime:      info.Host.Uptime,
	}
	storeInfo := define.StoreInfo{
		ContainerStore: define.ContainerStore{
			Number: int(info.Store.Containers),
		},
		GraphDriverName: info.Store.Graph_driver_name,
		GraphRoot:       info.Store.Graph_root,
		ImageStore: define.ImageStore{
			Number: int(info.Store.Images),
		},
		RunRoot: info.Store.Run_root,
	}
	reply.Host = &hostInfo
	reply.Store = &storeInfo
	regs := make(map[string]interface{})
	if len(info.Registries.Search) > 0 {
		regs["search"] = info.Registries.Search
	}
	if len(info.Registries.Blocked) > 0 {
		regs["blocked"] = info.Registries.Blocked
	}
	if len(info.Registries.Insecure) > 0 {
		regs["insecure"] = info.Registries.Insecure
	}
	reply.Registries = regs
	return &reply, nil
}