Update osbuild/images to v0.40.0

In addition, simplify the SPEC file to not have to update the minimum
required osbuild version gazillion times, but just once.

Update the minimum required osbuild version to v109, due to changes in
grub2 stages required by the new osbuild/images version.

Update osbild SHA in Schutzfile to v109.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-02-22 21:55:33 +01:00 committed by Tomáš Hozza
parent c138ea6939
commit 2f087f1a6c
190 changed files with 57031 additions and 52810 deletions

View file

@ -9,7 +9,6 @@ Adam Chalkley <atc0005@users.noreply.github.com>
Adam Fowler <adam@adamfowler.org>
Adam Shannon <adamkshannon@gmail.com>
Akanksha Panse <pansea@vmware.com>
akutz <akutz@users.noreply.github.com>
Al Biheiri <abiheiri@apple.com>
Alessandro Cortiana <alessandro.cortiana@gmail.com>
Alex <puzo2002@gmail.com>
@ -49,15 +48,20 @@ Benjamin Vickers <bvickers@vmware.com>
Bhavya Choudhary <bhavyac@vmware.com>
Bob Killen <killen.bob@gmail.com>
Brad Fitzpatrick <bradfitz@golang.org>
Brian McClain <brianmmcclain@gmail.com>
Brian Rak <brak@vmware.com>
brian57860 <brian57860@users.noreply.github.com>
Bruce Downs <bruceadowns@gmail.com>
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>
Cheng Cheng <chengch@vmware.com>
Chethan Venkatesh <chethanv@vmware.com>
Choudhury Sarada Prasanna Nanda <cspn@google.com>
Chris Marchesi <chrism@vancluevertech.com>
Christian Höltje <docwhat@gerf.org>
Christian Schlotter <christi.schlotter@gmail.com>
Clint Greenwood <cgreenwood@vmware.com>
cpiment <pimentel.carlos@gmail.com>
CuiHaozhi <cuihaozhi@chinacloud.com.cn>
@ -76,25 +80,27 @@ Davide Agnello <dagnello@hp.com>
Davinder Kumar <davinderk@vmware.com>
Defa <zhoudefa666@163.com>
demarey <christophe.demarey@inria.fr>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Deric Crago <deric.crago@gmail.com>
Deyan Popov <deyan.popov@gmail.com>
Dinesh Bhat <35480850+dbhat-arkin@users.noreply.github.com>
ditsuke <ditsuke@protonmail.com>
Divyen Patel <divyenp@vmware.com>
Dnyanesh Gate <dnyanesh.gate@druva.com>
Doug MacEachern <dougm@vmware.com>
East <60801291+houfangdong@users.noreply.github.com>
Eloy Coto <eloy.coto@gmail.com>
embano1 <embano1@users.noreply.github.com>
Eng Zer Jun <engzerjun@gmail.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>
Essodjolo KAHANAM <essodjolo@kahanam.com>
Ethan Kaley <ethan.kaley@emc.com>
Evan Chu <echu@vmware.com>
Fabio Rapposelli <fabio@vmware.com>
fabriziopandini <fpandini@vmware.com>
Faiyaz Ahmed <faiyaza@vmware.com>
Federico Pellegatta <12744504+federico-pellegatta@users.noreply.github.com>
forkbomber <forkbomber@users.noreply.github.com>
@ -103,8 +109,10 @@ freebsdly <qinhuajun@outlook.com>
Gavin Gray <gavin@infinio.com>
Gavrie Philipson <gavrie.philipson@elastifile.com>
George Hicken <ghicken@vmware.com>
George Hicken <hickeng@users.noreply.github.com>
Gerrit Renker <Gerrit.Renker@ctl.io>
gthombare <gthombare@vmware.com>
guoguangwu <guoguangwu@magic-shield.com>
Hakan Halil <hhalil@vmware.com>
HakanSunay <hakansunay@abv.bg>
Hasan Mahmood <mahmoodh@vmware.com>
@ -127,18 +135,24 @@ Jiatong Wang <wjiatong@vmware.com>
jingyizPensando <jingyiz@pensando.io>
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>
Julien PILLON <jpillon@lesalternatives.org>
Justin J. Novack <jnovack@users.noreply.github.com>
kayrus <kay.diam@gmail.com>
Keenan Brock <keenan@thebrocks.net>
Kevin George <georgek@vmware.com>
Kiril Karaatanassov <kkaraatanassov@vmware.com>
Knappek <andy.knapp.ak@gmail.com>
Kristian Alvestad <kristian.alvestad@statnett.no>
Lars Lehtonen <lars.lehtonen@gmail.com>
Leslie Wang <qiwa@pensando.io>
leslie-qiwa <leslie.qiwa@gmail.com>
Lintong Jiang <lintongj@vmware.com>
Liping Xue <lipingx@vmware.com>
liron.levin <liron.levin@wiz.io>
Louie Jiang <jiangl@vmware.com>
Lubron Zhan <lzhan@vmware.com>
Luther Monson <luther.monson@gmail.com>
Madanagopal Arunachalam <marunachalam@vmware.com>
makelarisjr <8687447+makelarisjr@users.noreply.github.com>
@ -157,10 +171,10 @@ Matt Clay <matt@mystile.com>
Matt Moore <mattmoor@vmware.com>
Matt Moriarity <matt@mattmoriarity.com>
Matthew Cosgrove <matthew.cosgrove@dell.com>
Mayank Bhatt <bmayank@vmware.com>
mbhadale <mbhadale@vmware.com>
Merlijn Sebrechts <merlijn.sebrechts@gmail.com>
Mevan Samaratunga <mevansam@gmail.com>
Michael Gasch <15986659+embano1@users.noreply.github.com>
Michael Gasch <mgasch@vmware.com>
Michal Jankowski <mjankowski@vmware.com>
Mike Schinkel <mike@newclarity.net>
@ -188,6 +202,7 @@ rconde01 <rconde01@hotmail.com>
rHermes <teodor_spaeren@riseup.net>
Rianto Wahyudi <rwahyudi@gmail.com>
Ricardo Katz <rkatz@vmware.com>
rmcqueen <rmcqueen@vmware.com>
Robin Watkins <robwatkins@gmail.com>
Rowan Jacobs <rojacobs@pivotal.io>
Roy Ling <royling0024@gmail.com>
@ -200,6 +215,7 @@ Saad Malik <saad@spectrocloud.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>
Sergey Ignatov <sergey.ignatov@jetbrains.com>
serokles <timbo.alexander@gmail.com>
@ -233,7 +249,9 @@ tshihad <tshihad9@gmail.com>
Ueli Banholzer <ueli@whatwedo.ch>
Uwe Bessle <Uwe.Bessle@iteratec.de>
Vadim Egorov <vegorov@vmware.com>
Vamshik Shetty <svamshik@vmware.com>
Vikram Krishnamurthy <vikramkrishnamu@vmware.com>
Vipul Kotkar <vkotkar@vmware.com>
volanja <volaaanja@gmail.com>
Volodymyr Bobyr <pupsua@gmail.com>
Waldek Maleska <w.maleska@gmail.com>

View file

@ -392,9 +392,10 @@ func init() {
type CnsBlockBackingDetails struct {
CnsBackingObjectDetails
BackingDiskId string `xml:"backingDiskId,omitempty"`
BackingDiskUrlPath string `xml:"backingDiskUrlPath,omitempty"`
BackingDiskObjectId string `xml:"backingDiskObjectId,omitempty"`
BackingDiskId string `xml:"backingDiskId,omitempty"`
BackingDiskUrlPath string `xml:"backingDiskUrlPath,omitempty"`
BackingDiskObjectId string `xml:"backingDiskObjectId,omitempty"`
AggregatedSnapshotCapacityInMb int64 `xml:"aggregatedSnapshotCapacityInMb,omitempty"`
}
func init() {

View file

@ -835,7 +835,7 @@ func (f *Finder) networkByID(ctx context.Context, path string) (object.NetworkRe
}
defer v.Destroy(ctx)
filter := property.Filter{
filter := property.Match{
"config.logicalSwitchUuid": path,
"config.segmentId": path,
}

View file

@ -21,5 +21,5 @@ const (
ClientName = "govmomi"
// ClientVersion is the version of this SDK
ClientVersion = "0.34.2"
ClientVersion = "0.35.0"
)

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,
@ -18,6 +18,7 @@ package object
import (
"context"
"fmt"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/task"
@ -43,18 +44,53 @@ func NewTask(c *vim25.Client, ref types.ManagedObjectReference) *Task {
return &t
}
// Deprecated: Please use WaitEx instead.
func (t *Task) Wait(ctx context.Context) error {
_, err := t.WaitForResult(ctx, nil)
return err
}
func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (*types.TaskInfo, error) {
// Deprecated: Please use WaitForResultEx instead.
func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (taskInfo *types.TaskInfo, result error) {
var pr progress.Sinker
if len(s) == 1 {
pr = s[0]
}
p, err := property.DefaultCollector(t.c).Create(ctx)
if err != nil {
return nil, err
}
// Attempt to destroy the collector using the background context, as the
// specified context may have timed out or have been canceled.
defer func() {
if err := p.Destroy(context.Background()); err != nil {
if result == nil {
result = err
} else {
result = fmt.Errorf(
"destroy property collector failed with %s after failing to wait for updates: %w",
err,
result)
}
}
}()
return task.WaitEx(ctx, t.Reference(), p, pr)
}
func (t *Task) WaitEx(ctx context.Context) error {
_, err := t.WaitForResultEx(ctx, nil)
return err
}
func (t *Task) WaitForResultEx(ctx context.Context, s ...progress.Sinker) (*types.TaskInfo, error) {
var pr progress.Sinker
if len(s) == 1 {
pr = s[0]
}
p := property.DefaultCollector(t.c)
return task.Wait(ctx, t.Reference(), p, pr)
return task.WaitEx(ctx, t.Reference(), p, pr)
}
func (t *Task) Cancel(ctx context.Context) error {

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.
@ -19,6 +19,8 @@ package property
import (
"context"
"errors"
"fmt"
"sync"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/methods"
@ -27,11 +29,19 @@ import (
"github.com/vmware/govmomi/vim25/types"
)
// ErrConcurrentCollector is returned from WaitForUpdates, WaitForUpdatesEx,
// or CheckForUpdates if any of those calls are unable to obtain an exclusive
// lock for the property collector.
var ErrConcurrentCollector = fmt.Errorf(
"only one goroutine may invoke WaitForUpdates, WaitForUpdatesEx, " +
"or CheckForUpdates on a given PropertyCollector")
// Collector models the PropertyCollector managed object.
//
// For more information, see:
// http://pubs.vmware.com/vsphere-60/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvmodl.query.PropertyCollector.html
type Collector struct {
mu sync.Mutex
roundTripper soap.RoundTripper
reference types.ManagedObjectReference
}
@ -46,7 +56,7 @@ func DefaultCollector(c *vim25.Client) *Collector {
return &p
}
func (p Collector) Reference() types.ManagedObjectReference {
func (p *Collector) Reference() types.ManagedObjectReference {
return p.reference
}
@ -85,18 +95,28 @@ func (p *Collector) Destroy(ctx context.Context) error {
return nil
}
func (p *Collector) CreateFilter(ctx context.Context, req types.CreateFilter) error {
func (p *Collector) CreateFilter(ctx context.Context, req types.CreateFilter) (*Filter, error) {
req.This = p.Reference()
_, err := methods.CreateFilter(ctx, p.roundTripper, &req)
resp, err := methods.CreateFilter(ctx, p.roundTripper, &req)
if err != nil {
return err
return nil, err
}
return nil
return &Filter{roundTripper: p.roundTripper, reference: resp.Returnval}, nil
}
func (p *Collector) WaitForUpdates(ctx context.Context, version string, opts ...*types.WaitOptions) (*types.UpdateSet, error) {
// Deprecated: Please use WaitForUpdatesEx instead.
func (p *Collector) WaitForUpdates(
ctx context.Context,
version string,
opts ...*types.WaitOptions) (*types.UpdateSet, error) {
if !p.mu.TryLock() {
return nil, ErrConcurrentCollector
}
defer p.mu.Unlock()
req := types.WaitForUpdatesEx{
This: p.Reference(),
Version: version,
@ -187,8 +207,15 @@ func (p *Collector) Retrieve(ctx context.Context, objs []types.ManagedObjectRefe
return mo.LoadObjectContent(res.Returnval, dst)
}
// RetrieveWithFilter populates dst as Retrieve does, but only for entities matching the given filter.
func (p *Collector) RetrieveWithFilter(ctx context.Context, objs []types.ManagedObjectReference, ps []string, dst interface{}, filter Filter) error {
// RetrieveWithFilter populates dst as Retrieve does, but only for entities
// that match the specified filter.
func (p *Collector) RetrieveWithFilter(
ctx context.Context,
objs []types.ManagedObjectReference,
ps []string,
dst interface{},
filter Match) error {
if len(filter) == 0 {
return p.Retrieve(ctx, objs, ps, dst)
}
@ -200,7 +227,7 @@ func (p *Collector) RetrieveWithFilter(ctx context.Context, objs []types.Managed
return err
}
objs = filter.MatchObjectContent(content)
objs = filter.ObjectContent(content)
if len(objs) == 0 {
return nil
@ -214,3 +241,71 @@ func (p *Collector) RetrieveOne(ctx context.Context, obj types.ManagedObjectRefe
var objs = []types.ManagedObjectReference{obj}
return p.Retrieve(ctx, objs, ps, dst)
}
// WaitForUpdatesEx waits for any of the specified properties of the specified
// managed object to change. It calls the specified function for every update it
// receives. If this function returns false, it continues waiting for
// subsequent updates. If this function returns true, it stops waiting and
// returns.
//
// If the Context is canceled, a call to CancelWaitForUpdates() is made and its
// error value is returned.
//
// By default, ObjectUpdate.MissingSet faults are not propagated to the returned
// error, set WaitFilter.PropagateMissing=true to enable MissingSet fault
// propagation.
func (p *Collector) WaitForUpdatesEx(
ctx context.Context,
opts WaitOptions,
onUpdatesFn func([]types.ObjectUpdate) bool) error {
if !p.mu.TryLock() {
return ErrConcurrentCollector
}
defer p.mu.Unlock()
req := types.WaitForUpdatesEx{
This: p.Reference(),
Options: opts.Options,
}
for {
res, err := methods.WaitForUpdatesEx(ctx, p.roundTripper, &req)
if err != nil {
if ctx.Err() == context.Canceled {
return p.CancelWaitForUpdates(context.Background())
}
return err
}
set := res.Returnval
if set == nil {
if req.Options != nil && req.Options.MaxWaitSeconds != nil {
return nil // WaitOptions.MaxWaitSeconds exceeded
}
// Retry if the result came back empty
continue
}
req.Version = set.Version
opts.Truncated = false
if set.Truncated != nil {
opts.Truncated = *set.Truncated
}
for _, fs := range set.FilterSet {
if opts.PropagateMissing {
for i := range fs.ObjectSet {
for _, p := range fs.ObjectSet[i].MissingSet {
// Same behavior as mo.ObjectContentToType()
return soap.WrapVimFault(p.Fault.Fault)
}
}
}
if onUpdatesFn(fs.ObjectSet) {
return nil
}
}
}
}

View file

@ -1,5 +1,5 @@
/*
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.
@ -17,152 +17,38 @@ limitations under the License.
package property
import (
"fmt"
"path"
"reflect"
"strconv"
"strings"
"context"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
// Filter provides methods for matching against types.DynamicProperty
type Filter map[string]types.AnyType
// Keys returns the Filter map keys as a []string
func (f Filter) Keys() []string {
keys := make([]string, 0, len(f))
for key := range f {
keys = append(keys, key)
}
return keys
// Filter models the Filter managed object.
//
// For more information, see:
// https://vdc-download.vmware.com/vmwb-repository/dcr-public/184bb3ba-6fa8-4574-a767-d0c96e2a38f4/ba9422ef-405c-47dd-8553-e11b619185b2/SDK/vsphere-ws/docs/ReferenceGuide/vmodl.query.PropertyCollector.Filter.html.
type Filter struct {
roundTripper soap.RoundTripper
reference types.ManagedObjectReference
}
// MatchProperty returns true if a Filter entry matches the given prop.
func (f Filter) MatchProperty(prop types.DynamicProperty) bool {
if prop.Val == nil {
return false
}
match, ok := f[prop.Name]
if !ok {
return false
}
if match == prop.Val {
return true
}
ptype := reflect.TypeOf(prop.Val)
if strings.HasPrefix(ptype.Name(), "ArrayOf") {
pval := reflect.ValueOf(prop.Val).Field(0)
for i := 0; i < pval.Len(); i++ {
prop.Val = pval.Index(i).Interface()
if f.MatchProperty(prop) {
return true
}
}
return false
}
if reflect.TypeOf(match) != ptype {
s, ok := match.(string)
if !ok {
return false
}
// convert if we can
switch val := prop.Val.(type) {
case bool:
match, _ = strconv.ParseBool(s)
case int16:
x, _ := strconv.ParseInt(s, 10, 16)
match = int16(x)
case int32:
x, _ := strconv.ParseInt(s, 10, 32)
match = int32(x)
case int64:
match, _ = strconv.ParseInt(s, 10, 64)
case float32:
x, _ := strconv.ParseFloat(s, 32)
match = float32(x)
case float64:
match, _ = strconv.ParseFloat(s, 64)
case fmt.Stringer:
prop.Val = val.String()
case *types.CustomFieldStringValue:
prop.Val = fmt.Sprintf("%d:%s", val.Key, val.Value)
default:
if ptype.Kind() != reflect.String {
return false
}
// An enum type we can convert to a string type
prop.Val = reflect.ValueOf(prop.Val).String()
}
}
switch pval := prop.Val.(type) {
case string:
s := match.(string)
if s == "*" {
return true // TODO: path.Match fails if s contains a '/'
}
m, _ := path.Match(s, pval)
return m
default:
return reflect.DeepEqual(match, pval)
}
func (f Filter) Reference() types.ManagedObjectReference {
return f.reference
}
// MatchPropertyList returns true if all given props match the Filter.
func (f Filter) MatchPropertyList(props []types.DynamicProperty) bool {
for _, p := range props {
if !f.MatchProperty(p) {
return false
}
// Destroy destroys this filter.
//
// This operation can be called explicitly, or it can take place implicitly when
// the session that created the filter is closed.
func (f *Filter) Destroy(ctx context.Context) error {
if _, err := methods.DestroyPropertyFilter(
ctx,
f.roundTripper,
&types.DestroyPropertyFilter{This: f.Reference()}); err != nil {
return err
}
return len(f) == len(props) // false if a property such as VM "guest" is unset
}
// MatchObjectContent returns a list of ObjectContent.Obj where the ObjectContent.PropSet matches all properties the Filter.
func (f Filter) MatchObjectContent(objects []types.ObjectContent) []types.ManagedObjectReference {
var refs []types.ManagedObjectReference
for _, o := range objects {
if f.MatchPropertyList(o.PropSet) {
refs = append(refs, o.Obj)
}
}
return refs
}
// MatchAnyPropertyList returns true if any given props match the Filter.
func (f Filter) MatchAnyPropertyList(props []types.DynamicProperty) bool {
for _, p := range props {
if f.MatchProperty(p) {
return true
}
}
return false
}
// MatchAnyObjectContent returns a list of ObjectContent.Obj where the ObjectContent.PropSet matches any property in the Filter.
func (f Filter) MatchAnyObjectContent(objects []types.ObjectContent) []types.ManagedObjectReference {
var refs []types.ManagedObjectReference
for _, o := range objects {
if f.MatchAnyPropertyList(o.PropSet) {
refs = append(refs, o.Obj)
}
}
return refs
f.reference = types.ManagedObjectReference{}
return nil
}

170
vendor/github.com/vmware/govmomi/property/match.go generated vendored Normal file
View file

@ -0,0 +1,170 @@
/*
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
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 property
import (
"fmt"
"path"
"reflect"
"strconv"
"strings"
"github.com/vmware/govmomi/vim25/types"
)
// Match provides methods for matching against types.DynamicProperty
type Match map[string]types.AnyType
// Keys returns the Match map keys as a []string
func (m Match) Keys() []string {
keys := make([]string, 0, len(m))
for key := range m {
keys = append(keys, key)
}
return keys
}
// Property returns true if an entry matches the given prop.
func (m Match) Property(prop types.DynamicProperty) bool {
if prop.Val == nil {
return false
}
match, ok := m[prop.Name]
if !ok {
return false
}
if match == prop.Val {
return true
}
ptype := reflect.TypeOf(prop.Val)
if strings.HasPrefix(ptype.Name(), "ArrayOf") {
pval := reflect.ValueOf(prop.Val).Field(0)
for i := 0; i < pval.Len(); i++ {
prop.Val = pval.Index(i).Interface()
if m.Property(prop) {
return true
}
}
return false
}
if reflect.TypeOf(match) != ptype {
s, ok := match.(string)
if !ok {
return false
}
// convert if we can
switch val := prop.Val.(type) {
case bool:
match, _ = strconv.ParseBool(s)
case int16:
x, _ := strconv.ParseInt(s, 10, 16)
match = int16(x)
case int32:
x, _ := strconv.ParseInt(s, 10, 32)
match = int32(x)
case int64:
match, _ = strconv.ParseInt(s, 10, 64)
case float32:
x, _ := strconv.ParseFloat(s, 32)
match = float32(x)
case float64:
match, _ = strconv.ParseFloat(s, 64)
case fmt.Stringer:
prop.Val = val.String()
case *types.CustomFieldStringValue:
prop.Val = fmt.Sprintf("%d:%s", val.Key, val.Value)
default:
if ptype.Kind() != reflect.String {
return false
}
// An enum type we can convert to a string type
prop.Val = reflect.ValueOf(prop.Val).String()
}
}
switch pval := prop.Val.(type) {
case string:
s := match.(string)
if s == "*" {
return true // TODO: path.Match fails if s contains a '/'
}
m, _ := path.Match(s, pval)
return m
default:
return reflect.DeepEqual(match, pval)
}
}
// List returns true if all given props match.
func (m Match) List(props []types.DynamicProperty) bool {
for _, p := range props {
if !m.Property(p) {
return false
}
}
return len(m) == len(props) // false if a property such as VM "guest" is unset
}
// ObjectContent returns a list of ObjectContent.Obj where the
// ObjectContent.PropSet matches all properties the Filter.
func (m Match) ObjectContent(objects []types.ObjectContent) []types.ManagedObjectReference {
var refs []types.ManagedObjectReference
for _, o := range objects {
if m.List(o.PropSet) {
refs = append(refs, o.Obj)
}
}
return refs
}
// AnyList returns true if any given props match.
func (m Match) AnyList(props []types.DynamicProperty) bool {
for _, p := range props {
if m.Property(p) {
return true
}
}
return false
}
// AnyObjectContent returns a list of ObjectContent.Obj where the
// ObjectContent.PropSet matches any property.
func (m Match) AnyObjectContent(objects []types.ObjectContent) []types.ManagedObjectReference {
var refs []types.ManagedObjectReference
for _, o := range objects {
if m.AnyList(o.PropSet) {
refs = append(refs, o.Obj)
}
}
return refs
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2015-2017 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.
@ -18,18 +18,23 @@ package property
import (
"context"
"fmt"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
// WaitOptions defines options for a property collector's WaitForUpdatesEx
// method.
type WaitOptions struct {
Options *types.WaitOptions
PropagateMissing bool
Truncated bool
}
// WaitFilter provides helpers to construct a types.CreateFilter for use with property.Wait
type WaitFilter struct {
types.CreateFilter
Options *types.WaitOptions
PropagateMissing bool
Truncated bool
WaitOptions
}
// Add a new ObjectSpec and PropertySpec to the WaitFilter
@ -70,8 +75,8 @@ func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, p
})
}
// WaitForUpdates waits for any of the specified properties of the specified managed
// object to change. It calls the specified function for every update it
// WaitForUpdates waits for any of the specified properties of the specified
// managed object to change. It calls the specified function for every update it
// receives. If this function returns false, it continues waiting for
// subsequent updates. If this function returns true, it stops waiting and
// returns.
@ -80,14 +85,24 @@ func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, p
// creates a new property collector and calls CreateFilter. A new property
// collector is required because filters can only be added, not removed.
//
// If the Context is canceled, a call to CancelWaitForUpdates() is made and its error value is returned.
// The newly created collector is destroyed before this function returns (both
// in case of success or error).
// If the Context is canceled, a call to CancelWaitForUpdates() is made and its
// error value is returned. The newly created collector is destroyed before this
// function returns (both in case of success or error).
//
// By default, ObjectUpdate.MissingSet faults are not propagated to the returned error,
// set WaitFilter.PropagateMissing=true to enable MissingSet fault propagation.
func WaitForUpdates(ctx context.Context, c *Collector, filter *WaitFilter, f func([]types.ObjectUpdate) bool) error {
p, err := c.Create(ctx)
// By default, ObjectUpdate.MissingSet faults are not propagated to the returned
// error, set WaitFilter.PropagateMissing=true to enable MissingSet fault
// propagation.
//
// Deprecated: Please consider using WaitForUpdatesEx instead, as it does not
// create a new property collector, instead it destroys the property filter
// after the expected update is received.
func WaitForUpdates(
ctx context.Context,
c *Collector,
filter *WaitFilter,
onUpdatesFn func([]types.ObjectUpdate) bool) (result error) {
pc, err := c.Create(ctx)
if err != nil {
return err
}
@ -95,57 +110,65 @@ func WaitForUpdates(ctx context.Context, c *Collector, filter *WaitFilter, f fun
// Attempt to destroy the collector using the background context, as the
// specified context may have timed out or have been canceled.
defer func() {
_ = p.Destroy(context.Background())
if err := pc.Destroy(context.Background()); err != nil {
if result == nil {
result = err
} else {
result = fmt.Errorf(
"destroy property collector failed with %s after failing to wait for updates: %w",
err,
result)
}
}
}()
err = p.CreateFilter(ctx, filter.CreateFilter)
// Create a property filter for the property collector.
if _, err := pc.CreateFilter(ctx, filter.CreateFilter); err != nil {
return err
}
return pc.WaitForUpdatesEx(ctx, filter.WaitOptions, onUpdatesFn)
}
// WaitForUpdates waits for any of the specified properties of the specified
// managed object to change. It calls the specified function for every update it
// receives. If this function returns false, it continues waiting for
// subsequent updates. If this function returns true, it stops waiting and
// returns.
//
// If the Context is canceled, a call to CancelWaitForUpdates() is made and its
// error value is returned.
//
// By default, ObjectUpdate.MissingSet faults are not propagated to the returned
// error, set WaitFilter.PropagateMissing=true to enable MissingSet fault
// propagation.
func WaitForUpdatesEx(
ctx context.Context,
pc *Collector,
filter *WaitFilter,
onUpdatesFn func([]types.ObjectUpdate) bool) (result error) {
// Create a property filter for the property collector.
pf, err := pc.CreateFilter(ctx, filter.CreateFilter)
if err != nil {
return err
}
req := types.WaitForUpdatesEx{
This: p.Reference(),
Options: filter.Options,
}
for {
res, err := methods.WaitForUpdatesEx(ctx, p.roundTripper, &req)
if err != nil {
if ctx.Err() == context.Canceled {
werr := p.CancelWaitForUpdates(context.Background())
return werr
}
return err
}
set := res.Returnval
if set == nil {
if req.Options != nil && req.Options.MaxWaitSeconds != nil {
return nil // WaitOptions.MaxWaitSeconds exceeded
}
// Retry if the result came back empty
continue
}
req.Version = set.Version
filter.Truncated = false
if set.Truncated != nil {
filter.Truncated = *set.Truncated
}
for _, fs := range set.FilterSet {
if filter.PropagateMissing {
for i := range fs.ObjectSet {
for _, p := range fs.ObjectSet[i].MissingSet {
// Same behavior as mo.ObjectContentToType()
return soap.WrapVimFault(p.Fault.Fault)
}
}
}
if f(fs.ObjectSet) {
return nil
// Destroy the filter using the background context, as the specified context
// may have timed out or have been canceled.
defer func() {
if err := pf.Destroy(context.Background()); err != nil {
if result == nil {
result = err
} else {
result = fmt.Errorf(
"destroy property filter failed with %s after failing to wait for updates: %w",
err,
result)
}
}
}
}()
return pc.WaitForUpdatesEx(ctx, filter.WaitOptions, onUpdatesFn)
}

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.
@ -99,7 +99,7 @@ func (t *taskCallback) fn(pc []types.PropertyChange) bool {
}
}
// Wait waits for a task to finish with either success or failure. It does so
// WaitEx waits for a task to finish with either success or failure. It does so
// by waiting for the "info" property of task managed object to change. The
// function returns when it finds the task in the "success" or "error" state.
// In the former case, the return value is nil. In the latter case the return
@ -113,7 +113,12 @@ func (t *taskCallback) fn(pc []types.PropertyChange) bool {
// The detail for the progress update is set to an empty string. If the task
// finishes in the error state, the error instance is passed through as well.
// Note that this error is the same error that is returned by this function.
func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Collector, s progress.Sinker) (*types.TaskInfo, error) {
func WaitEx(
ctx context.Context,
ref types.ManagedObjectReference,
pc *property.Collector,
s progress.Sinker) (*types.TaskInfo, error) {
cb := &taskCallback{}
// Include progress sink if specified
@ -122,19 +127,29 @@ func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Co
defer close(cb.ch)
}
filter := &property.WaitFilter{PropagateMissing: true}
filter := &property.WaitFilter{
WaitOptions: property.WaitOptions{
PropagateMissing: true,
},
}
filter.Add(ref, ref.Type, []string{"info"})
err := property.WaitForUpdates(ctx, pc, filter, func(updates []types.ObjectUpdate) bool {
for _, update := range updates {
if cb.fn(update.ChangeSet) {
return true
if err := property.WaitForUpdatesEx(
ctx,
pc,
filter,
func(updates []types.ObjectUpdate) bool {
for _, update := range updates {
// Only look at updates for the expected task object.
if update.Obj == ref {
if cb.fn(update.ChangeSet) {
return true
}
}
}
}
return false
}); err != nil {
return false
})
if err != nil {
return nil, err
}

View file

@ -91,7 +91,7 @@ func (v ContainerView) Retrieve(ctx context.Context, kind []string, ps []string,
}
// RetrieveWithFilter populates dst as Retrieve does, but only for entities matching the given filter.
func (v ContainerView) RetrieveWithFilter(ctx context.Context, kind []string, ps []string, dst interface{}, filter property.Filter) error {
func (v ContainerView) RetrieveWithFilter(ctx context.Context, kind []string, ps []string, dst interface{}, filter property.Match) error {
if len(filter) == 0 {
return v.Retrieve(ctx, kind, ps, dst)
}
@ -103,7 +103,7 @@ func (v ContainerView) RetrieveWithFilter(ctx context.Context, kind []string, ps
return err
}
objs := filter.MatchObjectContent(content)
objs := filter.ObjectContent(content)
pc := property.DefaultCollector(v.Client())
@ -111,10 +111,10 @@ func (v ContainerView) RetrieveWithFilter(ctx context.Context, kind []string, ps
}
// Find returns object references for entities of type kind, matching the given filter.
func (v ContainerView) Find(ctx context.Context, kind []string, filter property.Filter) ([]types.ManagedObjectReference, error) {
func (v ContainerView) Find(ctx context.Context, kind []string, filter property.Match) ([]types.ManagedObjectReference, error) {
if len(filter) == 0 {
// Ensure we have at least 1 filter to avoid retrieving all properties.
filter = property.Filter{"name": "*"}
filter = property.Match{"name": "*"}
}
var content []types.ObjectContent
@ -124,14 +124,14 @@ func (v ContainerView) Find(ctx context.Context, kind []string, filter property.
return nil, err
}
return filter.MatchObjectContent(content), nil
return filter.ObjectContent(content), nil
}
// FindAny returns object references for entities of type kind, matching any property the given filter.
func (v ContainerView) FindAny(ctx context.Context, kind []string, filter property.Filter) ([]types.ManagedObjectReference, error) {
func (v ContainerView) FindAny(ctx context.Context, kind []string, filter property.Match) ([]types.ManagedObjectReference, error) {
if len(filter) == 0 {
// Ensure we have at least 1 filter to avoid retrieving all properties.
filter = property.Filter{"name": "*"}
filter = property.Match{"name": "*"}
}
var content []types.ObjectContent
@ -141,5 +141,5 @@ func (v ContainerView) FindAny(ctx context.Context, kind []string, filter proper
return nil, err
}
return filter.MatchAnyObjectContent(content), nil
return filter.AnyObjectContent(content), nil
}

View file

@ -34,7 +34,7 @@ func init() {
}
type AlarmManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DefaultExpression []types.BaseAlarmExpression `json:"defaultExpression"`
Description types.AlarmDescription `json:"description"`
@ -49,7 +49,7 @@ func init() {
}
type AuthorizationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
PrivilegeList []types.AuthorizationPrivilege `json:"privilegeList"`
RoleList []types.AuthorizationRole `json:"roleList"`
@ -65,7 +65,7 @@ func init() {
}
type CertificateManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m CertificateManager) Reference() types.ManagedObjectReference {
@ -153,7 +153,7 @@ func init() {
}
type CryptoManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Enabled bool `json:"enabled"`
}
@ -193,7 +193,7 @@ func init() {
}
type CustomFieldsManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Field []types.CustomFieldDef `json:"field"`
}
@ -207,7 +207,7 @@ func init() {
}
type CustomizationSpecManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Info []types.CustomizationSpecInfo `json:"info"`
EncryptionKey []byte `json:"encryptionKey"`
@ -262,7 +262,7 @@ func init() {
}
type DatastoreNamespaceManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m DatastoreNamespaceManager) Reference() types.ManagedObjectReference {
@ -274,7 +274,7 @@ func init() {
}
type DiagnosticManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m DiagnosticManager) Reference() types.ManagedObjectReference {
@ -318,7 +318,7 @@ func init() {
}
type DistributedVirtualSwitchManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m DistributedVirtualSwitchManager) Reference() types.ManagedObjectReference {
@ -330,7 +330,7 @@ func init() {
}
type EnvironmentBrowser struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DatastoreBrowser *types.ManagedObjectReference `json:"datastoreBrowser"`
}
@ -354,7 +354,7 @@ func init() {
}
type EventManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Description types.EventDescription `json:"description"`
LatestEvent types.BaseEvent `json:"latestEvent"`
@ -370,7 +370,7 @@ func init() {
}
type ExtensibleManagedObject struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Value []types.BaseCustomFieldValue `json:"value"`
AvailableField []types.CustomFieldDef `json:"availableField"`
@ -385,7 +385,7 @@ func init() {
}
type ExtensionManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ExtensionList []types.Extension `json:"extensionList"`
}
@ -399,7 +399,7 @@ func init() {
}
type FailoverClusterConfigurator struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DisabledConfigureMethod []string `json:"disabledConfigureMethod"`
}
@ -413,7 +413,7 @@ func init() {
}
type FailoverClusterManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DisabledClusterMethod []string `json:"disabledClusterMethod"`
}
@ -427,7 +427,7 @@ func init() {
}
type FileManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m FileManager) Reference() types.ManagedObjectReference {
@ -455,7 +455,7 @@ func init() {
}
type GuestAliasManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m GuestAliasManager) Reference() types.ManagedObjectReference {
@ -467,7 +467,7 @@ func init() {
}
type GuestAuthManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m GuestAuthManager) Reference() types.ManagedObjectReference {
@ -479,7 +479,7 @@ func init() {
}
type GuestFileManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m GuestFileManager) Reference() types.ManagedObjectReference {
@ -491,7 +491,7 @@ func init() {
}
type GuestOperationsManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
AuthManager *types.ManagedObjectReference `json:"authManager"`
FileManager *types.ManagedObjectReference `json:"fileManager"`
@ -509,7 +509,7 @@ func init() {
}
type GuestProcessManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m GuestProcessManager) Reference() types.ManagedObjectReference {
@ -521,7 +521,7 @@ func init() {
}
type GuestWindowsRegistryManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m GuestWindowsRegistryManager) Reference() types.ManagedObjectReference {
@ -533,7 +533,7 @@ func init() {
}
type HealthUpdateManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HealthUpdateManager) Reference() types.ManagedObjectReference {
@ -545,7 +545,7 @@ func init() {
}
type HistoryCollector struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Filter types.AnyType `json:"filter"`
}
@ -559,7 +559,7 @@ func init() {
}
type HostAccessManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
LockdownMode types.HostLockdownMode `json:"lockdownMode"`
}
@ -581,7 +581,7 @@ func init() {
}
type HostAssignableHardwareManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Binding []types.HostAssignableHardwareBinding `json:"binding"`
Config types.HostAssignableHardwareConfig `json:"config"`
@ -596,7 +596,7 @@ func init() {
}
type HostAuthenticationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Info types.HostAuthenticationManagerInfo `json:"info"`
SupportedStore []types.ManagedObjectReference `json:"supportedStore"`
@ -611,7 +611,7 @@ func init() {
}
type HostAuthenticationStore struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Info types.BaseHostAuthenticationStoreInfo `json:"info"`
}
@ -625,7 +625,7 @@ func init() {
}
type HostAutoStartManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Config types.HostAutoStartManagerConfig `json:"config"`
}
@ -639,7 +639,7 @@ func init() {
}
type HostBootDeviceSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostBootDeviceSystem) Reference() types.ManagedObjectReference {
@ -651,7 +651,7 @@ func init() {
}
type HostCacheConfigurationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
CacheConfigurationInfo []types.HostCacheConfigurationInfo `json:"cacheConfigurationInfo"`
}
@ -665,7 +665,7 @@ func init() {
}
type HostCertificateManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
CertificateInfo types.HostCertificateManagerCertificateInfo `json:"certificateInfo"`
}
@ -689,7 +689,7 @@ func init() {
}
type HostDatastoreBrowser struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Datastore []types.ManagedObjectReference `json:"datastore"`
SupportedType []types.BaseFileQuery `json:"supportedType"`
@ -704,7 +704,7 @@ func init() {
}
type HostDatastoreSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Datastore []types.ManagedObjectReference `json:"datastore"`
Capabilities types.HostDatastoreSystemCapabilities `json:"capabilities"`
@ -719,7 +719,7 @@ func init() {
}
type HostDateTimeSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DateTimeInfo types.HostDateTimeInfo `json:"dateTimeInfo"`
}
@ -733,7 +733,7 @@ func init() {
}
type HostDiagnosticSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ActivePartition *types.HostDiagnosticPartition `json:"activePartition"`
}
@ -755,7 +755,7 @@ func init() {
}
type HostEsxAgentHostManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ConfigInfo types.HostEsxAgentHostManagerConfigInfo `json:"configInfo"`
}
@ -779,7 +779,7 @@ func init() {
}
type HostFirmwareSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostFirmwareSystem) Reference() types.ManagedObjectReference {
@ -804,7 +804,7 @@ func init() {
}
type HostHealthStatusSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Runtime types.HealthSystemRuntime `json:"runtime"`
}
@ -818,7 +818,7 @@ func init() {
}
type HostImageConfigManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostImageConfigManager) Reference() types.ManagedObjectReference {
@ -830,7 +830,7 @@ func init() {
}
type HostKernelModuleSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostKernelModuleSystem) Reference() types.ManagedObjectReference {
@ -842,7 +842,7 @@ func init() {
}
type HostLocalAccountManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostLocalAccountManager) Reference() types.ManagedObjectReference {
@ -889,7 +889,7 @@ func init() {
}
type HostNvdimmSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
NvdimmSystemInfo types.NvdimmSystemInfo `json:"nvdimmSystemInfo"`
}
@ -903,7 +903,7 @@ func init() {
}
type HostPatchManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostPatchManager) Reference() types.ManagedObjectReference {
@ -926,7 +926,7 @@ func init() {
}
type HostPowerSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Capability types.PowerSystemCapability `json:"capability"`
Info types.PowerSystemInfo `json:"info"`
@ -972,7 +972,7 @@ func init() {
}
type HostSnmpSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Configuration types.HostSnmpConfigSpec `json:"configuration"`
Limits types.HostSnmpSystemAgentLimits `json:"limits"`
@ -987,7 +987,7 @@ func init() {
}
type HostSpecificationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostSpecificationManager) Reference() types.ManagedObjectReference {
@ -1044,7 +1044,7 @@ func init() {
}
type HostVFlashManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
VFlashConfigInfo *types.HostVFlashManagerVFlashConfigInfo `json:"vFlashConfigInfo"`
}
@ -1087,7 +1087,7 @@ func init() {
}
type HostVsanInternalSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m HostVsanInternalSystem) Reference() types.ManagedObjectReference {
@ -1099,7 +1099,7 @@ func init() {
}
type HostVsanSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Config types.VsanHostConfigInfo `json:"config"`
}
@ -1113,7 +1113,7 @@ func init() {
}
type HttpNfcLease struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
InitializeProgress int32 `json:"initializeProgress"`
TransferProgress int32 `json:"transferProgress"`
@ -1141,7 +1141,7 @@ func init() {
}
type IoFilterManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m IoFilterManager) Reference() types.ManagedObjectReference {
@ -1153,7 +1153,7 @@ func init() {
}
type IpPoolManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m IpPoolManager) Reference() types.ManagedObjectReference {
@ -1165,7 +1165,7 @@ func init() {
}
type IscsiManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m IscsiManager) Reference() types.ManagedObjectReference {
@ -1177,7 +1177,7 @@ func init() {
}
type LicenseAssignmentManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m LicenseAssignmentManager) Reference() types.ManagedObjectReference {
@ -1189,7 +1189,7 @@ func init() {
}
type LicenseManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Source types.BaseLicenseSource `json:"source"`
SourceAvailable bool `json:"sourceAvailable"`
@ -1218,7 +1218,7 @@ func init() {
}
type LocalizationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Catalog []types.LocalizationManagerMessageCatalog `json:"catalog"`
}
@ -1255,7 +1255,7 @@ func init() {
}
type ManagedObjectView struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
View []types.ManagedObjectReference `json:"view"`
}
@ -1269,7 +1269,7 @@ func init() {
}
type MessageBusProxy struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m MessageBusProxy) Reference() types.ManagedObjectReference {
@ -1309,7 +1309,7 @@ func init() {
}
type OptionManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
SupportedOption []types.OptionDef `json:"supportedOption"`
Setting []types.BaseOptionValue `json:"setting"`
@ -1324,7 +1324,7 @@ func init() {
}
type OverheadMemoryManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m OverheadMemoryManager) Reference() types.ManagedObjectReference {
@ -1336,7 +1336,7 @@ func init() {
}
type OvfManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
OvfImportOption []types.OvfOptionInfo `json:"ovfImportOption"`
OvfExportOption []types.OvfOptionInfo `json:"ovfExportOption"`
@ -1351,7 +1351,7 @@ func init() {
}
type PerformanceManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Description types.PerformanceDescription `json:"description"`
HistoricalInterval []types.PerfInterval `json:"historicalInterval"`
@ -1367,7 +1367,7 @@ func init() {
}
type Profile struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Config types.BaseProfileConfigInfo `json:"config"`
Description *types.ProfileDescription `json:"description"`
@ -1387,7 +1387,7 @@ func init() {
}
type ProfileComplianceManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m ProfileComplianceManager) Reference() types.ManagedObjectReference {
@ -1399,7 +1399,7 @@ func init() {
}
type ProfileManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Profile []types.ManagedObjectReference `json:"profile"`
}
@ -1413,7 +1413,7 @@ func init() {
}
type PropertyCollector struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Filter []types.ManagedObjectReference `json:"filter"`
}
@ -1427,7 +1427,7 @@ func init() {
}
type PropertyFilter struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Spec types.PropertyFilterSpec `json:"spec"`
PartialUpdates bool `json:"partialUpdates"`
@ -1442,7 +1442,7 @@ func init() {
}
type ResourcePlanningManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m ResourcePlanningManager) Reference() types.ManagedObjectReference {
@ -1485,7 +1485,7 @@ func init() {
}
type ScheduledTaskManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ScheduledTask []types.ManagedObjectReference `json:"scheduledTask"`
Description types.ScheduledTaskDescription `json:"description"`
@ -1500,7 +1500,7 @@ func init() {
}
type SearchIndex struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m SearchIndex) Reference() types.ManagedObjectReference {
@ -1512,7 +1512,7 @@ func init() {
}
type ServiceInstance struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ServerClock time.Time `json:"serverClock"`
Capability types.Capability `json:"capability"`
@ -1528,7 +1528,7 @@ func init() {
}
type ServiceManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
Service []types.ServiceManagerServiceInfo `json:"service"`
}
@ -1542,7 +1542,7 @@ func init() {
}
type SessionManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
SessionList []types.UserSession `json:"sessionList"`
CurrentSession *types.UserSession `json:"currentSession"`
@ -1561,7 +1561,7 @@ func init() {
}
type SimpleCommand struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
EncodingType types.SimpleCommandEncoding `json:"encodingType"`
Entity types.ServiceManagerServiceInfo `json:"entity"`
@ -1576,7 +1576,7 @@ func init() {
}
type SiteInfoManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m SiteInfoManager) Reference() types.ManagedObjectReference {
@ -1599,7 +1599,7 @@ func init() {
}
type StorageQueryManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m StorageQueryManager) Reference() types.ManagedObjectReference {
@ -1611,7 +1611,7 @@ func init() {
}
type StorageResourceManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m StorageResourceManager) Reference() types.ManagedObjectReference {
@ -1643,7 +1643,7 @@ func init() {
}
type TaskManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
RecentTask []types.ManagedObjectReference `json:"recentTask"`
Description types.TaskDescription `json:"description"`
@ -1659,7 +1659,7 @@ func init() {
}
type TenantTenantManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m TenantTenantManager) Reference() types.ManagedObjectReference {
@ -1671,7 +1671,7 @@ func init() {
}
type UserDirectory struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
DomainList []string `json:"domainList"`
}
@ -1685,7 +1685,7 @@ func init() {
}
type VStorageObjectManagerBase struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VStorageObjectManagerBase) Reference() types.ManagedObjectReference {
@ -1705,7 +1705,7 @@ func init() {
}
type View struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m View) Reference() types.ManagedObjectReference {
@ -1717,7 +1717,7 @@ func init() {
}
type ViewManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
ViewList []types.ManagedObjectReference `json:"viewList"`
}
@ -1746,7 +1746,7 @@ func init() {
}
type VirtualDiskManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VirtualDiskManager) Reference() types.ManagedObjectReference {
@ -1788,7 +1788,7 @@ func init() {
}
type VirtualMachineCompatibilityChecker struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VirtualMachineCompatibilityChecker) Reference() types.ManagedObjectReference {
@ -1800,7 +1800,7 @@ func init() {
}
type VirtualMachineGuestCustomizationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VirtualMachineGuestCustomizationManager) Reference() types.ManagedObjectReference {
@ -1812,7 +1812,7 @@ func init() {
}
type VirtualMachineProvisioningChecker struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VirtualMachineProvisioningChecker) Reference() types.ManagedObjectReference {
@ -1836,7 +1836,7 @@ func init() {
}
type VirtualizationManager struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VirtualizationManager) Reference() types.ManagedObjectReference {
@ -1856,7 +1856,7 @@ func init() {
}
type VsanUpgradeSystem struct {
Self types.ManagedObjectReference
Self types.ManagedObjectReference `json:"self"`
}
func (m VsanUpgradeSystem) Reference() types.ManagedObjectReference {

View file

@ -77,7 +77,11 @@ func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
for _, p := range changes {
rv, ok := t.props[p.Name]
if !ok {
panic(p.Name + " not found")
// For now, skip unknown properties allowing PC updates to be triggered
// for partial updates (e.g. extensionList["my.extension"]).
// Ultimately we should support partial updates by assigning the value
// reflectively in assignValue.
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))

View file

@ -59,9 +59,10 @@ const (
)
// defaultUserAgent is the default user agent string, e.g.
// "govmomi/0.28.0 (go1.18.3;linux;amd64)"
// "govc govmomi/0.28.0 (go1.18.3;linux;amd64)"
var defaultUserAgent = fmt.Sprintf(
"%s/%s (%s)",
"%s %s/%s (%s)",
execName(),
version.ClientName,
version.ClientVersion,
strings.Join([]string{runtime.Version(), runtime.GOOS, runtime.GOARCH}, ";"),
@ -927,3 +928,12 @@ func (c *Client) DownloadFile(ctx context.Context, file string, u *url.URL, para
return c.WriteFile(ctx, file, rc, contentLength, param.Progress, param.Writer)
}
// execName gets the name of the executable for the current process
func execName() string {
name, err := os.Executable()
if err != nil {
return "N/A"
}
return strings.TrimSuffix(filepath.Base(name), ".exe")
}