-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsystem.go
72 lines (60 loc) · 1.65 KB
/
system.go
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
65
66
67
68
69
70
71
72
package machina
import "github.com/gentlemanautomaton/machina/summary"
// System holds configuration for the virtual machine host system.
type System struct {
// Processor defines processors available on the host system.
Processor ProcessorMap `json:"processor,omitempty"`
// Storage defines storage pools available on the host system.
Storage StorageMap `json:"storage,omitempty"`
// Network defines network pools available on the host system.
Network NetworkMap `json:"network,omitempty"`
// MediatedDevices is a list of mediated devices available on the host
// system.
MediatedDevices MediatedDeviceMap `json:"mdev,omitempty"`
// Tag defines tags available on the host system.
Tag TagMap `json:"tag,omitempty"`
}
// Summary returns a multiline string summarizing the system configuration.
func (sys System) Summary() string {
var out summary.Builder
out.Descend()
if len(sys.Storage) > 0 {
out.Add("Storage:")
out.Descend()
for name, store := range sys.Storage {
out.Add("%s: %s", name, store.Path)
}
out.Ascend()
}
if len(sys.Network) > 0 {
out.Add("Networks:")
out.Descend()
for name, network := range sys.Network {
out.Add("%s: %s", name, network)
}
out.Ascend()
}
if len(sys.MediatedDevices) > 0 {
out.Add("Mediated Devices:")
out.Descend()
for name, device := range sys.MediatedDevices {
out.Add("%s:", name)
out.Descend()
device.Config(&out)
out.Ascend()
}
out.Ascend()
}
if len(sys.Tag) > 0 {
out.Add("Tags:")
out.Descend()
for tag, def := range sys.Tag {
out.Add("%s:", tag)
out.Descend()
def.Config(MachineInfo{}, &out)
out.Ascend()
}
out.Ascend()
}
return out.String()
}