Skip to content

Instantly share code, notes, and snippets.

@pvandervelde
Created December 9, 2018 07:23
Show Gist options
  • Save pvandervelde/8980e3f396209fec53b7f8c4b8be6d21 to your computer and use it in GitHub Desktop.
Save pvandervelde/8980e3f396209fec53b7f8c4b8be6d21 to your computer and use it in GitHub Desktop.
Packer 1.3.3. VMCX Compare-VM error
==> hyperv-vmcx: Creating build directory...
==> hyperv-vmcx: Starting HTTP server on port 8158
==> hyperv-vmcx: Creating switch 'External switch' if required...
==> hyperv-vmcx: switch 'External switch' already exists. Will not delete on cleanup...
==> hyperv-vmcx: Cloning virtual machine...
==> hyperv-vmcx: Error cloning virtual machine: PowerShell error: Compare-VM : Cannot process command because of one or more missing mandatory parameters: Copy.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps024838572.ps1:28 char:24
==> hyperv-vmcx: + ... ityReport = Hyper-V\Compare-VM -Path $VirtualMachinePath -VirtualMach ...
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidArgument: (:) [Compare-VM], ParameterBindingException
==> hyperv-vmcx: + FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.HyperV.PowerShell.Commands.CompareVM
==> hyperv-vmcx:
==> hyperv-vmcx: Set-VMMemory : Cannot validate argument on parameter 'VM'. The argument is null or empty. Provide an argument that is
==> hyperv-vmcx: not null or empty, and then try the command again.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps024838572.ps1:38 char:26
==> hyperv-vmcx: + Hyper-V\Set-VMMemory -VM $compatibilityReport.VM -StartupBytes $memor ...
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidData: (:) [Set-VMMemory], ParameterBindingValidationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.HyperV.PowerShell.Commands.SetVMMemory
==> hyperv-vmcx:
==> hyperv-vmcx: Disconnect-VMNetworkAdapter : Cannot bind argument to parameter 'VMNetworkAdapter' because it is null.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps024838572.ps1:40 char:55
==> hyperv-vmcx: + Hyper-V\Disconnect-VMNetworkAdapter -VMNetworkAdapter $networkAdaptor
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidData: (:) [Disconnect-VMNetworkAdapter], ParameterBindingValidationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.HyperV.PowerShell.Commands.Disc
==> hyperv-vmcx: onnectVMNetworkAdapter
==> hyperv-vmcx:
==> hyperv-vmcx: Connect-VMNetworkAdapter : Cannot validate argument on parameter 'VMNetworkAdapter'. The argument is null or empty.
==> hyperv-vmcx: Provide an argument that is not null or empty, and then try the command again.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps024838572.ps1:41 char:52
==> hyperv-vmcx: + ... -V\Connect-VMNetworkAdapter -VMNetworkAdapter $networkAdaptor -Switch ...
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidData: (:) [Connect-VMNetworkAdapter], ParameterBindingValidationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.HyperV.PowerShell.Commands.ConnectVMNetworkAd
==> hyperv-vmcx: apter
==> hyperv-vmcx:
==> hyperv-vmcx: Import-VM : Cannot bind argument to parameter 'CompatibilityReport' because it is null.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps024838572.ps1:42 char:46
==> hyperv-vmcx: + $vm = Hyper-V\Import-VM -CompatibilityReport $compatibilityReport
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidData: (:) [Import-VM], ParameterBindingValidationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.HyperV.PowerShell.Commands.Impo
==> hyperv-vmcx: rtVM
==> hyperv-vmcx: Unregistering and deleting virtual machine...
==> hyperv-vmcx: Error deleting virtual machine: PowerShell error: Hyper-V\Get-VM : Hyper-V was unable to find a virtual machine with name "test-ubuntu-18-04-1".
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps830839067.ps1:4 char:7
==> hyperv-vmcx: + $vm = Hyper-V\Get-VM -Name $vmName
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : InvalidArgument: (test-ubuntu-18-04-1:String) [Get-VM], VirtualizationException
==> hyperv-vmcx: + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM
==> hyperv-vmcx:
==> hyperv-vmcx: Stop-VM : Cannot validate argument on parameter 'VM'. The argument is null or empty. Provide an argument that is not
==> hyperv-vmcx: null or empty, and then try the command again.
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps830839067.ps1:6 char:25
==> hyperv-vmcx: + Hyper-V\Stop-VM -VM $vm -TurnOff -Force -Confirm:$false
==> hyperv-vmcx: + ~~~
==> hyperv-vmcx: + CategoryInfo : InvalidData: (:) [Stop-VM], ParameterBindingValidationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.HyperV.PowerShell.Commands.StopVM
==> hyperv-vmcx:
==> hyperv-vmcx: Hyper-V\Remove-VM : Hyper-V was unable to find a virtual machine with name "test-ubuntu-18-04-1".
==> hyperv-vmcx: At F:\vcs\github\calvinverse\base.linux\build\temp\ps830839067.ps1:9 char:1
==> hyperv-vmcx: + Hyper-V\Remove-VM -Name $vmName -Force -Confirm:$false
==> hyperv-vmcx: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> hyperv-vmcx: + CategoryInfo : ObjectNotFound: (:) [Remove-VM], VirtualizationException
==> hyperv-vmcx: + FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.RemoveVM
==> hyperv-vmcx: Deleting output directory...
==> hyperv-vmcx: Deleting build directory...
{
"variables": {
"admin_username": "admin",
"admin_password": "admin",
"dir_deploy": null,
"dir_http_user": null,
"dir_temp": null,
"product_name": "not_really_a_product_name",
"vm_name": "not_really_a_vm_name",
"vm_ram_size_in_mb": "1024",
"vm_switch_name": "this_switch_does_not_exist",
"vm_switch_vlan": ""
},
"builders": [
{
"boot_wait": "45s",
"boot_command": [],
"clone_from_vmcx_path": "{{ user `dir_temp` }}/{{ user `vm_name` }}",
"communicator": "ssh",
"enable_dynamic_memory": false,
"enable_mac_spoofing": false,
"enable_secure_boot": true,
"enable_virtualization_extensions": false,
"generation": 2,
"guest_additions_mode": "disable",
"headless": true,
"http_directory": "{{ user `dir_http_user` }}",
"http_port_min": 8150,
"http_port_max": 8160,
"output_directory": "{{ user `dir_temp` }}/test-{{ user `vm_name` }}",
"ram_size": "{{ user `vm_ram_size_in_mb` }}",
"secondary_iso_images": [
"{{ user `dir_deploy` }}/{{ user `product_name` }}-test-provision.iso"
],
"secure_boot_template": "MicrosoftUEFICertificateAuthority",
"shutdown_command": "echo '{{user `admin_password`}}' | sudo -S -E shutdown -P now",
"shutdown_timeout": "5m",
"skip_compaction": true,
"skip_export": true,
"ssh_password": "{{user `admin_password`}}",
"ssh_timeout": "4h",
"ssh_username": "{{user `admin_username`}}",
"switch_name": "{{user `vm_switch_name`}}",
"type": "hyperv-vmcx",
"vlan_id": "{{ user `vm_switch_vlan` }}",
"vm_name": "test-{{ user `vm_name` }}"
}
],
"provisioners": [
{
"expect_disconnect" : true,
"inline": [
"echo \"Waiting for reboot after provisioning ...\""
],
"pause_before" : "45s",
"type": "shell"
},
{
"expect_disconnect": false,
"inline": [
"echo '{{user `admin_password`}}' | sudo -S -E mkdir -m 777 /test"
],
"type": "shell"
},
{
"destination": "/test/pester/",
"source": "{{ user `dir_temp` }}/tests/integration/pester",
"type": "file"
},
{
"expect_disconnect": false,
"inline": [
"(/usr/lib/update-notifier/apt-check --package-names 2>&1) &>> /test/updates.txt"
],
"type": "shell"
},
{
"expect_disconnect": false,
"inline": [
"echo '{{user `admin_password`}}' | sudo -S -E apt-get update",
"echo '{{user `admin_password`}}' | sudo -S -E apt install --assume-yes curl",
"curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -",
"curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list",
"echo '{{user `admin_password`}}' | sudo -S -E apt-get update",
"echo '{{user `admin_password`}}' | sudo -S -E apt-get install --assume-yes powershell",
"echo '{{user `admin_password`}}' | sudo -S -E apt-get install --assume-yes unzip"
],
"type": "shell"
},
{
"expect_disconnect": false,
"inline": [
"echo '{{user `admin_password`}}' | sudo -S -E pwsh -Command '. /test/pester/environment/Initialize-Environment.ps1; Initialize-Environment'"
],
"type": "shell"
},
{
"expect_disconnect": false,
"inline": [
"echo '{{user `admin_password`}}' | sudo -S -E pwsh -Command '$ErrorActionPreference = \"Stop\"; Set-PSRepository -Name PSGallery -InstallationPolicy Trusted '",
"echo '{{user `admin_password`}}' | sudo -S -E pwsh -Command '$ErrorActionPreference = \"Stop\"; Install-Module Pester '",
"echo '{{user `admin_password`}}' | sudo -S -E pwsh -Command '$ErrorActionPreference = \"Stop\"; $result = Invoke-Pester -Script /test/pester/* -PassThru; exit $result.FailedCount '"
],
"type": "shell"
}
]
}
{
"admin_username": "thebigkahuna",
"admin_password": "TheB1gK@huna",
"dir_deploy": "F:/vcs/github/calvinverse/base.linux/build/deploy",
"dir_http_user": "F:/vcs/github/calvinverse/base.linux/build/temp/http",
"dir_temp": "F:/vcs/github/calvinverse/base.linux/build/temp",
"product_name": "Base.Linux",
"vm_name": "ubuntu-18-04-1",
"vm_ram_size_in_mb": "1024",
"vm_switch_name": "External switch",
"vm_switch_vlan": ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment