go.mod: update github.com/vmware/govmomi to v0.48.0

Needs manual change of import paths.
This commit is contained in:
Achilleas Koutsou 2025-01-31 18:26:22 +01:00 committed by Sanne Raymaekers
parent 3a6bea380e
commit bec893e37c
170 changed files with 7474 additions and 1604 deletions

2
go.mod
View file

@ -53,7 +53,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.10.0
github.com/ubccr/kerby v0.0.0-20230802201021-412be7bfaee5
github.com/vmware/govmomi v0.42.0
github.com/vmware/govmomi v0.48.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/oauth2 v0.25.0
golang.org/x/sync v0.10.0

4
go.sum
View file

@ -656,8 +656,8 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/vbauerster/mpb/v8 v8.7.5 h1:hUF3zaNsuaBBwzEFoCvfuX3cpesQXZC0Phm/JcHZQ+c=
github.com/vbauerster/mpb/v8 v8.7.5/go.mod h1:bRCnR7K+mj5WXKsy0NWB6Or+wctYGvVwKn6huwvxKa0=
github.com/vmware/govmomi v0.42.0 h1:MbvAlVfjNBE1mHMaQ7yOSop1KLB0/93x6VAGuCtjqtI=
github.com/vmware/govmomi v0.42.0/go.mod h1:1H5LWwsBif8HKZqbFp0FdoKTHyJE4FzL6ACequMKYQg=
github.com/vmware/govmomi v0.48.0 h1:CP5bCvkDNGkmn29UlcJKTWMLwDg3iusP8anrZnedWrg=
github.com/vmware/govmomi v0.48.0/go.mod h1:bYwUHpGpisE4AOlDl5eph90T+cjJMIcKx/kaa5v5rQM=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=

View file

@ -11,11 +11,11 @@ import (
"strings"
// importing the packages registers these cli commands
"github.com/vmware/govmomi/govc/cli"
_ "github.com/vmware/govmomi/govc/datastore"
_ "github.com/vmware/govmomi/govc/importx"
_ "github.com/vmware/govmomi/govc/vm"
_ "github.com/vmware/govmomi/govc/vm/guest"
"github.com/vmware/govmomi/cli"
_ "github.com/vmware/govmomi/cli/datastore"
_ "github.com/vmware/govmomi/cli/importx"
_ "github.com/vmware/govmomi/cli/vm"
_ "github.com/vmware/govmomi/cli/vm/guest"
)
const WaitTimeout = 6000 // in seconds

View file

@ -3,8 +3,8 @@ package vmware
import (
"fmt"
"github.com/vmware/govmomi/govc/cli"
_ "github.com/vmware/govmomi/govc/importx"
"github.com/vmware/govmomi/cli"
_ "github.com/vmware/govmomi/cli/importx"
)
type Credentials struct {

View file

@ -17,8 +17,9 @@ builds:
- s390x
env:
- CGO_ENABLED=0
- PKGPATH=github.com/vmware/govmomi/govc/flags
main: ./govc/main.go
- PKGPATH=github.com/vmware/govmomi/cli/flags
dir: ./govc
main: .
binary: govc
ldflags:
- "-X {{.Env.PKGPATH}}.BuildVersion={{.Version}} -X {{.Env.PKGPATH}}.BuildCommit={{.ShortCommit}} -X {{.Env.PKGPATH}}.BuildDate={{.Date}}"
@ -28,7 +29,8 @@ builds:
goarch: *goarch-defs
env:
- CGO_ENABLED=0
main: ./vcsim/main.go
dir: ./vcsim
main: .
binary: vcsim
ldflags:
- "-X main.buildVersion={{.Version}} -X main.buildCommit={{.ShortCommit}} -X main.buildDate={{.Date}}"
@ -90,49 +92,6 @@ changelog:
- Merge pull request
- Merge branch
# upload disabled since it is maintained in homebrew-core
brews:
- name: govc
ids:
- govcbuild
repository:
owner: govmomi
name: homebrew-tap
# TODO: create token in specified tap repo, add as secret to govmomi repo and reference in release workflow
# token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
# enable once we do fully automated releases
skip_upload: true
commit_author:
name: Alfred the Narwhal
email: cna-alfred@vmware.com
directory: Formula
homepage: "https://github.com/vmware/govmomi/blob/main/govc/README.md"
description: "govc is a vSphere CLI built on top of govmomi."
test: |
system "#{bin}/govc version"
install: |
bin.install "govc"
- name: vcsim
ids:
- vcsimbuild
repository:
owner: govmomi
name: homebrew-tap
# TODO: create token in specified tap repo, add as secret to govmomi repo and reference in release workflow
# token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
# enable once we do fully automated releases
skip_upload: true
commit_author:
name: Alfred the Narwhal
email: cna-alfred@vmware.com
directory: Formula
homepage: "https://github.com/vmware/govmomi/blob/main/vcsim/README.md"
description: "vcsim is a vSphere API simulator built on top of govmomi."
test: |
system "#{bin}/vcsim -h"
install: |
bin.install "vcsim"
dockers:
- image_templates:
- "vmware/govc:{{ .Tag }}"

View file

@ -57,3 +57,9 @@ Yun Zhou <yunz@vmware.com> <41678287+gh05tn0va@users.noreply.github.com>
Zach G <zguan@vmware.com> zach96guan <zach96guan@users.noreply.github.com>
Zach Tucker <ztucker@vmware.com> <jzt@users.noreply.github.com>
Zee Yang <zeey@vmware.com> <zee.yang@gmail.com>
Arunesh Pandey <parunesh@vmware.com> Arunesh Pandey <aruneshpa@gmail.com>
Eric Cao <ecao@vmware.com> Eric Cao <32748317+ericvmw@users.noreply.github.com>
Eric Cao <ecao@vmware.com> Eric Cao <eric.cao@broadcom.com>
Ryan Johnson <johnsonryan@vmware.com> Ryan Johnson <ryan.johnson@broadcom.com>
Stoyan Zhelyazkov <stoyan.zhelyazkov@broadcom.com> Stoyan Zhelyazkov <156204153+spacegospod@users.noreply.github.com>
Yanlei Zhao <yanleizhao@vmware.com> Yanlei Zhao <136122252+yanleizhao-vmware@users.noreply.github.com>

View file

@ -1,4 +1,559 @@
<a name="v0.43.0"></a>
## [Release v0.43.0](https://github.com/vmware/govmomi/compare/v0.42.0...v0.43.0)
> Release Date: 2024-09-10
### 🐞 Fix
- [97aa7214] vcsim: avoid possible race when encoding PropertyCollector response
- [ad2d3573] use complete InventoryPath in Datacenter.Folders
### 💫 API Changes
- [476704a3] Fault helpers
- [caad54aa] add VirtualMachine.AddDeviceWithProfile method
- [a316da5c] VirtualMachine.AttachDisk unitNumber param is optional
- [8491321a] ToString for vim types
- [64610213] add namespace.RegisterVM binding
- [e602029e] Fix panic when encoding nil iface ptrs to JSON
### 💫 `govc` (CLI)
- [8fd86912] add disk.create '-profile' flag
- [ea3cf257] add vm.disk.create '-profile' flag
- [e73c34fa] add vm.disk.attach '-profile' flag
- [06dcf31a] Add '-size' flag to datastore.create
- [23390c23] add namespace.registervm command
- [1892eecd] Support thick/eager disk opts on vm.create
### 💫 `vcsim` (Simulator)
- [8421b678] Support PlaceVm with relocate placement type
- [9234233e] Support PlaceVm with reconfigure placement type
- [f06d0834] add VirtualMachine AttachDisk and DetachDisk methods
- [35dc193f] Support VM crypto spec in vC Sim
- [0517b87e] add namespace/registervm implementation
### 🧹 Chore
- [b17abb20] Update version.go for v0.43.0
- [93da4a20] sync generated govc/USAGE.md
- [51105db8] govc: add common StorageProfileFlag
### ⚠️ BREAKING
VirtualMachine.AttachDisk unitNumber param is optional [a316da5c]:
switching from int32 to *int32, otherwise the client must choose a valid unitNumber.
vCenter will choose a unitNumber when not provided.
### 📖 Commits
- [b17abb20] chore: Update version.go for v0.43.0
- [476704a3] api: Fault helpers
- [8421b678] vcsim: Support PlaceVm with relocate placement type
- [93b97e18] Update library state info to content library API
- [9234233e] vcsim: Support PlaceVm with reconfigure placement type
- [a2cbe108] build(deps): bump golang.org/x/text from 0.17.0 to 0.18.0
- [93da4a20] chore: sync generated govc/USAGE.md
- [8fd86912] govc: add disk.create '-profile' flag
- [ea3cf257] govc: add vm.disk.create '-profile' flag
- [e73c34fa] govc: add vm.disk.attach '-profile' flag
- [51105db8] chore: govc: add common StorageProfileFlag
- [caad54aa] api: add VirtualMachine.AddDeviceWithProfile method
- [f06d0834] vcsim: add VirtualMachine AttachDisk and DetachDisk methods
- [97aa7214] fix: vcsim: avoid possible race when encoding PropertyCollector response
- [014a150b] build(deps): bump peter-evans/create-pull-request from 6 to 7
- [35dc193f] vcsim: Support VM crypto spec in vC Sim
- [a56e33d3] Add BackingDiskPath to BackingObjectDetails
- [06dcf31a] govc: Add '-size' flag to datastore.create
- [f881d9b6] govc add disk.attach and disk.detach commands
- [a316da5c] api: VirtualMachine.AttachDisk unitNumber param is optional
- [8491321a] api: ToString for vim types
- [0517b87e] vcsim: add namespace/registervm implementation
- [23390c23] govc: add namespace.registervm command
- [64610213] api: add namespace.RegisterVM binding
- [e602029e] api: Fix panic when encoding nil iface ptrs to JSON
- [1892eecd] govc: Support thick/eager disk opts on vm.create
- [ad2d3573] fix: use complete InventoryPath in Datacenter.Folders
<a name="v0.42.0"></a>
## [Release v0.42.0](https://github.com/vmware/govmomi/compare/v0.41.0...v0.42.0)
> Release Date: 2024-08-16
### 💫 API Changes
- [3fd16f78] update eam bindings to include authentication schema with eam-vcenter build 24075398 Closes: 3521
### 🧹 Chore
- [7a7c0646] Update version.go for v0.42.0
### ⚠️ BREAKING
### 📖 Commits
- [7a7c0646] chore: Update version.go for v0.42.0
- [3fd16f78] api: update eam bindings to include authentication schema with eam-vcenter build 24075398 Closes: 3521
<a name="v0.41.0"></a>
## [Release v0.41.0](https://github.com/vmware/govmomi/compare/v0.40.0...v0.41.0)
> Release Date: 2024-08-16
### 💫 API Changes
- [5a036494] OptionValues IsTrue|IsFalse
### 🧹 Chore
- [a6cdbd4c] Update version.go for v0.41.0
### ⚠️ BREAKING
### 📖 Commits
- [a6cdbd4c] chore: Update version.go for v0.41.0
- [5a036494] api: OptionValues IsTrue|IsFalse
<a name="v0.40.0"></a>
## [Release v0.40.0](https://github.com/vmware/govmomi/compare/v0.39.0...v0.40.0)
> Release Date: 2024-08-12
### 🐞 Fix
- [15d5ffdb] govc object.collect truncation
- [18e43541] govc: output Message field for 'EventEx' types
- [11dc5a39] restore govc import.spec DiskProvisioning default value
### 💡 Examples
- [eea1d299] add ExampleCollector_WaitForUpdatesEx_pagination
### 💫 API Changes
- [d035dc72] add session.Manager.ImpersonateUser method
- [ea3e806f] add alarm package with helpers for AlarmManager and Alarms
- [208d532c] convert vSAN directory name to uuid in ResolveLibraryItemStorage
### 💫 `govc` (CLI)
- [0917e718] add session.login '-as' flag to impersonate user
- [d6a3b614] add alarm commands
- [2975ade1] add event.post command
- [db6e9623] add library.sync '-f' flag to force sync file content
- [cc02310c] add library.info -S flag
### 💫 `vcsim` (Simulator)
- [ee966a69] add SessionManager.ImpersonateUser method
- [5a501b50] implement WaitForUpdatesEx pagination support
- [9c282108] add AlarmManager
- [db40be6b] fix panic in CancelTask
- [e63f1272] add ovf DiskProvisioning validation
- [0633de5c] add DatastoreNamespaceManager
### 🧹 Chore
- [6e27ff34] Update version.go for v0.40.0
### ⚠️ BREAKING
### 📖 Commits
- [6e27ff34] chore: Update version.go for v0.40.0
- [eea1d299] examples: add ExampleCollector_WaitForUpdatesEx_pagination
- [ee966a69] vcsim: add SessionManager.ImpersonateUser method
- [0917e718] govc: add session.login '-as' flag to impersonate user
- [d035dc72] api: add session.Manager.ImpersonateUser method
- [15d5ffdb] fix: govc object.collect truncation
- [5a501b50] vcsim: implement WaitForUpdatesEx pagination support
- [9c282108] vcsim: add AlarmManager
- [d6a3b614] govc: add alarm commands
- [ea3e806f] api: add alarm package with helpers for AlarmManager and Alarms
- [2975ade1] govc: add event.post command
- [18e43541] fix: govc: output Message field for 'EventEx' types
- [6f998780] build(deps): bump golang.org/x/text from 0.16.0 to 0.17.0
- [db40be6b] vcsim: fix panic in CancelTask
- [db6e9623] govc: add library.sync '-f' flag to force sync file content
- [11dc5a39] fix: restore govc import.spec DiskProvisioning default value
- [e63f1272] vcsim: add ovf DiskProvisioning validation
- [208d532c] api: convert vSAN directory name to uuid in ResolveLibraryItemStorage
- [0633de5c] vcsim: add DatastoreNamespaceManager
- [cc02310c] govc: add library.info -S flag
- [0d6a605c] review feedback
- [2957bedf] review feedback
- [8e509dfb] implement capacityAllocationUnits parser
<a name="v0.39.0"></a>
## [Release v0.39.0](https://github.com/vmware/govmomi/compare/v0.38.0...v0.39.0)
> Release Date: 2024-07-22
### 🐞 Fix
- [1bc3a4a4] handle base types by default in mo.LoadObjectContent
### 💫 API Changes
- [5c0af375] use CheckTestType in compat and provisioning checkers
- [2e77836c] add sata controller
- [bdb034ee] Exporting Unit field in MetricSeries struct for external use
- [78f07c63] Add simulator test for GetVirtualDiskInfoByUUID
- [2d16e19f] GetVirtualDiskInfoByUUID for getting capacity/size info
- [29b1bce9] change CoresPerNumaNode to a pointer type
- [3139de32] Add a method for extending VMDK
- [6096c0d4] add ResolveLibraryItemStorage
### 💫 `govc` (CLI)
- [04fe4c26] add vm.check commands
- [976bca3b] add '-spec' flag to vm clone, migrate and create commands
- [d92015c4] add vm.migrate -net flag
### 💫 `vcsim` (Simulator)
- [eb2e1ea1] add VmCompatibilityChecker and VmProvisioningChecker
- [a463e543] Add support for DRS automation levels
- [f7a85a81] Re-enable TenantManager
### 🧹 Chore
- [590c92b1] Update version.go for v0.39.0
- [4434e26b] bump go version
- [d7e27099] fix codeql ([#3492](https://github.com/vmware/govmomi/issues/3492))
- [fb6e5977] fix codeql
### ⚠️ BREAKING
### 📖 Commits
- [590c92b1] chore: Update version.go for v0.39.0
- [5c0af375] api: use CheckTestType in compat and provisioning checkers
- [2e77836c] api: add sata controller
- [bdb034ee] api: Exporting Unit field in MetricSeries struct for external use
- [4434e26b] chore: bump go version
- [04fe4c26] govc: add vm.check commands
- [976bca3b] govc: add '-spec' flag to vm clone, migrate and create commands
- [d92015c4] govc: add vm.migrate -net flag
- [eb2e1ea1] vcsim: add VmCompatibilityChecker and VmProvisioningChecker
- [12467b00] refactor: make importing templates available as a lib
- [d7e27099] chore: fix codeql ([#3492](https://github.com/vmware/govmomi/issues/3492))
- [fb6e5977] chore: fix codeql
- [a463e543] vcsim: Add support for DRS automation levels
- [78f07c63] api: Add simulator test for GetVirtualDiskInfoByUUID
- [2d16e19f] api: GetVirtualDiskInfoByUUID for getting capacity/size info
- [29b1bce9] api: change CoresPerNumaNode to a pointer type
- [3139de32] api: Add a method for extending VMDK
- [6096c0d4] api: add ResolveLibraryItemStorage
- [1bc3a4a4] fix: handle base types by default in mo.LoadObjectContent
- [f7a85a81] vcsim: Re-enable TenantManager
<a name="v0.38.0"></a>
## [Release v0.38.0](https://github.com/vmware/govmomi/compare/v0.37.3...v0.38.0)
> Release Date: 2024-06-24
### 🐞 Fix
- [22607cd8] xml marshal byte array fields as vCenter does
- [298cfbf3] govc vm.disk.change should only modify CapacityInBytes
### 💫 API Changes
- [0de9553a] EnsureDisksHaveControllers helper
- [3d70ab5c] OptionValueList helper
- [d80136a5] add storage_specs field to Namespace related structures
- [748043cd] add pbm.DatastoreMap for finding compatible Datastores
- [fc2a6b12] HardwareVersion.IsSupported vs IsValid
- [a68c21f2] Add library item storage APIs
- [7d1be3e7] Update ConfigInfoToConfigSpec
- [12ab4099] Update generated types
- [45aa2e92] add checksum validation in Content Library update session file API
- [7a00a0b4] Generate enum consts with Values funcs
- [f2852e39] add SSLCertificate to TransferEndpoint in content library API
### 💫 `govc` (CLI)
- [c3c5ffba] add vsan.info -file-service-enabled flag
- [a916df4e] add host.tpm.info and host.tpm.report commands
- [7f0c9f0c] add host.cert.info -show flag
- [ae316d65] add storage.policy.create zonal option
- [3e648db2] add '-storage' flag to namespace.create and namespace.update commands
- [e7d54f90] add vm.create '-profile' and '-place' flags
- [5677b0e5] Add feature to pass fullname and org for windows vm customization
### 💫 `vcsim` (Simulator)
- [e9f4cb73] add vSAN FileServiceConfig support
- [072011c6] add HostCertificateManager
- [a0bbbf3f] add library item storage API support
- [3b7ff25f] add PropertyCollector index support
- [651f7d27] fix: ignore unknown refs in Datacenter.PowerOnMultiVM
- [7251db75] Add PbmCheckCompatibility method in pbm simulator
- [542398a2] add HostVirtualNicManager
- [0be5fec8] fix ReconfigVM validation when changing disk size
### 🧹 Chore
- [51648874] Update version.go for v0.38.0
- [43510fbc] make doc
- [36631314] govc: use generated enum lists
### ⚠️ BREAKING
HardwareVersion.IsSupported vs IsValid [fc2a6b12]:
HardwareVersion.IsValid is more relaxed, consider IsSupported
* HardwareVersion.IsValid returns true if the specified value
matches a VMX version format.
* HardwareVersion.IsSupported behaves how IsValid used to behave.
### 📖 Commits
- [51648874] chore: Update version.go for v0.38.0
- [c3c5ffba] govc: add vsan.info -file-service-enabled flag
- [e9f4cb73] vcsim: add vSAN FileServiceConfig support
- [43510fbc] chore: make doc
- [a916df4e] govc: add host.tpm.info and host.tpm.report commands
- [072011c6] vcsim: add HostCertificateManager
- [7f0c9f0c] govc: add host.cert.info -show flag
- [22607cd8] fix: xml marshal byte array fields as vCenter does
- [ae316d65] govc: add storage.policy.create zonal option
- [0de9553a] api: EnsureDisksHaveControllers helper
- [3d70ab5c] api: OptionValueList helper
- [3e648db2] govc: add '-storage' flag to namespace.create and namespace.update commands
- [d80136a5] api: add storage_specs field to Namespace related structures
- [e7d54f90] govc: add vm.create '-profile' and '-place' flags
- [748043cd] api: add pbm.DatastoreMap for finding compatible Datastores
- [5677b0e5] govc: Add feature to pass fullname and org for windows vm customization
- [298cfbf3] fix: govc vm.disk.change should only modify CapacityInBytes
- [ee49793c] build(deps): bump goreleaser/goreleaser-action from 5 to 6
- [a0bbbf3f] vcsim: add library item storage API support
- [1ec975ca] nfc: Record the SSL thumbprint for the host the (device) URL refers to
- [3b7ff25f] vcsim: add PropertyCollector index support
- [651f7d27] vcsim: fix: ignore unknown refs in Datacenter.PowerOnMultiVM
- [fc2a6b12] api: HardwareVersion.IsSupported vs IsValid
- [1edfbe3b] feat: vSphere Zones API bindings
- [a68c21f2] api: Add library item storage APIs
- [b20c733e] build(deps): bump nokogiri from 1.16.2 to 1.16.5 in /gen
- [7d1be3e7] api: Update ConfigInfoToConfigSpec
- [12ab4099] api: Update generated types
- [7251db75] vcsim: Add PbmCheckCompatibility method in pbm simulator
- [45aa2e92] api: add checksum validation in Content Library update session file API
- [542398a2] vcsim: add HostVirtualNicManager
- [36631314] chore: govc: use generated enum lists
- [7a00a0b4] api: Generate enum consts with Values funcs
- [0be5fec8] vcsim: fix ReconfigVM validation when changing disk size
- [f2852e39] api: add SSLCertificate to TransferEndpoint in content library API
- [12f8babe] build(deps): bump chuhlomin/render-template from 1.9 to 1.10
- [0893552e] bugfix: Exclude ServerGUID from MOR comparison in WaitEx
<a name="v0.37.3"></a>
## [Release v0.37.3](https://github.com/vmware/govmomi/compare/v0.37.2...v0.37.3)
> Release Date: 2024-06-05
### 🧹 Chore
- [6b391d35] Update version.go for v0.37.3
### ⚠️ BREAKING
### 📖 Commits
- [6b391d35] chore: Update version.go for v0.37.3
- [a554e040] nfc: Record the SSL thumbprint for the host the (device) URL refers to
<a name="v0.37.2"></a>
## [Release v0.37.2](https://github.com/vmware/govmomi/compare/v0.37.1...v0.37.2)
> Release Date: 2024-05-09
### 💫 API Changes
- [37269b6a] add checksum validation in Content Library update session file API
- [ce7ef70a] add SSLCertificate to TransferEndpoint in content library API
### 💫 `vcsim` (Simulator)
- [6a0d7e7d] Add PbmCheckCompatibility method in pbm simulator
- [e6fe159b] fix ReconfigVM validation when changing disk size
### 🧹 Chore
- [9a1b3c8f] Update version.go for v0.37.2
### ⚠️ BREAKING
### 📖 Commits
- [9a1b3c8f] chore: Update version.go for v0.37.2
- [6a0d7e7d] vcsim: Add PbmCheckCompatibility method in pbm simulator
- [37269b6a] api: add checksum validation in Content Library update session file API
- [e6fe159b] vcsim: fix ReconfigVM validation when changing disk size
- [ce7ef70a] api: add SSLCertificate to TransferEndpoint in content library API
<a name="v0.37.1"></a>
## [Release v0.37.1](https://github.com/vmware/govmomi/compare/v0.37.0...v0.37.1)
> Release Date: 2024-04-18
### 🧹 Chore
- [bf28314d] Update version.go for v0.37.1
### ⚠️ BREAKING
### 📖 Commits
- [bf28314d] chore: Update version.go for v0.37.1
- [8c99cb85] bugfix: Exclude ServerGUID from MOR comparison in WaitEx
<a name="v0.37.0"></a>
## [Release v0.37.0](https://github.com/vmware/govmomi/compare/v0.36.3...v0.37.0)
> Release Date: 2024-04-12
### 🐞 Fix
- [095f926b] make cns.Client independent of vim25.Client
- [dcf063cd] vcsim: re-parent children in ResourcePool.Destroy
- [7455935a] endpoint url to bypass lookup service if envoy sidecar enabled
- [83754772] lookup client to use envoy sidecar url if enabled
### 💫 API Changes
- [f5080d3e] use RetrievePropertiesEx in mo package functions
- [a0a8257a] change RetrieveProperties to collect results in batches
- [367c55fe] move vim25.Client.UseServiceVersion to soap.Client
- [f6710489] Expose vSphere API to evict subscribed content library
- [3784b2f2] Add Downloadendpoint field in the library item file struct
### 💫 `govc` (CLI)
- [9285e441] Add library.evict command
- [fc20e24d] add default output formatting for namespace commands
- [27824cf5] snapshot.tree json output to stdout
### 💫 `vcsim` (Simulator)
- [70a7617d] toggle Content Library cached fields in sync and evict calls
- [cf719441] add ExtensionManager.FindExtension method
- [4348bd9f] RetrievePropertiesEx & ContinueRetrievePropertiesEx
- [4cec0597] add TaskHistoryCollector support
- [9c59e9c5] add TaskManager.CreateTask support
- [d9af2a26] add ExtensionManager support
### 📃 Documentation
- [368d194a] update CHANGELOG
- [2bbe81af] update CONTRIBUTORS
### 🧹 Chore
- [134152d4] Update version.go for v0.37.0
### ⚠️ BREAKING
### 📖 Commits
- [134152d4] chore: Update version.go for v0.37.0
- [70a7617d] vcsim: toggle Content Library cached fields in sync and evict calls
- [9285e441] govc: Add library.evict command
- [cf719441] vcsim: add ExtensionManager.FindExtension method
- [92a29ebf] build(deps): add vcsim to rpm
- [fc20e24d] govc: add default output formatting for namespace commands
- [095f926b] fix: make cns.Client independent of vim25.Client
- [f5080d3e] api: use RetrievePropertiesEx in mo package functions
- [4348bd9f] vcsim: RetrievePropertiesEx & ContinueRetrievePropertiesEx
- [a0a8257a] api: change RetrieveProperties to collect results in batches
- [8a618f77] feat: Add VAPI bindings for guest namespaces and virtual machine classes
- [e66065ab] build(deps): enable rpm builds and add archs
- [367c55fe] api: move vim25.Client.UseServiceVersion to soap.Client
- [f6710489] api: Expose vSphere API to evict subscribed content library
- [dcf063cd] fix: vcsim: re-parent children in ResourcePool.Destroy
- [4cec0597] vcsim: add TaskHistoryCollector support
- [041fd59a] Remove deprecation for task.Wait and task.WaitForResult
- [27824cf5] govc: snapshot.tree json output to stdout
- [7455935a] fix: endpoint url to bypass lookup service if envoy sidecar enabled
- [3784b2f2] api: Add Downloadendpoint field in the library item file struct
- [9c59e9c5] vcsim: add TaskManager.CreateTask support
- [d9af2a26] vcsim: add ExtensionManager support
- [e0ab2da2] build(deps): bump google.golang.org/protobuf in /hack/tools
- [8bfb252c] Add support for SHA256 thumbprint based vCenter authentication
- [83754772] fix: lookup client to use envoy sidecar url if enabled
- [368d194a] docs: update CHANGELOG
- [2bbe81af] docs: update CONTRIBUTORS
<a name="v0.36.3"></a>
## [Release v0.36.3](https://github.com/vmware/govmomi/compare/v0.36.2...v0.36.3)
> Release Date: 2024-04-02
### 🧹 Chore
- [35df9f35] Update version.go for v0.36.3
### ⚠️ BREAKING
### 📖 Commits
- [35df9f35] chore: Update version.go for v0.36.3
- [47c5ff94] Remove deprecation for task.Wait and task.WaitForResult
<a name="v0.36.2"></a>
## [Release v0.36.2](https://github.com/vmware/govmomi/compare/v0.36.1...v0.36.2)
> Release Date: 2024-03-27
### 🐞 Fix
- [9c5fca64] endpoint url to bypass lookup service if envoy sidecar enabled
### 💫 API Changes
- [f9e1a48e] Add Downloadendpoint field in the library item file struct
### 💫 `govc` (CLI)
- [cd9ce0ae] snapshot.tree json output to stdout
### 🧹 Chore
- [f2a87d75] Update version.go for v0.36.2
### ⚠️ BREAKING
### 📖 Commits
- [f2a87d75] chore: Update version.go for v0.36.2
- [cd9ce0ae] govc: snapshot.tree json output to stdout
- [9c5fca64] fix: endpoint url to bypass lookup service if envoy sidecar enabled
- [f9e1a48e] api: Add Downloadendpoint field in the library item file struct
<a name="v0.36.1"></a>
## [Release v0.36.1](https://github.com/vmware/govmomi/compare/v0.36.0...v0.36.1)
> Release Date: 2024-03-12
### 🐞 Fix
- [edf70dc3] lookup client to use envoy sidecar url if enabled
### 🧹 Chore
- [cc533e4b] Update version.go for v0.36.1
### ⚠️ BREAKING
### 📖 Commits
- [cc533e4b] chore: Update version.go for v0.36.1
- [27996347] Add support for SHA256 thumbprint based vCenter authentication
- [edf70dc3] fix: lookup client to use envoy sidecar url if enabled
<a name="v0.36.0"></a>
## [Release v0.36.0](https://github.com/vmware/govmomi/compare/v0.35.0...v0.36.0)

View file

@ -1,5 +1,11 @@
# Contributing to `govmomi`
tl;dr
- Sign your commits, unless you've signed the CLA
- Include a component `prefix:` in your commit message, if applicable
- Squash fixup commits and force push to your branch
## Getting started
First, fork the repository on GitHub to your personal account.
@ -27,6 +33,7 @@ This is a rough outline of what a contributor's workflow looks like:
- Create an issue describing the feature/fix
- Create a topic branch from where you want to base your work.
- Make commits of logical units.
- [Sign](#sign-off-your-work) your commits.
- Make sure your commit messages are in the proper format (see below).
- Push your changes to a topic branch in your fork of the repository.
- Submit a pull request to `vmware/govmomi`.
@ -38,12 +45,30 @@ and **supported prefixes**, e.g. `govc: <message>`.
> my!](https://www.mgasch.com/2021/05/git-basics/) for more details on how to
> successfully contribute to an open source project.
### Sign-off Your Work
Use the [Developer Certificate of Origin](https://developercertificate.org/) (DCO) on all Pull Requests.
By adding this line to their commit messages, contributors *sign-off* that they adhere to the requirements of the DCO.
Git provides the `-s` command-line option to append the required line
automatically to the commit message:
```bash
git commit -s -m 'This is my commit message'
```
For an existing commit, you can also use this option with `--amend`:
```bash
git commit -s --amend
```
### Example 1 - Fix a Bug in `govmomi`
```bash
git checkout -b issue-<number> main
git add <files>
git commit -m "fix: ..." -m "Closes: #<issue-number>"
git commit -s -m "fix: ..." -m "Closes: #<issue-number>"
git push $USER issue-<number>
```
@ -52,7 +77,7 @@ git push $USER issue-<number>
```bash
git checkout -b issue-<number> main
git add <files>
git commit -m "Add API ..." -m "Closes: #<issue-number>"
git commit -s -m "Add API ..." -m "Closes: #<issue-number>"
git push $USER issue-<number>
```
@ -61,10 +86,10 @@ git push $USER issue-<number>
```bash
git checkout -b issue-<number> main
git add <files>
git commit -m "govc: Add feature ..." -m "Closes: #<issue-number>"
git commit -s -m "govc: Add feature ..." -m "Closes: #<issue-number>"
git push $USER issue-<number>
```
**Note**:
**Note**:
To register the new `govc` command package, add a blank `_` import to `govmomi/govc/main.go`.
### Example 4 - Fix a Bug in `vcsim`
@ -72,7 +97,7 @@ To register the new `govc` command package, add a blank `_` import to `govmomi/g
```bash
git checkout -b issue-<number> main
git add <files>
git commit -m "vcsim: Fix ..." -m "Closes: #<issue-number>"
git commit -s -m "vcsim: Fix ..." -m "Closes: #<issue-number>"
git push $USER issue-<number>
```
@ -80,7 +105,7 @@ git push $USER issue-<number>
Breaking changes, e.g. to the `govmomi` APIs, are highlighted in the `CHANGELOG`
and release notes when the keyword `BREAKING:` is used in the commit message
body.
body.
The text after `BREAKING:` is used in the corresponding highlighted section.
Thus these details should be stated at the body of the commit message.
@ -89,7 +114,7 @@ Multi-line strings are supported.
```bash
git checkout -b issue-<number> main
git add <files>
cat << EOF | git commit -F -
cat << EOF | git commit -s -F -
Add ctx to funcXYZ
This commit introduces context.Context to function XYZ
@ -127,7 +152,7 @@ directly instead.
git add .
# create a fixup commit which will be merged into your (original) <commit>
git commit --fixup <commit>
git commit -s --fixup <commit>
git push $USER issue-<number>
```
@ -162,7 +187,7 @@ e.g. `Closes: #<number>`.
The [`CHANGELOG.md`](./CHANGELOG.md) and release page uses **commit message
prefixes** for grouping and highlighting. A commit message that
starts with `[prefix:] ` will place this commit under the respective
section in the `CHANGELOG`.
section in the `CHANGELOG`.
The following example creates a commit referencing the `issue: 1234` and puts
the commit message in the `govc` `CHANGELOG` section:
@ -186,7 +211,7 @@ is recommended to break up your commits using distinct prefixes.
### Running CI Checks and Tests
You can run both `make check` and `make test` from the top level of the
repository.
repository.
While `make check` will catch formatting and import errors, it will not apply
any fixes. The developer is expected to do that.

View file

@ -8,6 +8,7 @@ abrarshivani <abrarshivani@users.noreply.github.com>
Adam Chalkley <atc0005@users.noreply.github.com>
Adam Fowler <adam@adamfowler.org>
Adam Shannon <adamkshannon@gmail.com>
Adnan Baruni <badnan@vmware.com>
Akanksha Panse <pansea@vmware.com>
Al Biheiri <abiheiri@apple.com>
Alessandro Cortiana <alessandro.cortiana@gmail.com>
@ -24,6 +25,7 @@ Andrew <AndrewDi@users.noreply.github.com>
Andrew Chin <andrew@andrewtchin.com>
Andrew Kutz <akutz@vmware.com>
Andrey Klimentyev <andrey.klimentyev@flant.com>
aneesurrehman001 <55150455+aneesurrehman001@users.noreply.github.com>
Anfernee Yongkun Gui <agui@vmware.com>
angystardust <angystardust@users.noreply.github.com>
aniketGslab <aniket.shinde@gslab.com>
@ -32,6 +34,7 @@ Ankit Vaidya <vaidyaa@vmware.com>
Ankur Huralikoppi <huralikoppia@vmware.com>
Anna Carrigan <anna.carrigan@hpe.com>
Antony Saba <awsaba@gmail.com>
Anusha Ramineni <raminenia@vmware.com>
Ariel Chinn <arielchinn@gmail.com>
Arran Walker <arran.walker@zopa.com>
Artem Anisimov <aanisimov@inbox.ru>
@ -46,6 +49,7 @@ Ben Vickers <bvickers@pivotal.io>
Benjamin Davini <davinib@vmware.com>
Benjamin Peterson <benjamin@python.org>
Benjamin Vickers <bvickers@vmware.com>
Bernd Zeimetz <bernd@bzed.de>
Bhavya Choudhary <bhavyac@vmware.com>
Bob Killen <killen.bob@gmail.com>
Brad Fitzpatrick <bradfitz@golang.org>
@ -57,6 +61,7 @@ Bruno Meneguello <1322552+bkmeneguello@users.noreply.github.com>
Bryan Venteicher <bryanventeicher@gmail.com>
C S P Nanda <cspn@google.com>
Carsten Grohmann <mail@carstengrohmann.de>
Chebrolu <hchebrol@redhat.com>
Cheng Cheng <chengch@vmware.com>
Chethan Venkatesh <chethanv@vmware.com>
Choudhury Sarada Prasanna Nanda <cspn@google.com>
@ -82,6 +87,7 @@ Davide Agnello <dagnello@hp.com>
Davinder Kumar <davinderk@vmware.com>
Defa <zhoudefa666@163.com>
demarey <christophe.demarey@inria.fr>
Derek Beard <derek.beard@gmail.com>
Deric Crago <deric.crago@gmail.com>
Deyan Popov <deyan.popov@gmail.com>
Dinesh Bhat <35480850+dbhat-arkin@users.noreply.github.com>
@ -92,12 +98,14 @@ Doug MacEachern <dougm@vmware.com>
East <60801291+houfangdong@users.noreply.github.com>
Eloy Coto <eloy.coto@gmail.com>
Eng Zer Jun <engzerjun@gmail.com>
Eric Cao <ecao@vmware.com>
Eric Edens <ericedens@google.com>
Eric Graham <16710890+Pheric@users.noreply.github.com>
Eric Gray <egray@vmware.com>
Eric Yutao <eric.yutao@gmail.com>
Erik Hollensbe <github@hollensbe.org>
Erik Lund <info@erikjensen.it>
Erim Erdal <erim.erdal@broadcom.com>
Essodjolo KAHANAM <essodjolo@kahanam.com>
Ethan Kaley <ethan.kaley@emc.com>
Evan Chu <echu@vmware.com>
@ -121,6 +129,7 @@ Hasan Mahmood <mahmoodh@vmware.com>
Haydon Ryan <haydon.ryan@gmail.com>
Heiko Reese <hreese@users.noreply.github.com>
Henrik Hodne <henrik@travis-ci.com>
Himanshu Ranjan <rhimanshu@vmware.com>
hkumar <hkumar@vmware.com>
Hrabur Stoyanov <hstoyanov@vmware.com>
hui luo <luoh@vmware.com>
@ -135,10 +144,12 @@ Jeremy Canady <jcanady@jackhenry.com>
jeremy-clerc <jeremy@clerc.io>
Jiatong Wang <wjiatong@vmware.com>
jingyizPensando <jingyiz@pensando.io>
jitinkumar94 <jitinkumar94@github.com>
Jonas Ausevicius <jonas.ausevicius@virtustream.com>
Jorge Sevilla <jorge.sevilla@rstor.io>
Joseph LeBlanc <jsleblanc@users.noreply.github.com>
João Pereira <joaodrp@gmail.com>
Jukka Lehtniemi <ext-jukka.lehtniemi@vaisala.com>
Julien PILLON <jpillon@lesalternatives.org>
Justin J. Novack <jnovack@users.noreply.github.com>
kayrus <kay.diam@gmail.com>
@ -155,6 +166,7 @@ Liping Xue <lipingx@vmware.com>
liron.levin <liron.levin@wiz.io>
Louie Jiang <jiangl@vmware.com>
Lubron Zhan <lzhan@vmware.com>
Luis Davim <dluis@vmware.com>
Luther Monson <luther.monson@gmail.com>
Madanagopal Arunachalam <marunachalam@vmware.com>
makelarisjr <8687447+makelarisjr@users.noreply.github.com>
@ -209,16 +221,19 @@ Robin Watkins <robwatkins@gmail.com>
Rowan Jacobs <rojacobs@pivotal.io>
Roy Ling <royling0024@gmail.com>
rsikdar <rsikdar@berkeley.edu>
rubinthomasdev <rubinthomasdev@gmail.com>
runner.mei <runner.mei@gmail.com>
Ryan Johnson <johnsonryan@vmware.com>
S R Ashrith <sashrith@vmware.com>
S.Çağlar Onur <conur@vmware.com>
Saad Malik <saad@spectrocloud.com>
Sai Diliyaer <sai.diliyaer@gmail.com>
Sam Zhu <zhusa@zhusa-a02.vmware.com>
samzhu333 <45263849+samzhu333@users.noreply.github.com>
Sandeep Pissay Srinivasa Rao <ssrinivas@vmware.com>
schmikei <keith.schmitt@bluemedora.com>
Scott Holden <scott@nullops.io>
Sebastian Mitterle <smitterl@redhat.com>
Sergey Ignatov <sergey.ignatov@jetbrains.com>
serokles <timbo.alexander@gmail.com>
shahra <shahra@vmware.com>
@ -229,6 +244,7 @@ shylasrinivas <sshyla@vmware.com>
sky-joker <sky.jokerxx@gmail.com>
smaftoul <samuel.maftoul@gmail.com>
smahadik <smahadik@vmware.com>
Sreeja Acharya <acharyasreej@vmware.com>
Sten Feldman <exile@chamber.ee>
Stepan Mazurov <smazurov@gmail.com>
Steve Purcell <steve@sanityinc.com>
@ -264,6 +280,7 @@ xing-yang <xingyang105@gmail.com>
xinyanw409 <wxinyan@vmware.com>
Yang Yang <yangy@vmware.com>
yangxi <yangxi@vmware.com>
Yanlei Zhao <yanleizhao@vmware.com>
Yann Hodique <yhodique@google.com>
Yash Nitin Desai <desaiy@vmware.com>
Yassine TIJANI <ytijani@vmware.com>

View file

@ -94,13 +94,21 @@ install: ## Install govc and vcsim
## Generate
## --------------------------------------
.PHONY: mod
mod: ## Runs go mod tidy to validate modules
go mod tidy -v
GO_MOD_FILES := $(filter-out ./hack/tools/go.mod,$(shell find . -name go.mod))
GO_MOD_OP := tidy
.PHONY: mod-get
mod-get: ## Downloads and caches the modules
go mod download
.PHONY: $(GO_MOD_FILES)
$(GO_MOD_FILES):
go -C $(@D) mod $(GO_MOD_OP)
.PHONY: mod
mod: $(GO_MOD_FILES)
mod: ## Validates the modules
.PHONY: modules-download
mod-download: GO_MOD_OP=download
mod-download: $(GO_MOD_FILES)
mod-download: ## Downloads and caches the modules
.PHONY: doc
doc: install

View file

@ -19,9 +19,7 @@ In addition to the vSphere API client, this repository includes:
## Compatibility
This library supports vCenter Server and ESXi versions following the [VMware Product Lifecycle Matrix][reference-lifecycle].
Product versions that are end of support may work, but are not officially supported.
vSphere 7.0 and higher.
## Documentation
@ -37,10 +35,7 @@ Installation instructions, released binaries, and Docker images are documented i
## Discussion
The project encourages the community to collaborate using GitHub [issues][govmomi-github-issues], GitHub [discussions][govmomi-github-discussions], and [Slack][slack-channel].
> **Note**
> Access to Slack requires a free [VMware {code}][slack-join] developer program membership.
Collaborate with the community using GitHub [discussions][govmomi-github-discussions] and GitHub [issues][govmomi-github-issues].
## Status
@ -48,29 +43,8 @@ Changes to the API are subject to [semantic versioning][reference-semver].
Refer to the [CHANGELOG][govmomi-changelog] for version to version changes.
## Notable Projects Using govmomi
* [collectd-vsphere][project-travisci-collectd-vsphere]
* [Docker LinuxKit][project-docker-linuxKit]
* [Elastic Agent VMware vSphere integration][project-elastic-agent]
* [Gru][project-gru]
* [Juju][project-juju]
* [Jupiter Brain][project-travisci-jupiter-brain]
* [Kubernetes vSphere Cloud Provider][project-k8s-cloud-provider]
* [Kubernetes Cluster API][project-k8s-cluster-api]
* [OPS][project-nanovms-ops]
* [OpenTelemetry Collector Contrib][opentelemetry-collector-contrib]
* [Packer Plugin for VMware vSphere][project-hashicorp-packer-plugin-vsphere]
* [Rancher][project-rancher]
* [Terraform Provider for VMware vSphere][project-hashicorp-terraform-provider-vsphere]
* [Telegraf][project-influxdata-telegraf]
* [VMware Event Broker Appliance][project-vmware-veba]
* [VMware vSphere Integrated Containers Engine][project-vmware-vic]
* [VMware vSphere 7.0][project-vmware-vsphere]
## Related Projects
* [go-vmware-nsxt][reference-go-vmware-nsxt]
* [pyvmomi][reference-pyvmomi]
* [rbvmomi][reference-rbvmomi]
@ -80,7 +54,7 @@ govmomi is available under the [Apache 2 License][govmomi-license].
## Name
Pronounced: _go·mom·ie_
Pronounced: _go·mom·e_
Follows pyvmomi and rbvmomi: language prefix + the vSphere acronym "VM Object Management Infrastructure".
@ -97,31 +71,10 @@ Follows pyvmomi and rbvmomi: language prefix + the vSphere acronym "VM Object Ma
[go-reference]: https://pkg.go.dev/github.com/vmware/govmomi
[go-report-card]: https://goreportcard.com/report/github.com/vmware/govmomi
[go-version]: https://github.com/vmware/govmomi
[opentelemetry-collector-contrib]: https://github.com/open-telemetry/opentelemetry-collector-contrib
[project-docker-linuxKit]: https://github.com/linuxkit/linuxkit/tree/master/src/cmd/linuxkit
[project-elastic-agent]: https://github.com/elastic/integrations/tree/main/packages/vsphere
[project-gru]: https://github.com/dnaeon/gru
[project-hashicorp-packer-plugin-vsphere]: https://github.com/hashicorp/packer-plugin-vsphere
[project-hashicorp-terraform-provider-vsphere]: https://github.com/hashicorp/terraform-provider-vsphere
[project-influxdata-telegraf]: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/vsphere
[project-juju]: https://github.com/juju/juju
[project-k8s-cloud-provider]: https://github.com/kubernetes/cloud-provider-vsphere
[project-k8s-cluster-api]: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere
[project-nanovms-ops]: https://github.com/nanovms/ops
[project-rancher]: https://github.com/rancher/rancher/blob/master/pkg/api/norman/customization/vsphere/listers.go
[project-travisci-collectd-vsphere]: https://github.com/travis-ci/collectd-vsphere
[project-travisci-jupiter-brain]: https://github.com/travis-ci/jupiter-brain
[project-vmware-veba]: https://github.com/vmware-samples/vcenter-event-broker-appliance/tree/development/vmware-event-router
[project-vmware-vic]: https://github.com/vmware/vic
[project-vmware-vsphere]: https://docs.vmware.com/en/VMware-vSphere/7.0/rn/vsphere-esxi-vcenter-server-7-vsphere-with-kubernetes-release-notes.html
[reference-api]: https://developer.vmware.com/apis/968/vsphere
[reference-godoc]: http://godoc.org/github.com/vmware/govmomi
[reference-go-vmware-nsxt]: https://github.com/vmware/go-vmware-nsxt
[reference-lifecycle]: https://lifecycle.vmware.com
[reference-api]: https://developer.broadcom.com/xapis/vsphere-web-services-api/latest/
[reference-godoc]: https://pkg.go.dev/github.com/vmware/govmomi
[reference-pyvmomi]: https://github.com/vmware/pyvmomi
[reference-rbvmomi]: https://github.com/vmware/rbvmomi
[reference-semver]: http://semver.org
[slack-join]: https://developer.vmware.com/join/
[slack-channel]: https://vmwarecode.slack.com/messages/govmomi
[toolbox]: toolbox/README.md
[vcsim]: vcsim/README.md

View file

View file

@ -65,7 +65,7 @@ It is licensed under the Apache License, Version 2.0
The available commands are listed below. A detailed description of each
command can be displayed with "govc <COMMAND> -h". The description of all
commands can be also found at https://via.vmw.com/GJ98hk .
commands can be also found at https://github.com/vmware/govmomi/blob/main/govc/USAGE.md.
Examples:
show usage of a command: govc <COMMAND> -h

View file

@ -21,8 +21,8 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
)

View file

@ -25,13 +25,19 @@ import (
"path/filepath"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/units"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
const (
sectorSize = 512 // Sector size in bytes
startSector = 2048 // Start sector (typically fixed)
)
type create struct {
*flags.HostSystemFlag
@ -50,6 +56,7 @@ type create struct {
// Options for VMFS
DiskCanonicalName string
Version *int32
Size units.ByteSize
// Options for local
Path string
@ -144,6 +151,7 @@ func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
// Options for VMFS
f.StringVar(&cmd.DiskCanonicalName, "disk", "", "Canonical name of disk (VMFS only)")
f.Var(flags.NewOptionalInt32(&cmd.Version), "version", "VMFS major version")
f.Var(&cmd.Size, "size", "Size of new disk. Default is to use entire disk")
// Options for Local
f.StringVar(&cmd.Path, "path", "", "Local directory path for the datastore (local only)")
@ -165,7 +173,8 @@ func (cmd *create) Description() string {
Examples:
govc datastore.create -type nfs -name nfsDatastore -remote-host 10.143.2.232 -remote-path /share cluster1
govc datastore.create -type vmfs -name vmfsDatastore -disk=mpx.vmhba0:C0:T0:L0 cluster1
govc datastore.create -type vmfs -name vmfsDatastore -disk=mpx.vmhba0:C0:T0:L0 cluster1 # use entire disk
govc datastore.create -type vmfs -name vmfsDatastore -disk=mpx.vmhba0:C0:T0:L0 -size 20G cluster1 # use 20G of disk
govc datastore.create -type local -name localDatastore -path /var/datastore host1`
}
@ -289,6 +298,12 @@ func (cmd *create) CreateVmfsDatastore(ctx context.Context, hosts []*object.Host
spec := *option.Spec.(*types.VmfsDatastoreCreateSpec)
spec.Vmfs.VolumeName = cmd.Name
if cmd.Size > 0 {
endSector := CalculateSectors(int64(cmd.Size))
// set values for Sectors
spec.Partition.Partition[0].StartSector = startSector
spec.Partition.Partition[0].EndSector = endSector
}
if cmd.Version != nil {
spec.Vmfs.MajorVersion = *cmd.Version
}
@ -301,6 +316,14 @@ func (cmd *create) CreateVmfsDatastore(ctx context.Context, hosts []*object.Host
return nil
}
// CalculateSectors calculates the start and end sectors based on the given size.
func CalculateSectors(sizeInBytes int64) (endSector int64) {
totalSectors := sizeInBytes / sectorSize
endSector = startSector + totalSectors - 1
return endSector
}
func (cmd *create) CreateLocalDatastore(ctx context.Context, hosts []*object.HostSystem) error {
for _, host := range hosts {
ds, err := host.ConfigManager().DatastoreSystem(ctx)

View file

@ -1,18 +1,6 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: Apache-2.0
package datastore
@ -23,10 +11,14 @@ import (
"fmt"
"io"
"os"
"path"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/ovf"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vmdk"
)
type download struct {
@ -67,7 +59,10 @@ If DEST name is "-", source is written to stdout.
Examples:
govc datastore.download vm-name/vmware.log ./local.log
govc datastore.download vm-name/vmware.log - | grep -i error`
govc datastore.download vm-name/vmware.log - | grep -i error
govc datastore.download -json vm-name/vm-name.vmdk - | jq .ddb
ovf=$(govc library.info -l -L vmservice/photon-5.0/*.ovf)
govc datastore.download -json "$ovf" - | jq -r .diskSection.disk[].capacity`
}
func (cmd *download) Run(ctx context.Context, f *flag.FlagSet) error {
@ -76,6 +71,16 @@ func (cmd *download) Run(ctx context.Context, f *flag.FlagSet) error {
return errors.New("invalid arguments")
}
src := args[0]
dst := args[1]
var dp object.DatastorePath
if dp.FromString(src) {
// e.g. `govc library.info -l -L ...`
cmd.DatastoreFlag.Name = dp.Datastore
src = dp.Path
}
ds, err := cmd.Datastore()
if err != nil {
return err
@ -95,14 +100,29 @@ func (cmd *download) Run(ctx context.Context, f *flag.FlagSet) error {
p := soap.DefaultDownload
src := args[0]
dst := args[1]
if dst == "-" {
f, _, err := ds.Download(ctx, src, &p)
if err != nil {
return err
}
if cmd.DatastoreFlag.All() {
switch path.Ext(src) {
case ".vmdk":
data, err := vmdk.ParseDescriptor(f)
if err != nil {
return err
}
return cmd.DatastoreFlag.WriteResult(data)
case ".ovf":
data, err := ovf.Unmarshal(f)
if err != nil {
return err
}
return cmd.DatastoreFlag.WriteResult(data)
}
}
_, err = io.Copy(os.Stdout, f)
return err
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -24,8 +24,8 @@ import (
"os"
"text/tabwriter"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25/mo"
@ -81,9 +81,9 @@ Examples:
govc datastore.info
govc datastore.info vsanDatastore
# info on Datastores shared between cluster hosts:
govc object.collect -s -d " " /dc1/host/k8s-cluster host | xargs govc datastore.info -H
govc collect -s -d " " /dc1/host/k8s-cluster host | xargs govc datastore.info -H
# info on Datastores shared between VM hosts:
govc ls /dc1/vm/*k8s* | xargs -n1 -I% govc object.collect -s % summary.runtime.host | xargs govc datastore.info -H`
govc ls /dc1/vm/*k8s* | xargs -n1 -I% govc collect -s % summary.runtime.host | xargs govc datastore.info -H`
}
func intersect(common []types.ManagedObjectReference, refs []types.ManagedObjectReference) []types.ManagedObjectReference {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -26,8 +26,9 @@ import (
"strings"
"text/tabwriter"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/units"
"github.com/vmware/govmomi/vim25/types"
@ -41,6 +42,7 @@ type ls struct {
slash bool
all bool
recurse bool
human bool
}
func init() {
@ -54,6 +56,7 @@ func (cmd *ls) Register(ctx context.Context, f *flag.FlagSet) {
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
cmd.OutputFlag.Register(ctx, f)
f.BoolVar(&cmd.human, "H", true, "Display human friendly name") // vSAN top-level dirs are ID by default
f.BoolVar(&cmd.long, "l", false, "Long listing format")
f.BoolVar(&cmd.slash, "p", false, "Append / indicator to directories")
f.BoolVar(&cmd.all, "a", false, "Do not ignore entries starting with .")
@ -75,14 +78,7 @@ func (cmd *ls) Usage() string {
}
func isInvalid(err error) bool {
if f, ok := err.(types.HasFault); ok {
switch f.Fault().(type) {
case *types.InvalidArgument:
return true
}
}
return false
return fault.Is(err, &types.InvalidArgument{})
}
func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
@ -212,10 +208,17 @@ func (o *listOutput) add(r types.HostDatastoreBrowserSearchResults) {
res.File = nil
for _, f := range r.File {
if f.GetFileInfo().Path[0] == '.' && !o.cmd.all {
info := f.GetFileInfo()
if info.Path[0] == '.' && !o.cmd.all {
continue
}
if o.cmd.human {
if info.FriendlyName != "" {
info.Path = info.FriendlyName
}
}
if o.cmd.slash {
if d, ok := f.(*types.FolderFileInfo); ok {
d.Path += "/"

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -22,10 +22,10 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
@ -105,11 +105,8 @@ func (cmd *mkdir) Run(ctx context.Context, f *flag.FlagSet) error {
// ignore EEXIST if -p flag is given
if err != nil && cmd.createParents {
if soap.IsSoapFault(err) {
soapFault := soap.ToSoapFault(err)
if _, ok := soapFault.VimFault().(types.FileAlreadyExists); ok {
return nil
}
if fault.Is(err, &types.FileAlreadyExists{}) {
return nil
}
}
}

View file

@ -21,7 +21,7 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type mv struct {

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type remove struct {

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -23,8 +23,8 @@ import (
"os"
"time"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type tail struct {

View file

@ -22,8 +22,8 @@ import (
"flag"
"os"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/vim25/soap"
)

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,14 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package esxcli
package esx
import (
"flag"
"fmt"
"strings"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/internal"
)
@ -57,7 +56,7 @@ type CommandInfoMethod struct {
type CommandInfo struct {
CommandInfoItem
Method []*CommandInfoMethod `xml:"method" json:"method"`
Method []CommandInfoMethod `xml:"method" json:"method"`
}
func NewCommand(args []string) *Command {
@ -91,11 +90,22 @@ func (c *Command) Moid() string {
return "ha-cli-handler-" + strings.Join(c.name[:len(c.name)-1], "-")
}
type stringList []string
func (l *stringList) String() string {
return fmt.Sprint(*l)
}
func (l *stringList) Set(value string) error {
*l = append(*l, value)
return nil
}
// Parse generates a flag.FlagSet based on the given []CommandInfoParam and
// returns arguments for use with methods.ExecuteSoap
func (c *Command) Parse(params []CommandInfoParam) ([]internal.ReflectManagedMethodExecuterSoapArgument, error) {
fs := flag.NewFlagSet(strings.Join(c.name, " "), flag.ExitOnError)
vals := make([]flags.StringList, len(params))
vals := make([]stringList, len(params))
for i, p := range params {
v := &vals[i]

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,15 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package esxcli
package esx
import (
"context"
"fmt"
"github.com/vmware/govmomi/internal"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/xml"
)
@ -35,7 +36,7 @@ func (f Fault) Error() string {
return f.Message
}
func (f Fault) messageDetail() string {
func (f Fault) MessageDetail() string {
if f.Detail != "" {
return fmt.Sprintf("%s %s", f.Message, f.Detail)
}
@ -45,14 +46,15 @@ func (f Fault) messageDetail() string {
type Executor struct {
c *vim25.Client
host *object.HostSystem
host mo.Reference
mme *internal.ReflectManagedMethodExecuter
dtm *internal.InternalDynamicTypeManager
info map[string]*CommandInfo
Trace func(*internal.ExecuteSoapRequest, *internal.ExecuteSoapResponse)
}
func NewExecutor(c *vim25.Client, host *object.HostSystem) (*Executor, error) {
ctx := context.TODO()
func NewExecutor(ctx context.Context, c *vim25.Client, host mo.Reference) (*Executor, error) {
e := &Executor{
c: c,
host: host,
@ -88,42 +90,60 @@ func NewExecutor(c *vim25.Client, host *object.HostSystem) (*Executor, error) {
return e, nil
}
func (e *Executor) CommandInfo(c *Command) (*CommandInfoMethod, error) {
func (e *Executor) Client() *vim25.Client {
return e.c
}
func (e *Executor) DynamicTypeManager() types.ManagedObjectReference {
return e.dtm.ManagedObjectReference
}
func (e *Executor) CommandInfo(ctx context.Context, ns string) (*CommandInfo, error) {
info, ok := e.info[ns]
if ok {
return info, nil
}
req := internal.ExecuteSoapRequest{
Moid: "ha-dynamic-type-manager-local-cli-cliinfo",
Method: "vim.CLIInfo.FetchCLIInfo",
Argument: []internal.ReflectManagedMethodExecuterSoapArgument{
NewCommand(nil).Argument("typeName", "vim.EsxCLI."+ns),
},
}
info = new(CommandInfo)
if err := e.Execute(ctx, &req, info); err != nil {
return nil, err
}
e.info[ns] = info
return info, nil
}
func (e *Executor) CommandInfoMethod(ctx context.Context, c *Command) (*CommandInfoMethod, error) {
ns := c.Namespace()
var info *CommandInfo
var ok bool
if info, ok = e.info[ns]; !ok {
req := internal.ExecuteSoapRequest{
Moid: "ha-dynamic-type-manager-local-cli-cliinfo",
Method: "vim.CLIInfo.FetchCLIInfo",
Argument: []internal.ReflectManagedMethodExecuterSoapArgument{
c.Argument("typeName", "vim.EsxCLI."+ns),
},
}
info = new(CommandInfo)
if err := e.Execute(&req, info); err != nil {
return nil, err
}
e.info[ns] = info
info, err := e.CommandInfo(ctx, ns)
if err != nil {
return nil, err
}
name := c.Name()
for _, method := range info.Method {
if method.Name == name {
return method, nil
return &method, nil
}
}
return nil, fmt.Errorf("method '%s' not found in name space '%s'", name, c.Namespace())
}
func (e *Executor) NewRequest(args []string) (*internal.ExecuteSoapRequest, *CommandInfoMethod, error) {
func (e *Executor) NewRequest(ctx context.Context, args []string) (*internal.ExecuteSoapRequest, *CommandInfoMethod, error) {
c := NewCommand(args)
info, err := e.CommandInfo(c)
info, err := e.CommandInfoMethod(ctx, c)
if err != nil {
return nil, nil, err
}
@ -142,8 +162,7 @@ func (e *Executor) NewRequest(args []string) (*internal.ExecuteSoapRequest, *Com
return &sreq, info, nil
}
func (e *Executor) Execute(req *internal.ExecuteSoapRequest, res interface{}) error {
ctx := context.TODO()
func (e *Executor) Execute(ctx context.Context, req *internal.ExecuteSoapRequest, res interface{}) error {
req.This = e.mme.ManagedObjectReference
req.Version = "urn:vim25/5.0"
@ -152,6 +171,10 @@ func (e *Executor) Execute(req *internal.ExecuteSoapRequest, res interface{}) er
return err
}
if e.Trace != nil {
e.Trace(req, x)
}
if x.Returnval != nil {
if x.Returnval.Fault != nil {
return &Fault{
@ -168,8 +191,8 @@ func (e *Executor) Execute(req *internal.ExecuteSoapRequest, res interface{}) er
return nil
}
func (e *Executor) Run(args []string) (*Response, error) {
req, info, err := e.NewRequest(args)
func (e *Executor) Run(ctx context.Context, args []string) (*Response, error) {
req, info, err := e.NewRequest(ctx, args)
if err != nil {
return nil, err
}
@ -178,7 +201,7 @@ func (e *Executor) Run(args []string) (*Response, error) {
Info: info,
}
if err := e.Execute(req, res); err != nil {
if err := e.Execute(ctx, req, res); err != nil {
return nil, err
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package esxcli
package esx
import "github.com/vmware/govmomi/object"
import "context"
type FirewallInfo struct {
Loaded bool `json:"loaded"`
@ -27,13 +27,8 @@ type FirewallInfo struct {
// GetFirewallInfo via 'esxcli network firewall get'
// The HostFirewallSystem type does not expose this data.
// This helper can be useful in particular to determine if the firewall is enabled or disabled.
func GetFirewallInfo(s *object.HostSystem) (*FirewallInfo, error) {
x, err := NewExecutor(s.Client(), s)
if err != nil {
return nil, err
}
res, err := x.Run([]string{"network", "firewall", "get"})
func (x *Executor) GetFirewallInfo(ctx context.Context) (*FirewallInfo, error) {
res, err := x.Run(ctx, []string{"network", "firewall", "get"})
if err != nil {
return nil, err
}

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -14,13 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package esxcli
package esx
import (
"context"
"strings"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/mo"
@ -44,20 +43,18 @@ func NewGuestInfo(c *vim25.Client) *GuestInfo {
}
}
func (g *GuestInfo) hostInfo(ref *types.ManagedObjectReference) (*hostInfo, error) {
func (g *GuestInfo) hostInfo(ctx context.Context, ref *types.ManagedObjectReference) (*hostInfo, error) {
// cache exectuor and uuid -> worldid map
if h, ok := g.hosts[ref.Value]; ok {
return h, nil
}
host := object.NewHostSystem(g.c, *ref)
e, err := NewExecutor(g.c, host)
e, err := NewExecutor(ctx, g.c, ref)
if err != nil {
return nil, err
}
res, err := e.Run([]string{"vm", "process", "list"})
res, err := e.Run(ctx, []string{"vm", "process", "list"})
if err != nil {
return nil, err
}
@ -82,8 +79,7 @@ func (g *GuestInfo) hostInfo(ref *types.ManagedObjectReference) (*hostInfo, erro
// ESX hosts must be configured with the /Net/GuestIPHack enabled.
// For example:
// $ govc host.esxcli -- system settings advanced set -o /Net/GuestIPHack -i 1
func (g *GuestInfo) IpAddress(vm *object.VirtualMachine) (string, error) {
ctx := context.TODO()
func (g *GuestInfo) IpAddress(ctx context.Context, vm mo.Reference) (string, error) {
const any = "0.0.0.0"
var mvm mo.VirtualMachine
@ -93,7 +89,7 @@ func (g *GuestInfo) IpAddress(vm *object.VirtualMachine) (string, error) {
return "", err
}
h, err := g.hostInfo(mvm.Runtime.Host)
h, err := g.hostInfo(ctx, mvm.Runtime.Host)
if err != nil {
return "", err
}
@ -102,7 +98,7 @@ func (g *GuestInfo) IpAddress(vm *object.VirtualMachine) (string, error) {
uuid := strings.Replace(mvm.Config.Uuid, "-", "", -1)
if wid, ok := h.wids[uuid]; ok {
res, err := h.Run([]string{"network", "vm", "port", "list", "--world-id", wid})
res, err := h.Run(ctx, []string{"network", "vm", "port", "list", "--world-id", wid})
if err != nil {
return "", err
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package esxcli
package esx
import (
"io"
@ -27,6 +28,7 @@ type Response struct {
Info *CommandInfoMethod `json:"info"`
Values []Values `json:"values"`
String string `json:"string"`
Kind string `json:"-"`
}
func (v Values) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
@ -55,6 +57,37 @@ func (v Values) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
}
}
func (s Values) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
tokens := []xml.Token{start}
for key, val := range s {
field := xml.StartElement{Name: xml.Name{Local: key}}
for _, v := range val {
tokens = append(tokens, field, xml.CharData(v), field.End())
}
}
tokens = append(tokens, start.End())
for _, t := range tokens {
err := e.EncodeToken(t)
if err != nil {
return err
}
}
return nil
}
func (v Values) Value(name string) string {
if val, ok := v[name]; ok {
if len(val) != 0 {
return val[0]
}
}
return ""
}
func (r *Response) Type(start xml.StartElement) string {
for _, a := range start.Attr {
if a.Name.Local == "type" {
@ -69,7 +102,7 @@ func (r *Response) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
if stype != "ArrayOfDataObject" {
switch stype {
case "xsd:string":
case "xsd:string", "xsd:boolean", "xsd:long":
return d.DecodeElement(&r.String, &start)
}
v := Values{}
@ -100,3 +133,56 @@ func (r *Response) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
}
}
}
func (r *Response) MarshalXML(e *xml.Encoder, _ xml.StartElement) error {
kind := "ArrayOfDataObject"
native := r.String != ""
if native {
kind = "xsd:" + r.Kind
}
start := xml.StartElement{
Name: xml.Name{
Space: "urn:vim25",
Local: "obj",
},
Attr: []xml.Attr{
{
Name: xml.Name{Local: "xmlns:xsd"},
Value: "http://www.w3.org/2001/XMLSchema",
},
{
Name: xml.Name{Local: "xmlns:xsi"},
Value: "http://www.w3.org/2001/XMLSchema-instance",
},
{
Name: xml.Name{Local: "xsi:type"},
Value: kind,
},
},
}
if err := e.EncodeToken(start); err != nil {
return err
}
var err error
if native {
err = e.EncodeToken(xml.CharData(r.String))
} else {
obj := xml.StartElement{
Name: xml.Name{Local: "DataObject"},
Attr: []xml.Attr{{
Name: xml.Name{Local: "xsi:type"},
Value: r.Kind,
}},
}
err = e.EncodeElement(r.Values, obj)
}
if err != nil {
return err
}
return e.EncodeToken(start.End())
}

View file

@ -53,8 +53,6 @@ const (
envVimVersion = "GOVC_VIM_VERSION"
envTLSCaCerts = "GOVC_TLS_CA_CERTS"
envTLSKnownHosts = "GOVC_TLS_KNOWN_HOSTS"
defaultMinVimVersion = "5.5"
)
const cDescr = "ESX or vCenter URL"
@ -69,7 +67,6 @@ type ClientFlag struct {
cert string
key string
persist bool
minAPIVersion string
vimNamespace string
vimVersion string
tlsCaCerts string
@ -167,15 +164,6 @@ func (flag *ClientFlag) Register(ctx context.Context, f *flag.FlagSet) {
f.BoolVar(&flag.persist, "persist-session", persist, usage)
}
{
env := os.Getenv(envMinAPIVersion)
if env == "" {
env = defaultMinVimVersion
}
flag.minAPIVersion = env
}
{
value := os.Getenv(envVimNamespace)
if value == "" {
@ -310,45 +298,6 @@ func (flag *ClientFlag) SetRootCAs(c *soap.Client) error {
return nil
}
func isDevelopmentVersion(apiVersion string) bool {
// Skip version check for development builds which can be in the form of "r4A70F" or "6.5.x"
return strings.Count(apiVersion, ".") == 0 || strings.HasSuffix(apiVersion, ".x")
}
// apiVersionValid returns whether or not the API version supported by the
// server the client is connected to is not recent enough.
func apiVersionValid(c *vim25.Client, minVersionString string) error {
if minVersionString == "-" {
// Disable version check
return nil
}
apiVersion := c.ServiceContent.About.ApiVersion
if isDevelopmentVersion(apiVersion) {
return nil
}
realVersion, err := ParseVersion(apiVersion)
if err != nil {
return fmt.Errorf("error parsing API version %q: %s", apiVersion, err)
}
minVersion, err := ParseVersion(minVersionString)
if err != nil {
return fmt.Errorf("error parsing %s=%q: %s", envMinAPIVersion, minVersionString, err)
}
if !minVersion.Lte(realVersion) {
err = fmt.Errorf("require API version %q, connected to API version %q (set %s to override)",
minVersionString,
c.ServiceContent.About.ApiVersion,
envMinAPIVersion)
return err
}
return nil
}
func (flag *ClientFlag) RoundTripper(c *soap.Client) soap.RoundTripper {
// Retry twice when a temporary I/O error occurs.
// This means a maximum of 3 attempts.
@ -375,13 +324,7 @@ func (flag *ClientFlag) Client() (*vim25.Client, error) {
return nil, err
}
// Check that the endpoint has the right API version
err = apiVersionValid(c, flag.minAPIVersion)
if err != nil {
return nil, err
}
if flag.vimVersion == "" {
if flag.vimVersion == "" || flag.vimVersion == "-" {
err = c.UseServiceVersion()
if err != nil {
return nil, err

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -197,16 +197,6 @@ func (flag *DatacenterFlag) ManagedObjects(ctx context.Context, args []string) (
}
for _, arg := range args {
if ref := object.ReferenceFromString(arg); ref != nil {
// e.g. output from object.collect
refs = append(refs, *ref)
continue
}
if !strings.Contains(arg, "/") {
return nil, fmt.Errorf("%q must be qualified with a path", arg)
}
elements, err := finder.ManagedObjectList(ctx, arg)
if err != nil {
return nil, err
@ -216,6 +206,10 @@ func (flag *DatacenterFlag) ManagedObjects(ctx context.Context, args []string) (
return nil, fmt.Errorf("object '%s' not found", arg)
}
if len(elements) > 1 && !strings.Contains(arg, "/") {
return nil, fmt.Errorf("%q must be qualified with a path", arg)
}
for _, e := range elements {
refs = append(refs, e.Object.Reference())
}

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -331,7 +331,7 @@ func (v *verbose) propertyValue(obj types.ManagedObjectReference, name string, p
val := v.value(pval)
if obj.Type != "Task" && !strings.HasPrefix(obj.Value, "session") {
if len(val) > 512 {
val = fmt.Sprintf("`govc object.collect -dump %s %s`", obj, name)
val = fmt.Sprintf("`govc collect -dump %s %s`", obj, name)
}
}
return fmt.Sprintf("%s\t%s:\t%s", v.mor(obj), name, val)

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -22,6 +22,7 @@ import (
"fmt"
"net/url"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/types"
@ -85,15 +86,9 @@ func (flag *HostConnectFlag) Spec(c *vim25.Client) types.HostConnectSpec {
// Fault checks if error is SSLVerifyFault, including the thumbprint if so
func (flag *HostConnectFlag) Fault(err error) error {
if err == nil {
return nil
}
if f, ok := err.(types.HasFault); ok {
switch fault := f.Fault().(type) {
case *types.SSLVerifyFault:
return fmt.Errorf("%s thumbprint=%s", err, fault.Thumbprint)
}
var verify *types.SSLVerifyFault
if _, ok := fault.As(err, &verify); ok {
return fmt.Errorf("%s thumbprint=%s", err, verify.Thumbprint)
}
return err

View file

@ -30,7 +30,7 @@ import (
"github.com/dougm/pretty"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/task"
"github.com/vmware/govmomi/vim25/progress"
"github.com/vmware/govmomi/vim25/soap"

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -23,10 +23,10 @@ import (
"fmt"
"strings"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
@ -205,11 +205,8 @@ func (flag *SearchFlag) searchByUUID(c *vim25.Client, dc *object.Datacenter) (ob
for _, iu := range []*bool{nil, types.NewBool(true)} {
ref, err = flag.searchIndex(c).FindByUuid(ctx, dc, flag.byUUID, isVM, iu)
if err != nil {
if soap.IsSoapFault(err) {
fault := soap.ToSoapFault(err).VimFault()
if _, ok := fault.(types.InvalidArgument); ok {
continue
}
if fault.Is(err, &types.InvalidArgument{}) {
continue
}
return nil, err
}

View file

@ -0,0 +1,124 @@
/*
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package flags
import (
"context"
"errors"
"flag"
"fmt"
"github.com/vmware/govmomi/vim25/types"
)
type StorageProfileFlag struct {
*ClientFlag
Name []string
option string
}
func NewStorageProfileFlag(ctx context.Context, option ...string) (*StorageProfileFlag, context.Context) {
v := &StorageProfileFlag{}
if len(option) == 1 {
v.option = option[0]
} else {
v.option = "profile"
}
v.ClientFlag, ctx = NewClientFlag(ctx)
return v, ctx
}
func (e *StorageProfileFlag) String() string {
return fmt.Sprint(e.Name)
}
func (e *StorageProfileFlag) Set(value string) error {
e.Name = append(e.Name, value)
return nil
}
func (flag *StorageProfileFlag) Register(ctx context.Context, f *flag.FlagSet) {
flag.ClientFlag.Register(ctx, f)
f.Var(flag, flag.option, "Storage profile name or ID")
}
func (flag *StorageProfileFlag) StorageProfileList(ctx context.Context) ([]string, error) {
if len(flag.Name) == 0 {
return nil, nil
}
c, err := flag.PbmClient()
if err != nil {
return nil, err
}
m, err := c.ProfileMap(ctx)
if err != nil {
return nil, err
}
list := make([]string, len(flag.Name))
for i, name := range flag.Name {
p, ok := m.Name[name]
if !ok {
return nil, fmt.Errorf("storage profile %q not found", name)
}
list[i] = p.GetPbmProfile().ProfileId.UniqueId
}
return list, nil
}
func (flag *StorageProfileFlag) StorageProfile(ctx context.Context) (string, error) {
switch len(flag.Name) {
case 0:
return "", nil
case 1:
default:
return "", errors.New("only 1 '-profile' can be specified")
}
list, err := flag.StorageProfileList(ctx)
if err != nil {
return "", err
}
return list[0], nil
}
func (flag *StorageProfileFlag) StorageProfileSpec(ctx context.Context) ([]types.BaseVirtualMachineProfileSpec, error) {
if len(flag.Name) == 0 {
return nil, nil
}
list, err := flag.StorageProfileList(ctx)
if err != nil {
return nil, err
}
spec := make([]types.BaseVirtualMachineProfileSpec, len(list))
for i, name := range list {
spec[i] = &types.VirtualMachineDefinedProfileSpec{
ProfileId: name,
}
}
return spec, nil
}

View file

@ -23,7 +23,7 @@ import (
"fmt"
"os"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/ovf"
"github.com/vmware/govmomi/ovf/importer"

View file

@ -20,7 +20,7 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/ovf/importer"
"github.com/vmware/govmomi/vim25/types"

View file

@ -21,8 +21,8 @@ import (
"errors"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/ovf/importer"
)

View file

@ -23,8 +23,8 @@ import (
"io"
"path"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/ovf/importer"
)

View file

@ -23,8 +23,8 @@ import (
"fmt"
"path"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/vmdk"
)

View file

@ -24,8 +24,8 @@ import (
"reflect"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/vim25/types"
)
@ -78,6 +78,7 @@ type change struct {
extraConfigFile extraConfigFile
Latency string
hwUpgradePolicy string
managedBy string
}
func init() {
@ -102,7 +103,11 @@ func (cmd *change) setLatency() error {
return fmt.Errorf("latency must be one of: %s", strings.Join(latencyLevels, "|"))
}
var hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
var (
hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
ftEncryptionModes = types.VirtualMachineConfigSpecEncryptedFtModes("").Strings()
migrateEncryptionModes = types.VirtualMachineConfigSpecEncryptedVMotionModes("").Strings()
)
// setHwUpgradePolicy validates hwUpgradePolicy if set
func (cmd *change) setHwUpgradePolicy() error {
@ -160,6 +165,7 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
f.StringVar(&cmd.Latency, "latency", "", fmt.Sprintf("Latency sensitivity (%s)", strings.Join(latencyLevels, "|")))
f.StringVar(&cmd.Annotation, "annotation", "", "VM description")
f.StringVar(&cmd.Uuid, "uuid", "", "BIOS UUID")
f.StringVar(&cmd.managedBy, "managed-by", "", "Set or clear managed by VC Extension")
f.Var(&cmd.extraConfig, "e", "ExtraConfig. <key>=<value>")
f.Var(&cmd.extraConfigFile, "f", "ExtraConfig. <key>=<absolute path to file>")
@ -174,6 +180,9 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
f.Var(flags.NewOptionalBool(&cmd.Flags.VvtdEnabled), "iommu-enabled", "Enable IOMMU")
f.StringVar(&cmd.hwUpgradePolicy, "scheduled-hw-upgrade-policy", "", fmt.Sprintf("Schedule hardware upgrade policy (%s)", strings.Join(hwUpgradePolicies, "|")))
f.StringVar(&cmd.FtEncryptionMode, "ft-encryption-mode", "", fmt.Sprintf("Encrypted fault tolerance mode (%s)", strings.Join(ftEncryptionModes, "|")))
f.StringVar(&cmd.MigrateEncryption, "migrate-encryption", "", fmt.Sprintf("Encrypted vMotion mode (%s)", strings.Join(migrateEncryptionModes, "|")))
}
func (cmd *change) Description() string {
@ -234,6 +243,18 @@ func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
return err
}
if cmd.managedBy != "" {
// From the VirtualMachineConfigSpec doc:
// To unset this field pass a ManagedByInfo object with an empty extensionKey
if cmd.managedBy == "-" {
cmd.managedBy = ""
}
cmd.ManagedBy = &types.ManagedByInfo{
Type: vm.Reference().Type,
ExtensionKey: cmd.managedBy,
}
}
task, err := vm.Reconfigure(ctx, cmd.VirtualMachineConfigSpec)
if err != nil {
return err

View file

@ -21,8 +21,8 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25"

View file

@ -24,8 +24,8 @@ import (
"net/url"
"os"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/session"
"github.com/vmware/govmomi/vim25/soap"

View file

@ -24,9 +24,9 @@ import (
"strings"
"text/tabwriter"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/units"
@ -51,6 +51,7 @@ type create struct {
*flags.HostSystemFlag
*flags.NetworkFlag
*flags.FolderFlag
*flags.StorageProfileFlag
name string
memory int
@ -60,11 +61,12 @@ type create struct {
on bool
force bool
controller string
eager bool
thick bool
annotation string
firmware string
version string
place bool
profile string
iso string
isoDatastoreFlag *flags.DatastoreFlag
@ -119,6 +121,9 @@ func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
cmd.FolderFlag, ctx = flags.NewFolderFlag(ctx)
cmd.FolderFlag.Register(ctx, f)
cmd.StorageProfileFlag, ctx = flags.NewStorageProfileFlag(ctx)
cmd.StorageProfileFlag.Register(ctx, f)
f.IntVar(&cmd.memory, "m", 1024, "Size in MB of memory")
f.IntVar(&cmd.cpus, "c", 1, "Number of CPUs")
f.StringVar(&cmd.guestID, "g", "otherGuest", "Guest OS ID")
@ -126,9 +131,10 @@ func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
f.BoolVar(&cmd.on, "on", true, "Power on VM")
f.BoolVar(&cmd.force, "force", false, "Create VM if vmx already exists")
f.StringVar(&cmd.controller, "disk.controller", "scsi", "Disk controller type")
f.BoolVar(&cmd.eager, "disk.eager", false, "Eagerly scrub new disk")
f.BoolVar(&cmd.thick, "disk.thick", false, "Thick provision new disk")
f.StringVar(&cmd.annotation, "annotation", "", "VM description")
f.StringVar(&cmd.firmware, "firmware", FirmwareTypes[0], FirmwareUsage)
f.StringVar(&cmd.profile, "profile", "", "Storage profile name or ID")
if cli.ShowUnreleased() {
f.BoolVar(&cmd.place, "place", false, "Place VM without creating")
}
@ -178,6 +184,9 @@ func (cmd *create) Process(ctx context.Context) error {
if err := cmd.FolderFlag.Process(ctx); err != nil {
return err
}
if err := cmd.StorageProfileFlag.Process(ctx); err != nil {
return err
}
// Default iso/disk datastores to the VM's datastore
if cmd.isoDatastoreFlag.Name == "" {
@ -411,22 +420,9 @@ func (cmd *create) createVM(ctx context.Context) (*object.Task, error) {
Version: cmd.version,
}
if cmd.profile != "" {
c, err := cmd.PbmClient()
if err != nil {
return nil, err
}
m, err := c.ProfileMap(ctx)
if err != nil {
return nil, err
}
p, ok := m.Name[cmd.profile]
if !ok {
return nil, fmt.Errorf("profile %q not found", cmd.profile)
}
spec.VmProfile = []types.BaseVirtualMachineProfileSpec{&types.VirtualMachineDefinedProfileSpec{
ProfileId: p.GetPbmProfile().ProfileId.UniqueId,
}}
spec.VmProfile, err = cmd.StorageProfileSpec(ctx)
if err != nil {
return nil, err
}
devices, err = cmd.addStorage(nil)
@ -558,13 +554,17 @@ func (cmd *create) addStorage(devices object.VirtualDeviceList) (object.VirtualD
return nil, err
}
backing := &types.VirtualDiskFlatVer2BackingInfo{
DiskMode: string(types.VirtualDiskModePersistent),
ThinProvisioned: types.NewBool(!cmd.thick),
}
if cmd.thick {
backing.EagerlyScrub = &cmd.eager
}
disk := &types.VirtualDisk{
VirtualDevice: types.VirtualDevice{
Key: devices.NewKey(),
Backing: &types.VirtualDiskFlatVer2BackingInfo{
DiskMode: string(types.VirtualDiskModePersistent),
ThinProvisioned: types.NewBool(true),
},
Key: devices.NewKey(),
Backing: backing,
},
CapacityInKB: cmd.diskByteSize / 1024,
}

View file

@ -23,8 +23,8 @@ import (
"strconv"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -21,7 +21,7 @@ import (
"flag"
"strconv"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -22,7 +22,7 @@ import (
"strconv"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -23,8 +23,8 @@ import (
"io"
"text/tabwriter"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/units"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"

View file

@ -22,7 +22,7 @@ import (
"io"
"os"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/vim25/progress"
)

View file

@ -20,7 +20,7 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -21,7 +21,7 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type getenv struct {

View file

@ -22,7 +22,7 @@ import (
"flag"
"net/url"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/guest"
"github.com/vmware/govmomi/guest/toolbox"
"github.com/vmware/govmomi/object"

View file

@ -20,7 +20,7 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type kill struct {

View file

@ -23,7 +23,7 @@ import (
"os"
"text/tabwriter"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/units"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/vim25/types"
)
@ -71,11 +71,8 @@ func (cmd *mkdir) Run(ctx context.Context, f *flag.FlagSet) error {
// ignore EEXIST if -p flag is given
if err != nil && cmd.createParents {
if soap.IsSoapFault(err) {
soapFault := soap.ToSoapFault(err)
if _, ok := soapFault.VimFault().(types.FileAlreadyExists); ok {
return nil
}
if fault.Is(err, &types.FileAlreadyExists{}) {
return nil
}
}

View file

@ -21,7 +21,7 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type mktemp struct {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/vim25/types"
)
@ -73,11 +73,8 @@ func (cmd *mv) Run(ctx context.Context, f *flag.FlagSet) error {
err = m.MoveFile(ctx, cmd.Auth(), src, dst, !cmd.noclobber)
if err != nil {
if soap.IsSoapFault(err) {
soapFault := soap.ToSoapFault(err)
if _, ok := soapFault.VimFault().(types.NotAFile); ok {
err = m.MoveDirectory(ctx, cmd.Auth(), src, dst)
}
if fault.Is(err, &types.NotAFile{}) {
err = m.MoveDirectory(ctx, cmd.Auth(), src, dst)
}
}

View file

@ -26,8 +26,8 @@ import (
"text/tabwriter"
"time"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -20,7 +20,7 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type rm struct {

View file

@ -20,7 +20,7 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type rmdir struct {

View file

@ -23,7 +23,7 @@ import (
"os"
"os/exec"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
)
type run struct {

View file

@ -22,7 +22,7 @@ import (
"fmt"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
)

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -22,7 +22,8 @@ import (
"flag"
"time"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
@ -96,9 +97,8 @@ func (cmd *touch) Run(ctx context.Context, f *flag.FlagSet) error {
}
err = m.ChangeFileAttributes(ctx, cmd.Auth(), name, &attr)
if err != nil && !cmd.nocreate && soap.IsSoapFault(err) {
fault := soap.ToSoapFault(err)
if _, ok := fault.VimFault().(types.FileNotFound); ok {
if err != nil && !cmd.nocreate {
if fault.Is(err, &types.FileNotFound{}) {
// create a new empty file
url, cerr := m.InitiateFileTransferToGuest(ctx, cmd.Auth(), name, &attr, 0, false)
if cerr != nil {

View file

@ -23,7 +23,7 @@ import (
"os"
"path/filepath"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/vim25/soap"
)

View file

@ -25,9 +25,9 @@ import (
"strings"
"text/tabwriter"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/units"

View file

@ -21,8 +21,8 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/types"

View file

@ -23,9 +23,9 @@ import (
"strings"
"time"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/govc/host/esxcli"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/esx"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
)
@ -123,7 +123,7 @@ func (cmd *ip) Run(ctx context.Context, f *flag.FlagSet) error {
if cmd.esx {
get = func(vm *object.VirtualMachine, deadline context.Context) (string, error) {
guest := esxcli.NewGuestInfo(c)
guest := esx.NewGuestInfo(c)
ticker := time.NewTicker(time.Millisecond * 500)
defer ticker.Stop()
@ -131,7 +131,7 @@ func (cmd *ip) Run(ctx context.Context, f *flag.FlagSet) error {
for {
select {
case <-ticker.C:
ip, err := guest.IpAddress(vm)
ip, err := guest.IpAddress(ctx, vm)
if err != nil {
return "", err
}

View file

@ -24,8 +24,8 @@ import (
"strconv"
"strings"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type markastemplate struct {

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type markasvm struct {

View file

@ -21,8 +21,8 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
)

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,10 +21,10 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/fault"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
@ -107,14 +107,7 @@ func (cmd *power) Process(ctx context.Context) error {
}
func isToolsUnavailable(err error) bool {
if soap.IsSoapFault(err) {
soapFault := soap.ToSoapFault(err)
if _, ok := soapFault.VimFault().(types.ToolsUnavailable); ok {
return ok
}
}
return false
return fault.Is(err, &types.ToolsUnavailable{})
}
// this is annoying, but the likely use cases for Datacenter.PowerOnVM outside of this command would

View file

@ -22,8 +22,8 @@ import (
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type register struct {

View file

@ -20,8 +20,8 @@ import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
)
type unregister struct {

Some files were not shown because too many files have changed in this diff Show more