diff --git a/builder/parallels/common/driver.go b/builder/parallels/common/driver.go index 0a276a6a1..d612e6224 100644 --- a/builder/parallels/common/driver.go +++ b/builder/parallels/common/driver.go @@ -16,7 +16,7 @@ import ( // extremely specific. type Driver interface { // Import a VM - Import(string, string, string) error + Import(string, string, string, bool) error // Checks if the VM with the given name is running. IsRunning(string) (bool, error) diff --git a/builder/parallels/common/driver_9.go b/builder/parallels/common/driver_9.go index 3bc608520..cc500e042 100644 --- a/builder/parallels/common/driver_9.go +++ b/builder/parallels/common/driver_9.go @@ -19,7 +19,7 @@ type Parallels9Driver struct { PrlctlPath string } -func (d *Parallels9Driver) Import(name, srcPath, dstDir string) error { +func (d *Parallels9Driver) Import(name, srcPath, dstDir string, reassignMac bool) error { err := d.Prlctl("register", srcPath, "--preserve-uuid") if err != nil { @@ -31,9 +31,12 @@ func (d *Parallels9Driver) Import(name, srcPath, dstDir string) error { return err } - srcMac, err := getFirtsMacAddress(srcPath) - if err != nil { - return err + srcMac := "auto" + if !reassignMac { + srcMac, err = getFirtsMacAddress(srcPath) + if err != nil { + return err + } } err = d.Prlctl("clone", srcId, "--name", name, "--dst", dstDir) diff --git a/builder/parallels/common/driver_mock.go b/builder/parallels/common/driver_mock.go index acb3f9533..77761586a 100644 --- a/builder/parallels/common/driver_mock.go +++ b/builder/parallels/common/driver_mock.go @@ -45,7 +45,7 @@ type DriverMock struct { IpAddressError error } -func (d *DriverMock) Import(name, srcPath, dstPath string) error { +func (d *DriverMock) Import(name, srcPath, dstPath string, reassignMac bool) error { d.ImportCalled = true d.ImportName = name d.ImportSrcPath = srcPath diff --git a/builder/parallels/pvm/config.go b/builder/parallels/pvm/config.go index a3c20bb5d..83e643111 100644 --- a/builder/parallels/pvm/config.go +++ b/builder/parallels/pvm/config.go @@ -2,10 +2,11 @@ package pvm import ( "fmt" + "os" + parallelscommon "github.com/mitchellh/packer/builder/parallels/common" "github.com/mitchellh/packer/common" "github.com/mitchellh/packer/packer" - "os" ) // Config is the configuration structure for the builder. @@ -23,6 +24,7 @@ type Config struct { BootCommand []string `mapstructure:"boot_command"` SourcePath string `mapstructure:"source_path"` VMName string `mapstructure:"vm_name"` + ReassignMac bool `mapstructure:"reassign_mac"` tpl *packer.ConfigTemplate } diff --git a/builder/parallels/pvm/step_import.go b/builder/parallels/pvm/step_import.go index 71ceac6a7..fdff75762 100644 --- a/builder/parallels/pvm/step_import.go +++ b/builder/parallels/pvm/step_import.go @@ -20,7 +20,7 @@ func (s *StepImport) Run(state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui.Say(fmt.Sprintf("Importing VM: %s", s.SourcePath)) - if err := driver.Import(s.Name, s.SourcePath, config.OutputDir); err != nil { + if err := driver.Import(s.Name, s.SourcePath, config.OutputDir, config.ReassignMac); err != nil { err := fmt.Errorf("Error importing VM: %s", err) state.Put("error", err) ui.Error(err.Error()) diff --git a/website/source/docs/builders/parallels-pvm.html.markdown b/website/source/docs/builders/parallels-pvm.html.markdown index 8b0624291..82f3fdda3 100644 --- a/website/source/docs/builders/parallels-pvm.html.markdown +++ b/website/source/docs/builders/parallels-pvm.html.markdown @@ -78,6 +78,10 @@ each category, the available options are alphabetized and described. be attached. The files listed in this configuration will all be put into the root directory of the floppy disk; sub-directories are not supported. +* `reassign_mac` (boolean) - If this is "false" the MAC address of the first + NIC will reused when imported else a new MAC address will be generated by + Parallels. Defaults to "false". + * `output_directory` (string) - This is the path to the directory where the resulting virtual machine will be created. This may be relative or absolute. If relative, the path is relative to the working directory when `packer`