Merge branch 'firmware' into combined

This commit is contained in:
flx5 2021-09-16 20:26:32 +02:00
commit 64e4fd2a4d
4 changed files with 10 additions and 1 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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)