From 2929200bdb49209ab7ce64a6c6454e4c06ecadde Mon Sep 17 00:00:00 2001 From: flx5 <1330854+flx5@users.noreply.github.com> Date: Thu, 16 Sep 2021 19:03:24 +0200 Subject: [PATCH] Add firmware setting --- builder/xenserver/common/config.go | 2 ++ builder/xenserver/common/config.hcl2spec.go | 2 ++ builder/xenserver/common/step_start_vm_paused.go | 3 ++- builder/xenserver/iso/builder.go | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/xenserver/common/config.go b/builder/xenserver/common/config.go index c09a09f..658e5c8 100644 --- a/builder/xenserver/common/config.go +++ b/builder/xenserver/common/config.go @@ -32,6 +32,8 @@ type Config struct { RawInstallTimeout string `mapstructure:"install_timeout"` InstallTimeout time.Duration `` SourcePath string `mapstructure:"source_path"` + + Firmware string `mapstructure:"firmware"` ctx interpolate.Context } diff --git a/builder/xenserver/common/config.hcl2spec.go b/builder/xenserver/common/config.hcl2spec.go index 768c5ee..65644ea 100644 --- a/builder/xenserver/common/config.hcl2spec.go +++ b/builder/xenserver/common/config.hcl2spec.go @@ -107,6 +107,7 @@ type FlatConfig struct { PlatformArgs map[string]string `mapstructure:"platform_args" cty:"platform_args" hcl:"platform_args"` RawInstallTimeout *string `mapstructure:"install_timeout" cty:"install_timeout" hcl:"install_timeout"` SourcePath *string `mapstructure:"source_path" cty:"source_path" hcl:"source_path"` + Firmware *string `mapstructure:"firmware" cty:"firmware" hcl:"firmware"` } // FlatMapstructure returns a new FlatConfig. @@ -218,6 +219,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "platform_args": &hcldec.AttrSpec{Name: "platform_args", Type: cty.Map(cty.String), Required: false}, "install_timeout": &hcldec.AttrSpec{Name: "install_timeout", Type: cty.String, Required: false}, "source_path": &hcldec.AttrSpec{Name: "source_path", Type: cty.String, Required: false}, + "firmware": &hcldec.AttrSpec{Name: "firmware", Type: cty.String, Required: false}, } return s } diff --git a/builder/xenserver/common/step_start_vm_paused.go b/builder/xenserver/common/step_start_vm_paused.go index d383878..b8cd1ee 100644 --- a/builder/xenserver/common/step_start_vm_paused.go +++ b/builder/xenserver/common/step_start_vm_paused.go @@ -16,6 +16,7 @@ func (self *StepStartVmPaused) Run(ctx context.Context, state multistep.StateBag c := state.Get("client").(*Connection) ui := state.Get("ui").(packer.Ui) + config := state.Get("config").(Config) ui.Say("Step: Start VM Paused") @@ -34,7 +35,7 @@ func (self *StepStartVmPaused) Run(ctx context.Context, state multistep.StateBag return multistep.ActionHalt } - err = c.client.VM.SetHVMBootParams(c.session, instance, map[string]string{"order": "cd"}) + err = c.client.VM.SetHVMBootParams(c.session, instance, map[string]string{"order": "cd", "firmware": config.Firmware}) if err != nil { ui.Error(fmt.Sprintf("Unable to set HVM boot params: %s", err.Error())) return multistep.ActionHalt diff --git a/builder/xenserver/iso/builder.go b/builder/xenserver/iso/builder.go index 02b5548..c5ec0c8 100644 --- a/builder/xenserver/iso/builder.go +++ b/builder/xenserver/iso/builder.go @@ -76,6 +76,10 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri if self.config.CloneTemplate == "" { self.config.CloneTemplate = "Other install media" } + + if self.config.Firmware == "" { + self.config.Firmware = "bios" + } if len(self.config.PlatformArgs) == 0 { pargs := make(map[string]string)