Merge pull request #7790 from hashicorp/fix_7748

clarify pathing requirements for hyperv-vmcx
This commit is contained in:
Megan Marsh 2019-06-24 11:36:49 -07:00 committed by GitHub
commit 3a55437f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -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 {

View File

@ -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"
@ -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: