You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The command fails with a helpful error message, possibly indicating that VMMS is down.
Actual behavior
The import_vm.ps1 script fails with the following error:
You cannot call a method on a null-valued expression.
Steps to reproduce
Disable the VMMS service ("Hyper-V Virtual Machine Management"). (PowerShell: Get-Service vmms | Stop-Service)
Initialize a new Vagrant directory with a bare-bones Vagrantfile pointing at a Hyper-V box:
Vagrant.configure("2") do |config|
config.vm.box = "<some-hyperv-box>"
end
Run vagrant up (with --provider hyperv as necessary with the box).
Root cause
I've found the root cause and will open a PR ASAP. Just wanted to create an issue to track it.
Vagrant fails to create a VM due to VMMS not running, which is expected behavior. It then attempts to create a more helpful error message for the failed import, and starts by querying WMI for the VMMS service:
Checking for null after querying the service and throwing a more specific message should do the trick.
The text was updated successfully, but these errors were encountered:
mrshanahan
changed the title
PowerShell null reference error when initially calling vagrant up with VMMS not running
PowerShell null reference error when importing Hyper-V VM with VMMS not running
Jul 17, 2019
* commit '07a51906769ad1d717e9246a67d3dc4fc57e84a9':
Update CHANGELOG
Update CHANGELOG
Update CHANGELOG
Fixeshashicorp#10950: Ensure pip_install_cmd is finalized
Fixeshashicorp#11027: Ensure VM id is passed to list snapshots
Update CHANGELOG
Move around example mention in docs
Docs: Add note about running bash with the `run` option for triggers
Fixeshashicorp#10966: Ensure all subdirectory files are watched
Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately
ansible_ssh_host in the example is deprecated
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Vagrant version
2.2.5
Host operating system
Windows 10 (1709)
Guest operating system
Windows Server 2012 R2
Vagrantfile
Nothing specific:
Debug output
https://gist.github.com/mrshanahan/58edae984050bcb94dafae8ddd8545d1
Expected behavior
The command fails with a helpful error message, possibly indicating that VMMS is down.
Actual behavior
The
import_vm.ps1
script fails with the following error:Steps to reproduce
Get-Service vmms | Stop-Service
)vagrant up
(with--provider hyperv
as necessary with the box).Root cause
I've found the root cause and will open a PR ASAP. Just wanted to create an issue to track it.
Vagrant fails to create a VM due to VMMS not running, which is expected behavior. It then attempts to create a more helpful error message for the failed import, and starts by querying WMI for the VMMS service:
vagrant/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1
Line 357 in 83ed018
Since this service is not running, the return value is null, and the attempt to import the system definition from the null service fails:
vagrant/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1
Line 364 in 83ed018
Checking for null after querying the service and throwing a more specific message should do the trick.
The text was updated successfully, but these errors were encountered: