providers/hyperv: reset machine ID if machine deleted outside

This commit is contained in:
Mitchell Hashimoto 2014-02-26 11:20:53 -08:00
parent faf906c057
commit d4ec3b5dfc
1 changed files with 8 additions and 1 deletions

View File

@ -12,8 +12,15 @@ module VagrantPlugins
def call(env)
if env[:machine].id
options = { VmId: env[:machine].id }
response = env[:machine].provider.driver.execute('get_vm_status.ps1', options)
response = env[:machine].provider.driver.execute(
"get_vm_status.ps1", options)
env[:machine_state_id] = response["state"].downcase.to_sym
# If the machine isn't created, then our ID is stale, so just
# mark it as not created.
if env[:machine_state_id] == :not_created
env[:machine].id = nil
end
else
env[:machine_state_id] = :not_created
end