From a34ee404d82cdf24be8515cef6966e7e09da52a1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 5 May 2014 21:52:28 -0700 Subject: [PATCH] providers/*: use special NOT_CREATED_ID if not created --- plugins/providers/docker/provider.rb | 8 +++++--- plugins/providers/hyperv/provider.rb | 5 +++++ plugins/providers/virtualbox/provider.rb | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/providers/docker/provider.rb b/plugins/providers/docker/provider.rb index b2c1f2fe2..de18a206d 100644 --- a/plugins/providers/docker/provider.rb +++ b/plugins/providers/docker/provider.rb @@ -146,12 +146,14 @@ module VagrantPlugins state_id = driver.state(@machine.id) if @machine.id && !state_id state_id = :unknown if !state_id - # If the machine is not created, make sure to clear out machine ID - @machine.id = nil if state_id == :not_created - short = state_id.to_s.gsub("_", " ") long = I18n.t("docker_provider.status.#{state_id}") + # If we're not created, then specify the special ID flag + if state_id == :not_created + state_id = Vagrant::MachineState::NOT_CREATED_ID + end + Vagrant::MachineState.new(state_id, short, long) end diff --git a/plugins/providers/hyperv/provider.rb b/plugins/providers/hyperv/provider.rb index 75aeaee88..d8fee52e7 100644 --- a/plugins/providers/hyperv/provider.rb +++ b/plugins/providers/hyperv/provider.rb @@ -67,6 +67,11 @@ module VagrantPlugins short = state_id.to_s long = "" + # If we're not created, then specify the special ID flag + if state_id == :not_created + state_id = Vagrant::MachineState::NOT_CREATED_ID + end + # Return the MachineState object Vagrant::MachineState.new(state_id, short, long) end diff --git a/plugins/providers/virtualbox/provider.rb b/plugins/providers/virtualbox/provider.rb index 28d220223..3f265c6ad 100644 --- a/plugins/providers/virtualbox/provider.rb +++ b/plugins/providers/virtualbox/provider.rb @@ -79,15 +79,15 @@ module VagrantPlugins state_id = @driver.read_state if !state_id state_id = :unknown if !state_id - # If we're not created, then reset the ID to nil - if state_id == :not_created - @machine.id = nil - end - # Translate into short/long descriptions short = state_id.to_s.gsub("_", " ") long = I18n.t("vagrant.commands.status.#{state_id}") + # If we're not created, then specify the special ID flag + if state_id == :not_created + state_id = Vagrant::MachineState::NOT_CREATED_ID + end + # Return the state Vagrant::MachineState.new(state_id, short, long) end