Skip to content

Commit

Permalink
Merge pull request #7790 from hashicorp/fix_7748
Browse files Browse the repository at this point in the history
clarify pathing requirements for hyperv-vmcx
  • Loading branch information
SwampDragons committed Jun 24, 2019
2 parents 6ead049 + 29bff09 commit 3a55437
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions builder/hyperv/vmcx/builder.go
Expand Up @@ -221,6 +221,21 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs, fmt.Errorf("CloneFromVMCXPath does not exist: %s", err))
}
}
if strings.HasSuffix(strings.ToLower(b.config.CloneFromVMCXPath), ".vmcx") {
// User has provided the vmcx file itself rather than the containing
// folder.
if strings.Contains(b.config.CloneFromVMCXPath, "Virtual Machines") {
keep := strings.Split(b.config.CloneFromVMCXPath, "Virtual Machines")
b.config.CloneFromVMCXPath = keep[0]
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to "+
"parse the clone_from_vmcx_path to find the vm directory. "+
"Please provide the path to the folder containing the "+
"vmcx file, not the file itself. Example: instead of "+
"C:\\path\\to\\output-hyperv-iso\\Virtual Machines\\filename.vmcx"+
", provide C:\\path\\to\\output-hyperv-iso\\."))
}
}
}

if b.config.Generation < 1 || b.config.Generation > 2 {
Expand Down
6 changes: 5 additions & 1 deletion website/source/docs/builders/hyperv-vmcx.html.md.erb
Expand Up @@ -33,7 +33,7 @@ Import from folder:
``` json
{
"type": "hyperv-vmcx",
"clone_from_vmcx_path": "c:/virtual machines/ubuntu-12.04.5-server-amd64",
"clone_from_vmcx_path": "c:/path/to/ubuntu-12.04.5-server-amd64",
"ssh_username": "packer",
"ssh_password": "packer",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
Expand Down Expand Up @@ -77,6 +77,10 @@ builder.
previously exported virtual machine. The exported machine will be used
as the source for new VM.

note: You should provide the named directory that contains the
"Virtual Machines", "Snapshots", and/or "Virtual Hard Disks" subdirectories,
not the .vmcx file itself.


### Required for virtual machine clone:

Expand Down

0 comments on commit 3a55437

Please sign in to comment.