Commit Graph

50 Commits

Author SHA1 Message Date
Megan Marsh 847a3b0061 provide useful powershell error 2018-10-09 12:13:07 -07:00
DanHam da21c25791
Convert incorrect 'vmxc' -> 'vmcx' in codebase, docs and template opts
grep -rli --exclude-dir={vendor,bin\*,\*vmware\*,\*pkg\*} vmxc . | \
xargs sed -i 's/\(vm\)\(x\)\(c\)/\1\3\2/ig'
2018-07-20 02:12:47 +01:00
DanHam 674bad0ab4
Break very long lines for readability 2018-07-20 02:12:47 +01:00
DanHam d2390f464d
Actually implement the function for the driver 2018-07-20 02:12:45 +01:00
DanHam c2437ba592
Remove the option to place the VHD files in a separate directory
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`.
2018-07-20 02:12:43 +01:00
DanHam c6b9d9ce90
Add checks/error reporting to compaction process
* 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.
2018-07-20 02:12:42 +01:00
DanHam 534fc4a473
Ensure the export directory structure matches that of previous versions
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.
2018-07-20 02:09:57 +01:00
DanHam dc46848f89
Remove now redundant function to copy exported VM files 2018-07-20 02:09:57 +01:00
DanHam 3fc2defb6d
Refactor the export step for Hyper-V ISO and VMCX builders
* 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.
2018-07-20 02:09:54 +01:00
DanHam 297f6b85ec
Use Get-Command over Get-Help to check for SecureBootTemplate parameter 2018-06-25 23:52:01 +01:00
Simon Hulme 475e79a251 Fixed SecureBootTemplate not being passed through to PS cmdlet
Added check for SecureBootTemplate parameter for Server 2012 and below
Corrected enableSecureBootString usage
2018-06-25 14:13:43 +01:00
Jordan Borean efa9021974
Check if hyper-v addresses is an array before slicing it 2018-06-18 14:45:33 +10:00
M. Marsh edb5c1f50d
Merge pull request #6243 from camjjack/hyper-v-gui
Using vmconnect to display gui for hyper-v
2018-05-18 11:24:24 -07:00
WaaZaa666 b747877222
Fixing #6267, multiple hyper-v disks 2018-05-17 14:50:18 +02:00
Unknown 29c4b4436d Changes requested in PR #6243
- 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
2018-05-14 20:52:10 +10:00
Unknown fc734b6bd9 Using vmconnect to display gui for hyper-v
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.
2018-05-14 20:52:10 +10:00
M. Marsh 5871b8242b
Merge pull request #6101 from adarobin/azurecompatible
Add use_fixed_vhd_format Hyper-V ISO option
2018-05-10 17:02:44 -07:00
Stefan Henseler 6f00596053 Adds config option to specify hyper-v secure boot template 2018-05-10 19:00:35 +02:00
Jordan Borean 14e41fad7e
Hyper-V: Add support retrieving IP for Server 2008 2018-04-30 15:18:28 +10:00
Adam Robinson 3aebd5f462 Add use_fixed_vhd_format Hyper-V ISO option 2018-04-26 13:35:19 -04:00
M. Marsh f5c031baf9
Merge pull request #5941 from synax/hyper-v-disk-block-size
Adds Support to configure hyper-v disk block size
2018-04-19 11:27:52 -07:00
Stefan Henseler b8bf421dc2 Fixes missing diskblocksize parameter for gen1 vms 2018-04-18 22:14:44 +02:00
Hannu Piki 3ffaf551c0 Fixing Hyper-V ISO builder CopyExportedVirtualMachine PowerShell
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
2018-03-29 18:34:14 +03:00
Stefan Henseler 03f0b4aa11 Fixes minor typo 2018-03-25 16:30:03 +02:00
Stefan Henseler d31e35075e Removes obsolete code 2018-03-25 16:27:57 +02:00
Stefan Henseler a6b0bd2927
Merge branch 'master' into hyper-v-disk-block-size 2018-02-23 20:21:22 +01:00
Stefan Henseler 103186af86 Adds Support to configure hyper-v disk block size 2018-02-23 20:19:26 +01:00
Anthony Allen f3c361de6b Fully qualify hyper-v powershell commands 2018-02-07 08:01:05 +01:00
Ben Phegan c338cb79d0 Initial commit of feature to allow MAC address specification for HyperV builders 2017-12-15 13:24:15 +11:00
Vijaya Bhaskar Reddy Kondreddi b7e3f37b44 Add support for differential disk 2017-11-24 12:44:53 +05:30
Matthew Hooker f64fa7b5ba
Merge pull request #5491 from BenPhegan/hyperv-disk_additional_size
Hyper-V disk_additional_size capability
2017-10-31 08:42:07 -07:00
Matthew Hooker a66f51f025
Merge pull request #5517 from PatrickLang/hyperv-gen2-autocheckpoint
Fixing auto checkpoints for generation 2 VMs.
2017-10-30 09:33:16 -07:00
Patrick Lang 6d5f75e118 run gofmt 2017-10-25 21:47:14 -07:00
Patrick Lang 95d82b4637 Fixing auto checkpoints for generation 2 VMs. Resolves #5506
Also cleaning up ifs
2017-10-25 21:21:32 -07:00
Matthew Hooker 812fd12a0b
move trimspace to powershell exit check 2017-10-25 13:28:59 -07:00
Matthew Hooker 0be02ab217
hyper-v: Don't error while checking for admin permissions. 2017-10-25 09:18:40 -07:00
Ben Phegan 12fc928e1d Initial commit of Hyper-V disk_additional_size capability. Support a
maximum of 64 disks added to the SCSI controller.  Implement #4823.
2017-10-23 08:26:35 +11:00
Vijaya Bhaskar Reddy Kondreddi 4f6a207441 go fmt 2017-10-11 22:10:39 +05:30
Taliesin Sisson efa62e1550 Can specify an iso, vhd or vhdx for download. If it is a vhd or vhdx it is used as the hard drive for spinning up a new machine, importing an exported virtual machine or cloning a virtual machine.
Can import a virtual machine from a folder
Can clone an existing virtual machine
2017-10-11 22:05:45 +05:30
Taliesin Sisson 452fcbd9a1 Only attach dvd drive if there is one
Fix debug messages for cloning

Add hyperv-vmcx as a builder from command line
2017-10-11 21:42:32 +05:30
Taliesin Sisson 429e1bc3ad Adding an ISO is now optional for hyperv vmcx
Add documentation for hyperv vmcx
2017-10-11 21:42:32 +05:30
Taliesin Sisson 6fd7f0877d Initial check in to add a builder that can clone existing hyper v machines 2017-10-11 21:42:32 +05:30
Matthew Hooker 150b1522f4 Merge pull request #5374 from PatrickLang/hyperv-checkpoint
Disabling automatic checkpoints in hyperv-iso builder
2017-10-09 14:05:16 -07:00
Patrick Lang 6acdb9d148 Disabling automatic checkpoints
Signed-off-by: Patrick Lang <plang@microsoft.com>
2017-09-21 14:51:38 -07:00
Sander Saares 028c941b77 Enable use of separate temp path for Hyper-V VHD 2017-09-02 14:55:00 +03:00
Petrik van der Velde aa33740ffb Removing the check for administrator rights from the script that sends keystrokes to Hyper-V.
Because Packer has already verified that we are running with at least Hyper-V administrator rights this should
be safe. Having the requirement for administrator rights in the script means that you still need to be an
administrator if you want to use packer to build Hyper-V images with a configuration that requires you to
send keystrokes to the MV, say when building a Linux box.
2017-04-15 11:04:15 +12:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Matthew Hooker 35578d9ed1
remove unnecessary type conversions 2017-03-28 20:36:21 -07:00
Tadas Medisauskas 088d3d1ac8 Add -NoProfile switch 2016-12-22 14:50:17 +00:00
Matthew Hooker 45d4cf8b36
move powershell module to common 2016-12-12 18:34:15 -08:00