Add support for floppy_dirs with hyperv-iso builder

This commit is contained in:
Lee Spottiswood 2017-06-15 13:12:39 +01:00
parent 3a579bea81
commit f95093ef63
4 changed files with 12 additions and 50 deletions

View File

@ -1,19 +0,0 @@
package common
import (
"github.com/hashicorp/packer/template/interpolate"
)
// FloppyConfig is configuration related to created floppy disks and attaching
// them to a Parallels virtual machine.
type FloppyConfig struct {
FloppyFiles []string `mapstructure:"floppy_files"`
}
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
if c.FloppyFiles == nil {
c.FloppyFiles = make([]string, 0)
}
return nil
}

View File

@ -1,18 +0,0 @@
package common
import (
"testing"
)
func TestFloppyConfigPrepare(t *testing.T) {
c := new(FloppyConfig)
errs := c.Prepare(testConfigTemplate(t))
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
}
if len(c.FloppyFiles) > 0 {
t.Fatal("should not have floppy files")
}
}

View File

@ -45,7 +45,7 @@ type Config struct {
common.PackerConfig `mapstructure:",squash"`
common.HTTPConfig `mapstructure:",squash"`
common.ISOConfig `mapstructure:",squash"`
hypervcommon.FloppyConfig `mapstructure:",squash"`
common.FloppyConfig `mapstructure:",squash"`
hypervcommon.OutputConfig `mapstructure:",squash"`
hypervcommon.SSHConfig `mapstructure:",squash"`
hypervcommon.RunConfig `mapstructure:",squash"`
@ -57,16 +57,6 @@ type Config struct {
// The size, in megabytes, of the computer memory in the VM.
// By default, this is 1024 (about 1 GB).
RamSize uint `mapstructure:"ram_size"`
// A list of files to place onto a floppy disk that is attached when the
// VM is booted. This is most useful for unattended Windows installs,
// which look for an Autounattend.xml file on removable media. By default,
// no floppy will be attached. All files listed in this setting get
// placed into the root directory of the floppy and the floppy is attached
// as the first floppy device. Currently, no support exists for creating
// sub-directories on the floppy. Wildcard characters (*, ?, and [])
// are allowed. Directory names are also allowed, which will add all
// the files found in the directory to the floppy.
FloppyFiles []string `mapstructure:"floppy_files"`
//
SecondaryDvdImages []string `mapstructure:"secondary_iso_images"`
@ -156,7 +146,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
if b.config.Generation == 2 {
if len(b.config.FloppyFiles) > 0 {
if len(b.config.FloppyFiles) > 0 || len(b.config.FloppyDirectories) > 0 {
err = errors.New("Generation 2 vms don't support floppy drives. Use ISO image instead.")
errs = packer.MultiErrorAppend(errs, err)
}
@ -318,7 +308,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
TargetPath: b.config.TargetPath,
},
&common.StepCreateFloppy{
Files: b.config.FloppyFiles,
Files: b.config.FloppyConfig.FloppyFiles,
Directories: b.config.FloppyConfig.FloppyDirectories,
},
&common.StepHTTPServer{
HTTPDir: b.config.HTTPDir,

View File

@ -113,6 +113,14 @@ can be configured for this builder.
characters (`*`, `?`, and `[]`) are allowed. Directory names are also allowed,
which will add all the files found in the directory to the floppy.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
The maximum summary size of all files in the listed directories are the
same as in `floppy_files`.
- `generation` (integer) - The Hyper-V generation for the virtual machine. By
default, this is 1. Generation 2 Hyper-V virtual machines do not support
floppy drives. In this scenario use `secondary_iso_images` instead. Hard