Skip to content

Commit f6a077a

Browse files
committed
system/info: Show discovered devices
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent be03dc9 commit f6a077a

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

cli/command/system/info.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ func prettyPrintServerInfo(streams command.Streams, info *dockerInfo) []error {
281281
}
282282
}
283283

284+
if len(info.DiscoveredDevices) > 0 {
285+
fprintln(output, " Discovered Devices:")
286+
for _, device := range info.DiscoveredDevices {
287+
fprintf(output, " %s: %s\n", device.Source, device.ID)
288+
}
289+
}
290+
284291
fprintln(output, " Swarm:", info.Swarm.LocalNodeState)
285292
printSwarmInfo(output, *info.Info)
286293

cli/command/system/info_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ func TestPrettyPrintInfo(t *testing.T) {
260260
sampleInfoLabelsEmpty := sampleInfoNoSwarm
261261
sampleInfoLabelsEmpty.Labels = []string{}
262262

263+
sampleInfoWithDevices := sampleInfoNoSwarm
264+
sampleInfoWithDevices.DiscoveredDevices = []system.DeviceInfo{
265+
{Source: "cdi", ID: "com.example.device1"},
266+
{Source: "cdi", ID: "nvidia.com/gpu=gpu0"},
267+
}
268+
263269
for _, tc := range []struct {
264270
doc string
265271
dockerInfo dockerInfo
@@ -366,6 +372,14 @@ func TestPrettyPrintInfo(t *testing.T) {
366372
warningsGolden: "docker-info-badsec-stderr",
367373
expectedError: "errors pretty printing info",
368374
},
375+
{
376+
doc: "info with devices",
377+
dockerInfo: dockerInfo{
378+
Info: &sampleInfoWithDevices,
379+
},
380+
prettyGolden: "docker-info-with-devices",
381+
jsonGolden: "docker-info-with-devices",
382+
},
369383
} {
370384
t.Run(tc.doc, func(t *testing.T) {
371385
cli := test.NewFakeCli(&fakeClient{})
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Client:
2+
3+
Server:
4+
Containers: 0
5+
Running: 0
6+
Paused: 0
7+
Stopped: 0
8+
Images: 0
9+
Server Version: 17.06.1-ce
10+
Storage Driver: overlay2
11+
Backing Filesystem: extfs
12+
Supports d_type: true
13+
Using metacopy: false
14+
Native Overlay Diff: true
15+
Logging Driver: json-file
16+
Cgroup Driver: cgroupfs
17+
Plugins:
18+
Volume: local
19+
Network: bridge host macvlan null overlay
20+
Log: awslogs fluentd gcplogs gelf journald json-file splunk syslog
21+
CDI spec directories:
22+
/etc/cdi
23+
/var/run/cdi
24+
Discovered Devices:
25+
cdi: com.example.device1
26+
cdi: nvidia.com/gpu=gpu0
27+
Swarm: inactive
28+
Runtimes: runc
29+
Default Runtime: runc
30+
Init Binary: docker-init
31+
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
32+
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
33+
init version: 949e6fa
34+
Security Options:
35+
apparmor
36+
seccomp
37+
Profile: default
38+
Kernel Version: 4.4.0-87-generic
39+
Operating System: Ubuntu 16.04.3 LTS
40+
OSType: linux
41+
Architecture: x86_64
42+
CPUs: 2
43+
Total Memory: 1.953GiB
44+
Name: system-sample
45+
ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX
46+
Docker Root Dir: /var/lib/docker
47+
Debug Mode: true
48+
File Descriptors: 33
49+
Goroutines: 135
50+
System Time: 2017-08-24T17:44:34.077811894Z
51+
EventsListeners: 0
52+
Labels:
53+
provider=digitalocean
54+
Experimental: false
55+
Insecure Registries:
56+
127.0.0.0/8
57+
Live Restore Enabled: false
58+
Default Address Pools:
59+
Base: 10.123.0.0/16, Size: 24
60+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"overlay2","DriverStatus":[["Backing Filesystem","extfs"],["Supports d_type","true"],["Using metacopy","false"],["Native Overlay Diff","true"]],"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"PidsLimit":false,"IPv4Forwarding":true,"BridgeNfIptables":false,"BridgeNfIp6tables":false,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSVersion":"","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"IndexConfigs":{"docker.io":{"Mirrors":null,"Name":"docker.io","Official":true,"Secure":true}},"InsecureRegistryCIDRs":["127.0.0.0/8"],"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"DefaultAddressPools":[{"Base":"10.123.0.0/16","Size":24}],"CDISpecDirs":["/etc/cdi","/var/run/cdi"],"DiscoveredDevices":[{"Source":"cdi","ID":"com.example.device1"},{"Source":"cdi","ID":"nvidia.com/gpu=gpu0"}],"Warnings":null}

0 commit comments

Comments
 (0)