implement cd_files for qemu builder
This commit is contained in:
parent
f774983d36
commit
9140985ab0
|
@ -77,6 +77,7 @@ type Config struct {
|
|||
shutdowncommand.ShutdownConfig `mapstructure:",squash"`
|
||||
CommConfig CommConfig `mapstructure:",squash"`
|
||||
common.FloppyConfig `mapstructure:",squash"`
|
||||
common.CDConfig `mapstructure:",squash"`
|
||||
// Use iso from provided url. Qemu must support
|
||||
// curl block device. This defaults to `false`.
|
||||
ISOSkipCache bool `mapstructure:"iso_skip_cache" required:"false"`
|
||||
|
@ -469,6 +470,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||
}
|
||||
|
||||
errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...)
|
||||
errs = packer.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...)
|
||||
errs = packer.MultiErrorAppend(errs, b.config.VNCConfig.Prepare(&b.config.ctx)...)
|
||||
|
||||
if b.config.NetDevice == "" {
|
||||
|
@ -622,6 +624,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||
Directories: b.config.FloppyConfig.FloppyDirectories,
|
||||
Label: b.config.FloppyConfig.FloppyLabel,
|
||||
},
|
||||
&common.StepCreateCD{
|
||||
Files: b.config.CDConfig.CDFiles,
|
||||
Label: b.config.CDConfig.CDLabel,
|
||||
},
|
||||
new(stepCreateDisk),
|
||||
new(stepCopyDisk),
|
||||
new(stepResizeDisk),
|
||||
|
|
|
@ -190,14 +190,26 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error
|
|||
}
|
||||
}
|
||||
|
||||
cdPaths := []string{}
|
||||
// Add the installation CD to the run command
|
||||
if !config.DiskImage {
|
||||
cdPaths = append(cdPaths, isoPath)
|
||||
}
|
||||
// Add our custom CD created from cd_files, if it exists
|
||||
cdFilesPath, ok := state.Get("cd_path").(string)
|
||||
if ok {
|
||||
if cdFilesPath != "" {
|
||||
cdPaths = append(cdPaths, cdFilesPath)
|
||||
}
|
||||
}
|
||||
for i, cdPath := range cdPaths {
|
||||
if config.CDROMInterface == "" {
|
||||
defaultArgs["-cdrom"] = isoPath
|
||||
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,index=%d,media=cdrom", cdPath, i))
|
||||
} else if config.CDROMInterface == "virtio-scsi" {
|
||||
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=none,id=cdrom,media=cdrom", isoPath))
|
||||
deviceArgs = append(deviceArgs, "virtio-scsi-device", "scsi-cd,drive=cdrom")
|
||||
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=none,index=%d,id=cdrom%d,media=cdrom", cdPath, i, i))
|
||||
deviceArgs = append(deviceArgs, "virtio-scsi-device", fmt.Sprintf("scsi-cd,drive=cdrom%d", i))
|
||||
} else {
|
||||
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=%s,id=cdrom,media=cdrom", isoPath, config.CDROMInterface))
|
||||
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=%s,index=%d,id=cdrom%d,media=cdrom", cdPath, config.CDROMInterface, i, i))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue