Skip to content

Commit

Permalink
Reverting to switch block
Browse files Browse the repository at this point in the history
  • Loading branch information
amanpaha committed May 28, 2021
1 parent 7b961a8 commit b3d7bd7
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions simulator/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func NewVirtualMachine(ctx *Context, parent types.ManagedObjectReference, spec *
vm.Runtime.ConnectionState = types.VirtualMachineConnectionStateConnected
vm.Summary.Runtime = vm.Runtime

vm.Capability.ChangeTrackingSupported = changeTrackingSupported(spec)
vm.Capability.ChangeTrackingSupported = types.NewBool(changeTrackingSupported(spec))

vm.Summary.QuickStats.GuestHeartbeatStatus = types.ManagedEntityStatusGray
vm.Summary.OverallStatus = types.ManagedEntityStatusGreen
Expand Down Expand Up @@ -2240,31 +2240,22 @@ func allSnapshotsInTree(tree []types.VirtualMachineSnapshotTree) []types.Managed
return result
}

func changeTrackingSupported(spec *types.VirtualMachineConfigSpec) *bool {
supported := false
func changeTrackingSupported(spec *types.VirtualMachineConfigSpec) bool {
for _, device := range spec.DeviceChange {
if dev, ok := device.GetVirtualDeviceConfigSpec().Device.(*types.VirtualDisk); ok {

if _, ok := dev.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok {
supported = true
return &supported
}

if _, ok := dev.Backing.(*types.VirtualDiskSparseVer2BackingInfo); ok {
supported = true
return &supported
}

if _, ok := dev.Backing.(*types.VirtualDiskRawDiskMappingVer1BackingInfo); ok {
supported = true
return &supported
}

if _, ok := dev.Backing.(*types.VirtualDiskRawDiskVer2BackingInfo); ok {
supported = true
return &supported
switch dev.Backing.(type) {
case *types.VirtualDiskFlatVer2BackingInfo:
return true
case *types.VirtualDiskSparseVer2BackingInfo:
return true
case *types.VirtualDiskRawDiskMappingVer1BackingInfo:
return true
case *types.VirtualDiskRawDiskVer2BackingInfo:
return true
default:
return false
}
}
}
return &supported
return false
}

0 comments on commit b3d7bd7

Please sign in to comment.