The export process now exports the VM directly from the build directory
into the output directory. There are no intermediate steps or copying of
files involved. This means that there is no longer any benefit in having
a separate directory to house the VHD files - see #5206 for the
reasoning behind the introduction of this feature.
If a user wishes to house the build files on a separate disk from the
output directory (perhaps for performance reasons or due to disk space
limitations) they can still do so through the use of `temp_path`.
* Report compaction results
* Failure to find any disks under the supplied path is treated as a
'soft' error and a warning message will be printed in place of the
compaction result. Any other failure will cause the build to fail.
Commit 3fc2defb6 altered the directory structure associated with an
exported VM. The changes mean that the export process now stores the
exported machine files and folders under a folder with name 'vm_name' in
the output directory.
This commit restores the previous behaviour whereby the exported machine
files and folders were stored directly in the output directory. This
allows us to keep the efficiency improvements introduced with 3fc2defb6
while maintaining backward compatibility.
By default the Export-VM command creates three folders in the specified
export directory - 'Virtual Hard Disks', 'Virtual Machines' and
'Snapshots'. When a machine with no associated snapshots is exported the
'Snapshots' directory is empty.
Prior to 3fc2defb6 the Snapshots folder was not copied/incorporated into
the output directory at all. This was a bug.
This commit preserves the legacy behaviour by not including an empty
Snapshots directory in the export. However, if there *are* Snapshots
associated with the VM, they are now moved into the output directory
along with the usual directories containing disks and VM metadata. This
prevents warnings/errors on import due to missing snapshots.
* Fixes a bug that caused the build to error if users did not
explicitly set `skip_compaction:true` when setting `skip_export:
true`. See #6392.
* Improves the efficiency of the compaction and export process by
reordering the compaction and export steps.
* Further improves the efficiency of the compacting step through
compacting the vmd* file directly rather than creating and then
operating on a copy.
* The changes mean the export process now stores the exported machine
files and folders under a folder with name 'vm_name' in the output
directory. Previously the exported machine files and folders were
stored directly in the output directory.
- Logging error if vmconnect.exe fails.
- Using StepRun struct rather than StateBag for command Cancel function
- Better handling in Disconnect when headless is true or vmconnect failed in Start
vmconnect.exe comes as part of Hyper-V and is the tool used by Hyper-V Manager to connect with a virtual machine. This commits sets behaviour the same as virtualbox and vmware to display the virtual machine connection unless headless is set in the template.
This way we don't crash if someone sticks something else in the error
key in the state bag (which a quick glance at the code tells me we're
already doing.
Perhaps in the future we can add an error attribute to the state bag
but for now this will have to suffice.
Let's cache the scancodes and flush them at the end. Also make sure to
send only as many as the driver can send correctly. It's important here
to chunk the scancodes correctly, so that we don't accidentally split them
over successive calls to the driver
There were 5 different formats for the Packer useragent string. This
fixes that and unifies it into a helper package.
I did not touch oracle's user-agent, because it looked kinda special.
Script wasn't able to handle path that Packer used to create VM in the first place:
"==> hyperv-iso: Copying to output dir...
==> hyperv-iso: Error exporting vm: PowerShell error: Move-Item : An object at the specified path C:\Users\HANNU~1.PIK does not exist.
==> hyperv-iso: At C:\Users\hannu.piki\AppData\Local\Temp\ps520830935.ps1:13 char:1
==> hyperv-iso: + Move-Item -Path "$srcPath/$vhdDirName" -Destination $dstPath -Verbose
==> hyperv-iso: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> hyperv-iso: + CategoryInfo : InvalidArgument: (:) [Move-Item], PSArgumentException
==> hyperv-iso: + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.MoveItemCommand"
Used path was: C:\Users\HANNU~1.PIK\AppData\Local\Temp\packerhv616791918\export253729206\2016min
Real path was: C:\Users\hannu.piki\AppData\Local\Temp\packerhv616791918\export253729206\2016min