Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update govc jq examples with correct case #3238

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions govc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ System information including the name, type, version, and build number.

Examples:
govc about
govc about -json | jq -r .About.ProductLineId
govc about -json | jq -r .About.productLineId

Options:
-c=false Include client info
Expand Down Expand Up @@ -1425,9 +1425,9 @@ Device info for VM.
Examples:
govc device.info -vm $name
govc device.info -vm $name disk-*
govc device.info -vm $name -json disk-* | jq -r .Devices[].Backing.Uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].Backing.FileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].MacAddress
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress

Options:
-net= Network [GOVC_NETWORK]
Expand Down Expand Up @@ -3707,7 +3707,7 @@ Set license labels.
Examples:
govc license.label.set 00000-00000-00000-00000-00000 team cnx # add/set label
govc license.label.set 00000-00000-00000-00000-00000 team "" # remove label
govc license.ls -json | jq '.[] | select(.Labels[].Key == "team") | .LicenseKey'
govc license.ls -json | jq '.[] | select(.labels[].key == "team") | .licenseKey'

Options:
```
Expand Down Expand Up @@ -4668,7 +4668,7 @@ All SOAP sessions are listed by default. The '-S' flag will limit this list to t

Examples:
govc session.ls
govc session.ls -json | jq -r .CurrentSession.Key
govc session.ls -json | jq -r .currentSession.key

Options:
-S=false List current SOAP session
Expand Down Expand Up @@ -6183,7 +6183,7 @@ List IPs for VM.
By default the vm.ip command depends on vmware-tools to report the 'guest.ipAddress' field and will
wait until it has done so. This value can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.IpAddress
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.ipAddress

When given the '-a' flag, only IP addresses for which there is a corresponding virtual nic are listed.
If there are multiple nics, the listed addresses will be comma delimited. The '-a' flag depends on
Expand All @@ -6193,7 +6193,7 @@ by tools for which there is no virtual nic are not included, for example that of

These values can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.Net[].IpConfig.IpAddress[].IpAddress
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress

When given the '-n' flag, filters '-a' behavior to the nic specified by MAC address or device name.

Expand Down Expand Up @@ -6363,7 +6363,7 @@ By default, supported guest OS IDs and full name are listed.
Examples:
govc vm.option.info -cluster C0
govc vm.option.info -cluster C0 -dump ubuntu64Guest
govc vm.option.info -cluster C0 -json | jq .GuestOSDescriptor[].Id
govc vm.option.info -cluster C0 -json | jq .guestOSDescriptor[].id
govc vm.option.info -host my_hostname
govc vm.option.info -vm my_vm

Expand Down
2 changes: 1 addition & 1 deletion govc/about/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ System information including the name, type, version, and build number.

Examples:
govc about
govc about -json | jq -r .About.ProductLineId`
govc about -json | jq -r .About.productLineId`
}

func (cmd *about) Process(ctx context.Context) error {
Expand Down
6 changes: 3 additions & 3 deletions govc/device/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func (cmd *info) Description() string {
Examples:
govc device.info -vm $name
govc device.info -vm $name disk-*
govc device.info -vm $name -json disk-* | jq -r .Devices[].Backing.Uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].Backing.FileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].MacAddress`
govc device.info -vm $name -json disk-* | jq -r .Devices[].backing.uuid
govc device.info -vm $name -json 'disk-*' | jq -r .Devices[].backing.fileName # vmdk path
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].macAddress`
}

func match(p string, devices object.VirtualDeviceList) object.VirtualDeviceList {
Expand Down
22 changes: 11 additions & 11 deletions govc/emacs/govc.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: The govc developers
;; URL: https://github.com/vmware/govmomi/tree/main/govc/emacs
;; Keywords: convenience
;; Version: 0.18.0
;; Version: 0.31.0
;; Package-Requires: ((emacs "24.3") (dash "1.5.0") (s "1.9.0") (magit-popup "2.0.50") (json-mode "1.6.0"))

;; This file is NOT part of GNU Emacs.
Expand Down Expand Up @@ -1148,12 +1148,12 @@ Optionally filter by FILTER and inherit SESSION."
(defun govc-datastore-ls-entries ()
"Wrapper for govc datastore.ls."
(let* ((data (govc-json "datastore.ls" "-l" "-p" govc-filter))
(file (plist-get (elt data 0) :File)))
(file (plist-get (elt data 0) :file)))
(-map (lambda (ent)
(let ((name (plist-get ent :Path))
(size (plist-get ent :FileSize))
(time (plist-get ent :Modification))
(user (plist-get ent :Owner)))
(let ((name (plist-get ent :path))
(size (or (plist-get ent :fileSize) 0))
(time (plist-get ent :modification))
(user (plist-get ent :owner)))
(list (concat govc-filter name)
(vector (file-size-human-readable size)
(current-time-string (date-to-time time))
Expand Down Expand Up @@ -1507,13 +1507,13 @@ With prefix \\[universal-argument] ARG, launches an interactive console (VMRC)."
(info))
(mapc
(lambda (vm)
(let* ((config (plist-get vm :Config))
(name (plist-get config :Name)))
(let* ((config (plist-get vm :config))
(name (plist-get config :name)))
(mapc (lambda (x)
(let ((key (plist-get x :Key))
(val (plist-get x :Value)))
(let ((key (plist-get x :key))
(val (plist-get x :value)))
(push (list key (vector key val)) info)))
(plist-get config :ExtraConfig))
(plist-get config :extraConfig))
(if (> (length vms) 1)
(push (list name (vector "vm.name" name)) info))))
vms)
Expand Down
2 changes: 1 addition & 1 deletion govc/license/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (cmd *label) Description() string {
Examples:
govc license.label.set 00000-00000-00000-00000-00000 team cnx # add/set label
govc license.label.set 00000-00000-00000-00000-00000 team "" # remove label
govc license.ls -json | jq '.[] | select(.Labels[].Key == "team") | .LicenseKey'`
govc license.ls -json | jq '.[] | select(.labels[].key == "team") | .licenseKey'`
}

func (cmd *label) Run(ctx context.Context, f *flag.FlagSet) error {
Expand Down
2 changes: 1 addition & 1 deletion govc/session/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ All SOAP sessions are listed by default. The '-S' flag will limit this list to t

Examples:
govc session.ls
govc session.ls -json | jq -r .CurrentSession.Key`
govc session.ls -json | jq -r .currentSession.key`
}

func (cmd *ls) Process(ctx context.Context) error {
Expand Down
4 changes: 2 additions & 2 deletions govc/vm/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (cmd *ip) Description() string {
By default the vm.ip command depends on vmware-tools to report the 'guest.ipAddress' field and will
wait until it has done so. This value can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.IpAddress
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.ipAddress

When given the '-a' flag, only IP addresses for which there is a corresponding virtual nic are listed.
If there are multiple nics, the listed addresses will be comma delimited. The '-a' flag depends on
Expand All @@ -78,7 +78,7 @@ by tools for which there is no virtual nic are not included, for example that of

These values can also be obtained using:

govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.Net[].IpConfig.IpAddress[].IpAddress
govc vm.info -json $vm | jq -r .VirtualMachines[].guest.net[].ipConfig.ipAddress[].ipAddress

When given the '-n' flag, filters '-a' behavior to the nic specified by MAC address or device name.

Expand Down
2 changes: 1 addition & 1 deletion govc/vm/option/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ By default, supported guest OS IDs and full name are listed.
Examples:
govc vm.option.info -cluster C0
govc vm.option.info -cluster C0 -dump ubuntu64Guest
govc vm.option.info -cluster C0 -json | jq .GuestOSDescriptor[].Id
govc vm.option.info -cluster C0 -json | jq .guestOSDescriptor[].id
govc vm.option.info -host my_hostname
govc vm.option.info -vm my_vm`
}
Expand Down