Add support for floppy_dirs with hyperv-iso builder
This commit is contained in:
parent
3a579bea81
commit
f95093ef63
|
@ -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
|
|
||||||
}
|
|
|
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,7 +45,7 @@ type Config struct {
|
||||||
common.PackerConfig `mapstructure:",squash"`
|
common.PackerConfig `mapstructure:",squash"`
|
||||||
common.HTTPConfig `mapstructure:",squash"`
|
common.HTTPConfig `mapstructure:",squash"`
|
||||||
common.ISOConfig `mapstructure:",squash"`
|
common.ISOConfig `mapstructure:",squash"`
|
||||||
hypervcommon.FloppyConfig `mapstructure:",squash"`
|
common.FloppyConfig `mapstructure:",squash"`
|
||||||
hypervcommon.OutputConfig `mapstructure:",squash"`
|
hypervcommon.OutputConfig `mapstructure:",squash"`
|
||||||
hypervcommon.SSHConfig `mapstructure:",squash"`
|
hypervcommon.SSHConfig `mapstructure:",squash"`
|
||||||
hypervcommon.RunConfig `mapstructure:",squash"`
|
hypervcommon.RunConfig `mapstructure:",squash"`
|
||||||
|
@ -57,16 +57,6 @@ type Config struct {
|
||||||
// The size, in megabytes, of the computer memory in the VM.
|
// The size, in megabytes, of the computer memory in the VM.
|
||||||
// By default, this is 1024 (about 1 GB).
|
// By default, this is 1024 (about 1 GB).
|
||||||
RamSize uint `mapstructure:"ram_size"`
|
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"`
|
SecondaryDvdImages []string `mapstructure:"secondary_iso_images"`
|
||||||
|
|
||||||
|
@ -156,7 +146,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.config.Generation == 2 {
|
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.")
|
err = errors.New("Generation 2 vms don't support floppy drives. Use ISO image instead.")
|
||||||
errs = packer.MultiErrorAppend(errs, err)
|
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,
|
TargetPath: b.config.TargetPath,
|
||||||
},
|
},
|
||||||
&common.StepCreateFloppy{
|
&common.StepCreateFloppy{
|
||||||
Files: b.config.FloppyFiles,
|
Files: b.config.FloppyConfig.FloppyFiles,
|
||||||
|
Directories: b.config.FloppyConfig.FloppyDirectories,
|
||||||
},
|
},
|
||||||
&common.StepHTTPServer{
|
&common.StepHTTPServer{
|
||||||
HTTPDir: b.config.HTTPDir,
|
HTTPDir: b.config.HTTPDir,
|
||||||
|
|
|
@ -113,6 +113,14 @@ can be configured for this builder.
|
||||||
characters (`*`, `?`, and `[]`) are allowed. Directory names are also allowed,
|
characters (`*`, `?`, and `[]`) are allowed. Directory names are also allowed,
|
||||||
which will add all the files found in the directory to the floppy.
|
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
|
- `generation` (integer) - The Hyper-V generation for the virtual machine. By
|
||||||
default, this is 1. Generation 2 Hyper-V virtual machines do not support
|
default, this is 1. Generation 2 Hyper-V virtual machines do not support
|
||||||
floppy drives. In this scenario use `secondary_iso_images` instead. Hard
|
floppy drives. In this scenario use `secondary_iso_images` instead. Hard
|
||||||
|
|
Loading…
Reference in New Issue