From a03f4735570027d2e6e2bc9cb7584a0af19f9353 Mon Sep 17 00:00:00 2001 From: akutz Date: Mon, 25 Sep 2023 08:41:44 -0500 Subject: [PATCH] api: Fix errors w 8.0U2 GA update This patch addresses a build error after the update to 8.0U2 GA. The VSLM client was using an invalid API syntax. Additionally, there was a fix for the change from the "mo" field tag to using "json" instead. --- govc/test/cluster.bats | 8 ++++---- govc/test/fields.bats | 2 +- govc/test/host.bats | 2 +- govc/test/import.bats | 2 +- govc/test/library.bats | 2 +- govc/test/session.bats | 4 ++-- govc/test/vcsim.bats | 4 ++-- govc/test/vm.bats | 2 +- vim25/mo/retrieve.go | 2 +- vim25/mo/type_info.go | 5 ++++- vslm/object_manager.go | 6 +++++- 11 files changed, 23 insertions(+), 16 deletions(-) diff --git a/govc/test/cluster.bats b/govc/test/cluster.bats index de96a021e..681a927c9 100755 --- a/govc/test/cluster.bats +++ b/govc/test/cluster.bats @@ -243,17 +243,17 @@ _EOF_ vcsim_env unset GOVC_HOST - ip=$(govc object.collect -o -json host/DC0_C0/DC0_C0_H0 | jq -r .Config.network.vnic[].spec.ip.ipAddress) + ip=$(govc object.collect -o -json host/DC0_C0/DC0_C0_H0 | jq -r .config.network.vnic[].spec.ip.ipAddress) assert_equal 127.0.0.1 "$ip" govc cluster.add -cluster DC0_C0 -hostname 10.0.0.42 -username user -password pass assert_success - ip=$(govc object.collect -o -json host/DC0_C0/10.0.0.42 | jq -r .Config.network.vnic[].spec.ip.ipAddress) + ip=$(govc object.collect -o -json host/DC0_C0/10.0.0.42 | jq -r .config.network.vnic[].spec.ip.ipAddress) assert_equal 10.0.0.42 "$ip" - govc host.info -json '*' | jq -r .HostSystems[].Config.network.vnic[].spec.ip - name=$(govc host.info -json -host.ip 10.0.0.42 | jq -r .HostSystems[].Name) + govc host.info -json '*' | jq -r .HostSystems[].config.network.vnic[].spec.ip + name=$(govc host.info -json -host.ip 10.0.0.42 | jq -r .HostSystems[].name) assert_equal 10.0.0.42 "$name" } diff --git a/govc/test/fields.bats b/govc/test/fields.bats index ceeae37a1..2712eaeae 100755 --- a/govc/test/fields.bats +++ b/govc/test/fields.bats @@ -38,7 +38,7 @@ load test_helper run govc fields.info -n $val vm/$vm_id assert_success - info=$(govc vm.info -json $vm_id | jq .VirtualMachines[0].CustomValue[0]) + info=$(govc vm.info -json $vm_id | jq .VirtualMachines[0].customValue[0]) ikey=$(jq -r .key <<<"$info") assert_equal $key $ikey diff --git a/govc/test/host.bats b/govc/test/host.bats index 521473570..a2e5ff52b 100755 --- a/govc/test/host.bats +++ b/govc/test/host.bats @@ -74,7 +74,7 @@ load test_helper run govc host.info -host.dns $(basename "$name") assert_failure # TODO: SearchIndex:SearchIndex does not implement: FindByDnsName - uuid=$(govc host.info -host "$name" -json | jq -r .HostSystems[].Summary.hardware.uuid) + uuid=$(govc host.info -host "$name" -json | jq -r .HostSystems[].summary.hardware.uuid) run govc host.info -host.uuid "$uuid" assert_success diff --git a/govc/test/import.bats b/govc/test/import.bats index 77855206d..15edf1884 100755 --- a/govc/test/import.bats +++ b/govc/test/import.bats @@ -16,7 +16,7 @@ load test_helper assert_success # link ovf/ova to datastore so we can test with an http source - dir=$(govc datastore.info -json | jq -r .Datastores[].Info.url) + dir=$(govc datastore.info -json | jq -r .Datastores[].info.url) ln -s "$GOVC_IMAGES/$TTYLINUX_NAME."* "$dir" run govc import.spec "https://$(govc env GOVC_URL)/folder/$TTYLINUX_NAME.ovf" diff --git a/govc/test/library.bats b/govc/test/library.bats index 762abc78f..88598c878 100755 --- a/govc/test/library.bats +++ b/govc/test/library.bats @@ -184,7 +184,7 @@ load test_helper library_id="$output" # link ovf/ova to datastore so we can test library.import with an http source - dir=$(govc datastore.info -json | jq -r .Datastores[].Info.url) + dir=$(govc datastore.info -json | jq -r .Datastores[].info.url) ln -s "$GOVC_IMAGES/$TTYLINUX_NAME."* "$dir" run govc library.import -pull my-content "https://$(govc env GOVC_URL)/folder/$TTYLINUX_NAME.ovf" diff --git a/govc/test/session.bats b/govc/test/session.bats index 1c45be6f6..4e34aa392 100755 --- a/govc/test/session.bats +++ b/govc/test/session.bats @@ -32,12 +32,12 @@ load test_helper assert_failure # NotFound # Can't remove the current session - id=$(govc session.ls -json | jq -r .CurrentSession.key) + id=$(govc session.ls -json | jq -r .currentSession.key) run govc session.rm "$id" assert_failure thumbprint=$(govc about.cert -thumbprint) - id=$(govc session.ls -json -k=false -tls-known-hosts <(echo "$thumbprint") | jq -r .CurrentSession.key) + id=$(govc session.ls -json -k=false -tls-known-hosts <(echo "$thumbprint") | jq -r .currentSession.key) rm -rf "$dir" diff --git a/govc/test/vcsim.bats b/govc/test/vcsim.bats index 4c9bb850c..125fb1d1f 100755 --- a/govc/test/vcsim.bats +++ b/govc/test/vcsim.bats @@ -128,7 +128,7 @@ EOF run govc object.collect -s $vm summary.guest.ipAddress assert_success "10.0.0.1" - netip=$(govc object.collect -json -o $vm guest.net | jq -r .Guest.net[].ipAddress[0]) + netip=$(govc object.collect -json -o $vm guest.net | jq -r .guest.net[].ipAddress[0]) [ "$netip" = "10.0.0.1" ] run govc vm.info -vm.ip 10.0.0.1 @@ -268,7 +268,7 @@ EOF run govc object.collect -s vm/$vm summary.guest.ipAddress assert_success "$ip" - netip=$(govc object.collect -json -o vm/$vm guest.net | jq -r .Guest.net[].ipAddress[0]) + netip=$(govc object.collect -json -o vm/$vm guest.net | jq -r .guest.net[].ipAddress[0]) [ "$netip" = "$ip" ] run govc vm.ip $vm # covers VirtualMachine.WaitForIP diff --git a/govc/test/vm.bats b/govc/test/vm.bats index 3107b5ee2..af787ad7b 100755 --- a/govc/test/vm.bats +++ b/govc/test/vm.bats @@ -480,7 +480,7 @@ load test_helper run govc vm.change -nested-hv-enabled=true -vm "$id" assert_success - hv=$(govc vm.info -json "$id" | jq '.[][0].Config.nestedHVEnabled') + hv=$(govc vm.info -json "$id" | jq '.[][0].config.nestedHVEnabled') assert_equal "$hv" "true" } diff --git a/vim25/mo/retrieve.go b/vim25/mo/retrieve.go index e877da063..0ddf78eb9 100644 --- a/vim25/mo/retrieve.go +++ b/vim25/mo/retrieve.go @@ -77,7 +77,7 @@ func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) { for _, p := range changes { rv, ok := t.props[p.Name] if !ok { - continue + panic(p.Name + " not found") } assignValue(v, rv, reflect.ValueOf(p.Val)) diff --git a/vim25/mo/type_info.go b/vim25/mo/type_info.go index 0a2c229d2..3b1ccce2d 100644 --- a/vim25/mo/type_info.go +++ b/vim25/mo/type_info.go @@ -82,7 +82,10 @@ func buildName(fn string, f reflect.StructField) string { motag := f.Tag.Get("json") if motag != "" { - return fn + motag + tokens := strings.Split(motag, ",") + if tokens[0] != "" { + return fn + tokens[0] + } } xmltag := f.Tag.Get("xml") diff --git a/vslm/object_manager.go b/vslm/object_manager.go index 9add57c0e..7e49cf0bc 100644 --- a/vslm/object_manager.go +++ b/vslm/object_manager.go @@ -250,7 +250,11 @@ func (m ObjectManager) RegisterDisk(ctx context.Context, path, name string) (*ty return &res.Returnval, nil } - res, err := methods.HostRegisterDisk(ctx, m.c, (*types.HostRegisterDisk)(&req)) + res, err := methods.HostRegisterDisk(ctx, m.c, &types.HostRegisterDisk{ + This: m.Reference(), + Path: path, + Name: name, + }) if err != nil { return nil, err }