Skip to content

Commit

Permalink
api: Fix errors w 8.0U2 GA update
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akutz committed Sep 25, 2023
1 parent 515df5d commit a03f473
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 16 deletions.
8 changes: 4 additions & 4 deletions govc/test/cluster.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion govc/test/fields.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion govc/test/host.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion govc/test/import.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion govc/test/library.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions govc/test/session.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions govc/test/vcsim.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion govc/test/vm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion vim25/mo/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion vim25/mo/type_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion vslm/object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a03f473

Please sign in to comment.