// Returns key of the controller. // Key is unique id that distinguishes one device from other devices in the same virtual machine. func getControllerKey(scsiType string, vmDevices object.VirtualDeviceList, dc *object.Datacenter, client *govmomi.Client) (int32, error) { for _, device := range vmDevices { devType := vmDevices.Type(device) if devType == scsiType { if c, ok := device.(types.BaseVirtualController); ok { return c.GetVirtualController().Key, nil } } } return -1, ErrNoDevicesFound }
func getSCSIController(vmDevices object.VirtualDeviceList, scsiType string) *types.VirtualController { // get virtual scsi controller of passed argument type for _, device := range vmDevices { devType := vmDevices.Type(device) if devType == scsiType { if c, ok := device.(types.BaseVirtualController); ok { return c.GetVirtualController() } } } return nil }
func getSCSIControllersOfType(vmDevices object.VirtualDeviceList, scsiType string) []*types.VirtualController { // get virtual scsi controllers of passed argument type var scsiControllers []*types.VirtualController for _, device := range vmDevices { devType := vmDevices.Type(device) if devType == scsiType { if c, ok := device.(types.BaseVirtualController); ok { scsiControllers = append(scsiControllers, c.GetVirtualController()) } } } return scsiControllers }
func getSCSIControllers(vmDevices object.VirtualDeviceList) []*types.VirtualController { // get all virtual scsi controllers var scsiControllers []*types.VirtualController for _, device := range vmDevices { devType := vmDevices.Type(device) switch devType { case SCSIControllerType, strings.ToLower(LSILogicControllerType), strings.ToLower(BusLogicControllerType), PVSCSIControllerType, strings.ToLower(LSILogicSASControllerType): if c, ok := device.(types.BaseVirtualController); ok { scsiControllers = append(scsiControllers, c.GetVirtualController()) } } } return scsiControllers }