summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-01-12 05:39:27 -0500
committerGitHub <noreply@github.com>2022-01-12 05:39:27 -0500
commit8365d49a05eccbaad4a796470c2cf62083249997 (patch)
tree488fde1071d4ccdfa0bbb15a86359a293556ae8e
parent6945b37850d77944fc79a784af9e362cb0184234 (diff)
parent6e208c2226f856ed67d6ab807f3baf5bf9611135 (diff)
downloadpodman-8365d49a05eccbaad4a796470c2cf62083249997.tar.gz
podman-8365d49a05eccbaad4a796470c2cf62083249997.tar.bz2
podman-8365d49a05eccbaad4a796470c2cf62083249997.zip
Merge pull request #12819 from rhatdan/machine
add additional fields to podman machine ls --json
-rw-r--r--cmd/podman/machine/list.go26
-rw-r--r--docs/source/markdown/podman-machine-list.1.md3
-rw-r--r--pkg/machine/config.go21
-rw-r--r--pkg/machine/qemu/machine.go3
4 files changed, 34 insertions, 19 deletions
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go
index ed43b42df..3d8def0db 100644
--- a/cmd/podman/machine/list.go
+++ b/cmd/podman/machine/list.go
@@ -44,16 +44,19 @@ type listFlagType struct {
}
type machineReporter struct {
- Name string
- Default bool
- Created string
- Running bool
- LastUp string
- Stream string
- VMType string
- CPUs uint64
- Memory string
- DiskSize string
+ Name string
+ Default bool
+ Created string
+ Running bool
+ LastUp string
+ Stream string
+ VMType string
+ CPUs uint64
+ Memory string
+ DiskSize string
+ Port int
+ RemoteUsername string
+ IdentityPath string
}
func init() {
@@ -190,6 +193,9 @@ func toMachineFormat(vms []*machine.ListResponse) ([]*machineReporter, error) {
response.CPUs = vm.CPUs
response.Memory = strUint(vm.Memory)
response.DiskSize = strUint(vm.DiskSize)
+ response.Port = vm.Port
+ response.RemoteUsername = vm.RemoteUsername
+ response.IdentityPath = vm.IdentityPath
machineResponses = append(machineResponses, response)
}
diff --git a/docs/source/markdown/podman-machine-list.1.md b/docs/source/markdown/podman-machine-list.1.md
index b2596ac59..d68b8b1ca 100644
--- a/docs/source/markdown/podman-machine-list.1.md
+++ b/docs/source/markdown/podman-machine-list.1.md
@@ -37,6 +37,9 @@ Valid placeholders for the Go template are listed below:
| .Running | Is machine running |
| .Stream | Stream name |
| .VMType | VM type |
+| .Port | SSH Port to use to connect to VM|
+| .RemoteUsername | VM Username for rootless Podman |
+| .IdentityPath | Path to ssh identify file |
#### **--help**
diff --git a/pkg/machine/config.go b/pkg/machine/config.go
index 33a352898..27a7c1b1f 100644
--- a/pkg/machine/config.go
+++ b/pkg/machine/config.go
@@ -66,15 +66,18 @@ type Download struct {
type ListOptions struct{}
type ListResponse struct {
- Name string
- CreatedAt time.Time
- LastUp time.Time
- Running bool
- Stream string
- VMType string
- CPUs uint64
- Memory uint64
- DiskSize uint64
+ Name string
+ CreatedAt time.Time
+ LastUp time.Time
+ Running bool
+ Stream string
+ VMType string
+ CPUs uint64
+ Memory uint64
+ DiskSize uint64
+ Port int
+ RemoteUsername string
+ IdentityPath string
}
type SSHOptions struct {
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index f09107c71..a43d78665 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -696,6 +696,9 @@ func GetVMInfos() ([]*machine.ListResponse, error) {
listEntry.CPUs = vm.CPUs
listEntry.Memory = vm.Memory * units.MiB
listEntry.DiskSize = vm.DiskSize * units.GiB
+ listEntry.Port = vm.Port
+ listEntry.RemoteUsername = vm.RemoteUsername
+ listEntry.IdentityPath = vm.IdentityPath
fi, err := os.Stat(fullPath)
if err != nil {
return err