Add 'usb_controller' option

This commit is contained in:
Michael Kuzmin 2018-02-27 03:22:52 +03:00
parent 39f1e4a394
commit ba06b00e70
2 changed files with 28 additions and 17 deletions

View File

@ -50,6 +50,7 @@ type CreateConfig struct {
GuestOS string // example: otherGuest
Network string // "" for default network
NetworkCard string // example: vmxnet3
USBController bool
}
func (d *Driver) NewVM(ref *types.ManagedObjectReference) *VirtualMachine {
@ -108,6 +109,14 @@ func (d *Driver) CreateVM(config *CreateConfig) (*VirtualMachine, error) {
return nil, err
}
if config.USBController {
t := true
usb := &types.VirtualUSBController{
EhciEnabled: &t,
}
devices = append(devices, usb)
}
createSpec.DeviceChange, err = devices.ConfigSpec(types.VirtualDeviceConfigSpecOperationAdd)
if err != nil {
return nil, err

View File

@ -22,6 +22,7 @@ type CreateConfig struct {
GuestOSType string `mapstructure:"guest_os_type"`
Network string `mapstructure:"network"`
NetworkCard string `mapstructure:"network_card"`
USBController bool `mapstructure:"usb_controller"`
}
func (c *CreateConfig) Prepare() []error {
@ -79,6 +80,7 @@ func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction {
GuestOS: s.Config.GuestOSType,
Network: s.Config.Network,
NetworkCard: s.Config.NetworkCard,
USBController: s.Config.USBController,
})
if err != nil {