diff options
author | Anders F Björklund <anders.f.bjorklund@gmail.com> | 2021-09-22 12:29:24 +0200 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2021-09-29 16:39:29 -0400 |
commit | 2c5382ba981217ef751649302ad15ecd493a6e90 (patch) | |
tree | e909eecca3d4c91d6d162960d10b7b1155eee5f3 | |
parent | 57c055f61a96fa49f8a8709297da5e81597e4b48 (diff) | |
download | podman-2c5382ba981217ef751649302ad15ecd493a6e90.tar.gz podman-2c5382ba981217ef751649302ad15ecd493a6e90.tar.bz2 podman-2c5382ba981217ef751649302ad15ecd493a6e90.zip |
Show cpus and memory in machine list
[NO TESTS NEEDED]
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
-rw-r--r-- | cmd/podman/machine/list.go | 8 | ||||
-rw-r--r-- | pkg/machine/config.go | 2 | ||||
-rw-r--r-- | pkg/machine/qemu/machine.go | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index d4360bb9b..b9dc62d6d 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -44,6 +44,8 @@ type machineReporter struct { Created string LastUp string VMType string + CPUs uint64 + Memory string } func init() { @@ -54,7 +56,7 @@ func init() { flags := lsCmd.Flags() formatFlagName := "format" - flags.StringVar(&listFlag.format, formatFlagName, "{{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\n", "Format volume output using Go template") + flags.StringVar(&listFlag.format, formatFlagName, "{{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\t{{.CPUs}}\t{{.Memory}}\n", "Format volume output using Go template") _ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, completion.AutocompleteNone) flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers") } @@ -87,6 +89,8 @@ func outputTemplate(cmd *cobra.Command, responses []*machineReporter) error { headers := report.Headers(machineReporter{}, map[string]string{ "LastUp": "LAST UP", "VmType": "VM TYPE", + "CPUs": "CPUS", + "Memory": "MEMORY", }) row := report.NormalizeFormat(listFlag.format) @@ -136,6 +140,8 @@ func toHumanFormat(vms []*machine.ListResponse) ([]*machineReporter, error) { } response.Created = units.HumanDuration(time.Since(vm.CreatedAt)) + " ago" response.VMType = vm.VMType + response.CPUs = vm.CPUs + response.Memory = units.HumanSize(float64(vm.Memory) * units.MiB) humanResponses = append(humanResponses, response) } diff --git a/pkg/machine/config.go b/pkg/machine/config.go index 8db2335aa..583eacbaa 100644 --- a/pkg/machine/config.go +++ b/pkg/machine/config.go @@ -58,6 +58,8 @@ type ListResponse struct { LastUp time.Time Running bool VMType string + CPUs uint64 + Memory uint64 } type SSHOptions struct { diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index b9b66c123..281a8b7a9 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -574,6 +574,8 @@ func GetVMInfos() ([]*machine.ListResponse, error) { listEntry.Name = vm.Name listEntry.VMType = "qemu" + listEntry.CPUs = vm.CPUs + listEntry.Memory = vm.Memory fi, err := os.Stat(fullPath) if err != nil { return err |