Add new option, nvme_device_path, so that we can properly mount nvme block devices.
This commit is contained in:
parent
97652b62e5
commit
e670eed315
|
@ -33,6 +33,7 @@ type Config struct {
|
||||||
CommandWrapper string `mapstructure:"command_wrapper"`
|
CommandWrapper string `mapstructure:"command_wrapper"`
|
||||||
CopyFiles []string `mapstructure:"copy_files"`
|
CopyFiles []string `mapstructure:"copy_files"`
|
||||||
DevicePath string `mapstructure:"device_path"`
|
DevicePath string `mapstructure:"device_path"`
|
||||||
|
NVMEDevicePath string `mapstructure:"nvme_device_path"`
|
||||||
FromScratch bool `mapstructure:"from_scratch"`
|
FromScratch bool `mapstructure:"from_scratch"`
|
||||||
MountOptions []string `mapstructure:"mount_options"`
|
MountOptions []string `mapstructure:"mount_options"`
|
||||||
MountPartition string `mapstructure:"mount_partition"`
|
MountPartition string `mapstructure:"mount_partition"`
|
||||||
|
|
|
@ -35,6 +35,10 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi
|
||||||
config := state.Get("config").(*Config)
|
config := state.Get("config").(*Config)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
device := state.Get("device").(string)
|
device := state.Get("device").(string)
|
||||||
|
if config.NVMEDevicePath != "" {
|
||||||
|
// customizable device path for mounting NVME block devices on c5 and m5 HVM
|
||||||
|
device = config.NVMEDevicePath
|
||||||
|
}
|
||||||
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
|
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
|
||||||
|
|
||||||
var virtualizationType string
|
var virtualizationType string
|
||||||
|
@ -47,6 +51,7 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := config.ctx
|
ctx := config.ctx
|
||||||
|
|
||||||
ctx.Data = &mountPathData{Device: filepath.Base(device)}
|
ctx.Data = &mountPathData{Device: filepath.Base(device)}
|
||||||
mountPath, err := interpolate.Render(config.MountPath, &ctx)
|
mountPath, err := interpolate.Render(config.MountPath, &ctx)
|
||||||
|
|
||||||
|
@ -98,7 +103,7 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
log.Printf("[DEBUG] (step mount) mount command is %s", mountCommand)
|
||||||
cmd := ShellCommand(mountCommand)
|
cmd := ShellCommand(mountCommand)
|
||||||
cmd.Stderr = stderr
|
cmd.Stderr = stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue