Cleaner upgrade process and backup previous .vagrant file
This commit is contained in:
parent
446d1155fe
commit
baccbd047d
|
@ -1,3 +1,5 @@
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Command
|
module Command
|
||||||
class UpgradeTo060Command < Base
|
class UpgradeTo060Command < Base
|
||||||
|
@ -12,19 +14,29 @@ module Vagrant
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@env.local_data.empty?
|
local_data = @env.local_data
|
||||||
|
if !local_data.empty?
|
||||||
|
if local_data[:active]
|
||||||
|
@env.ui.confirm "vagrant.commands.upgrade_to_060.already_done", :_prefix => false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Backup the previous file
|
||||||
|
@env.ui.info "vagrant.commands.upgrade_to_060.backing_up", :_prefix => false
|
||||||
|
FileUtils.cp(local_data.file_path, "#{local_data.file_path}.bak-#{Time.now.to_i}")
|
||||||
|
|
||||||
# Gather the previously set virtual machines into a single
|
# Gather the previously set virtual machines into a single
|
||||||
# active hash
|
# active hash
|
||||||
active = @env.local_data.inject({}) do |acc, data|
|
active = local_data.inject({}) do |acc, data|
|
||||||
key, uuid = data
|
key, uuid = data
|
||||||
acc[key.to_sym] = uuid
|
acc[key.to_sym] = uuid
|
||||||
acc
|
acc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set the active hash to the active list and save it
|
# Set the active hash to the active list and save it
|
||||||
@env.local_data.clear
|
local_data.clear
|
||||||
@env.local_data[:active] = active
|
local_data[:active] = active
|
||||||
@env.local_data.commit
|
local_data.commit
|
||||||
end
|
end
|
||||||
|
|
||||||
@env.ui.confirm "vagrant.commands.upgrade_to_060.complete", :_prefix => false
|
@env.ui.confirm "vagrant.commands.upgrade_to_060.complete", :_prefix => false
|
||||||
|
|
|
@ -127,15 +127,17 @@ en:
|
||||||
up:
|
up:
|
||||||
vm_created: "VM already created. Booting if its not already running..."
|
vm_created: "VM already created. Booting if its not already running..."
|
||||||
upgrade_to_060:
|
upgrade_to_060:
|
||||||
|
already_done: "Environment appears to already be upgraded to 0.6.0. Doing nothing!"
|
||||||
|
ask: "Are you sure you want to execute this command?"
|
||||||
|
backing_up: "Backing up previous .vagrant file..."
|
||||||
|
complete: "Environment upgraded to 0.6.0 successfully."
|
||||||
info: |-
|
info: |-
|
||||||
This command will upgrade the current environment from a pre-0.6.0
|
This command will upgrade the current environment from a pre-0.6.0
|
||||||
environment to a 0.6.x compatible environment. Running this command
|
environment to a 0.6.x compatible environment. Running this command
|
||||||
on a 0.6.0 environment may cause corrupt virtual machines, however,
|
multiple times should be okay. This command will make a backup file
|
||||||
so verify now that this is your first time running this command and
|
prior to making any changes. Therefore, if anything goes wrong, then
|
||||||
that this environment was created pre-0.6.0.
|
restore that file to ".vagrant" in the same directory as the Vagrantfile.
|
||||||
ask: "Are you sure you want to execute this command?"
|
|
||||||
quit: "Not executing this command by user request. Quitting..."
|
quit: "Not executing this command by user request. Quitting..."
|
||||||
complete: "Environment upgraded to 0.6.0 successfully."
|
|
||||||
version:
|
version:
|
||||||
output: "Vagrant version %{version}"
|
output: "Vagrant version %{version}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue