diff --git a/README.md b/README.md index 6ca2579d4..eab8ef553 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ See complete Ubuntu, Windows, and macOS templates in the [examples folder](https * `network`(string) - Set network VM will be connected to. * `network_card`(string) - Set VM network card type. Example `vmxnet3`. * `usb_controller`(boolean) - Create USB controller for virtual machine. Defaults to `false`. +* `firmware`(string) - Set the Firmware at machine creation. Example `efi`. Defaults to `bios` ### Boot (`vsphere-iso` only) diff --git a/driver/vm.go b/driver/vm.go index 5e253311f..0171ac606 100644 --- a/driver/vm.go +++ b/driver/vm.go @@ -55,6 +55,7 @@ type CreateConfig struct { NetworkCard string // example: vmxnet3 USBController bool Version uint // example: 10 + Firmware string // efi or bios } func (d *Driver) NewVM(ref *types.ManagedObjectReference) *VirtualMachine { @@ -80,6 +81,7 @@ func (d *Driver) CreateVM(config *CreateConfig) (*VirtualMachine, error) { Name: config.Name, Annotation: config.Annotation, GuestId: config.GuestOS, + Firmware: config.Firmware, } if config.Version != 0 { createSpec.Version = fmt.Sprintf("%s%d", "vmx-", config.Version) diff --git a/iso/step_create.go b/iso/step_create.go index f9e2f9207..5a23bd535 100644 --- a/iso/step_create.go +++ b/iso/step_create.go @@ -12,6 +12,7 @@ import ( type CreateConfig struct { Version uint `mapstructure:"vm_version"` GuestOSType string `mapstructure:"guest_os_type"` + Firmware string `mapstructure:"firmware"` DiskControllerType string `mapstructure:"disk_controller_type"` DiskSize int64 `mapstructure:"disk_size"` @@ -33,6 +34,10 @@ func (c *CreateConfig) Prepare() []error { c.GuestOSType = "otherGuest" } + if (c.Firmware == "") { + c.Firmware = "bios" + } + return errs } @@ -61,6 +66,7 @@ func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multiste NetworkCard: s.Config.NetworkCard, USBController: s.Config.USBController, Version: s.Config.Version, + Firmware: s.Config.Firmware, }) if err != nil { state.Put("error", fmt.Errorf("error creating vm: %v", err))