From d4ec3b5dfc7fded539b22b431f380df87491caa7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Feb 2014 11:20:53 -0800 Subject: [PATCH] providers/hyperv: reset machine ID if machine deleted outside --- plugins/providers/hyperv/action/read_state.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/action/read_state.rb b/plugins/providers/hyperv/action/read_state.rb index 31f5f2371..c56bd44c4 100644 --- a/plugins/providers/hyperv/action/read_state.rb +++ b/plugins/providers/hyperv/action/read_state.rb @@ -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