From f95093ef63f3e3e24de4437770ebdfbe2700cd14 Mon Sep 17 00:00:00 2001 From: Lee Spottiswood Date: Thu, 15 Jun 2017 13:12:39 +0100 Subject: [PATCH] Add support for floppy_dirs with hyperv-iso builder --- builder/hyperv/common/floppy_config.go | 19 ------------------- builder/hyperv/common/floppy_config_test.go | 18 ------------------ builder/hyperv/iso/builder.go | 17 ++++------------- .../source/docs/builders/hyperv-iso.html.md | 8 ++++++++ 4 files changed, 12 insertions(+), 50 deletions(-) delete mode 100644 builder/hyperv/common/floppy_config.go delete mode 100644 builder/hyperv/common/floppy_config_test.go diff --git a/builder/hyperv/common/floppy_config.go b/builder/hyperv/common/floppy_config.go deleted file mode 100644 index b0d6a5ab9..000000000 --- a/builder/hyperv/common/floppy_config.go +++ /dev/null @@ -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 -} diff --git a/builder/hyperv/common/floppy_config_test.go b/builder/hyperv/common/floppy_config_test.go deleted file mode 100644 index 3e4fc55db..000000000 --- a/builder/hyperv/common/floppy_config_test.go +++ /dev/null @@ -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") - } -} diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index cd73c4873..8ad3883c6 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -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, diff --git a/website/source/docs/builders/hyperv-iso.html.md b/website/source/docs/builders/hyperv-iso.html.md index a795a73b7..0165e8117 100644 --- a/website/source/docs/builders/hyperv-iso.html.md +++ b/website/source/docs/builders/hyperv-iso.html.md @@ -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