vsphere/internal/virtualdevice/virtual_machine_disk_subresource.go
func (r *Subresource) findControllerInfo(l object.VirtualDeviceList, disk *types.VirtualDisk) (int, types.BaseVirtualController, error) {
	ctlr := l.FindByKey(disk.ControllerKey)
	if ctlr == nil {
		return -1, nil, fmt.Errorf("could not find disk controller with key %d for disk key %d", disk.ControllerKey, disk.Key)
	}
	if disk.UnitNumber == nil {
		return -1, nil, fmt.Errorf("unit number on disk key %d is unset", disk.Key)
	}
	sc, ok := ctlr.(types.BaseVirtualSCSIController)
	if !ok {
		return -1, nil, fmt.Errorf("controller at key %d is not a SCSI controller (actual: %T)", ctlr.GetVirtualDevice().Key, ctlr)
	}
	unit := *disk.UnitNumber
	if unit > sc.GetVirtualSCSIController().ScsiCtlrUnitNumber {
		unit--
	}
	unit = unit + 15*sc.GetVirtualSCSIController().BusNumber
	return int(unit), ctlr.(types.BaseVirtualController), nil
}
func (r *Subresource) findControllerInfo(l object.VirtualDeviceList, disk *types.VirtualDisk) (int, types.BaseVirtualController, error) {
	ctlr := l.FindByKey(disk.ControllerKey)
	if ctlr == nil {
		return -1, nil, fmt.Errorf("could not find disk controller with key %d for disk key %d", disk.ControllerKey, disk.Key)
	}
	if disk.UnitNumber == nil {
		return -1, nil, fmt.Errorf("unit number on disk key %d is unset", disk.Key)
	}
	sc, ok := ctlr.(types.BaseVirtualSCSIController)
	if !ok {
		return -1, nil, fmt.Errorf("controller at key %d is not a SCSI controller (actual: %T)", ctlr.GetVirtualDevice().Key, ctlr)
	}
	unit := *disk.UnitNumber
	if unit > sc.GetVirtualSCSIController().ScsiCtlrUnitNumber {
		unit--
	}
	unit = unit + 15*sc.GetVirtualSCSIController().BusNumber
	return int(unit), ctlr.(types.BaseVirtualController), nil
}
func ( r * Subresource ) findControllerInfo ( l object . VirtualDeviceList , disk * types . VirtualDisk ) ( int , types . BaseVirtualController , error ) { ctlr := l . FindByKey ( disk . ControllerKey ) if ctlr == nil { return - 1 , nil , fmt . Errorf ( " " , disk . ControllerKey , disk . Key ) } if disk . UnitNumber == nil { return - 1 , nil , fmt . Errorf ( " " , disk . Key ) } sc , ok := ctlr . ( types . BaseVirtualSCSIController ) if ! ok { return - 1 , nil , fmt . Errorf ( " " , ctlr . GetVirtualDevice ( ) . Key , ctlr ) } unit := * disk . UnitNumber if unit > sc . GetVirtualSCSIController ( ) . ScsiCtlrUnitNumber { unit -- } unit = unit + 15 * sc . GetVirtualSCSIController ( ) . BusNumber return int ( unit ) , ctlr . ( types . BaseVirtualController ) , nil }
// findControllerInfo determines the normalized unit number for the disk device
// based on the SCSI controller and unit number it's connected to. The
// controller is also returned.
findControllerInfo determines the normalized unit number for the disk device based on the SCSI controller and unit number it s connected to . The controller is also returned .