Sha256: 290338795f0efcf31e33e18a1940dc77e43699f759c9ed267ef25c5a95df56e5

Contents?: true

Size: 1.51 KB

Versions: 61

Compression:

Stored size: 1.51 KB

Contents

require 'fileutils'

module Vagrant
  module Command
    class UpgradeTo060Command < Base
      register "upgrade_to_060", "Upgrade pre-0.6.0 environment to 0.6.0", :hide => true

      def execute
        @env.ui.warn I18n.t("vagrant.commands.upgrade_to_060.info"), :prefix => false
        @env.ui.warn "", :prefix => false
        if !@env.ui.yes? I18n.t("vagrant.commands.upgrade_to_060.ask"), :prefix => false, :color => :yellow
          @env.ui.info I18n.t("vagrant.commands.upgrade_to_060.quit"), :prefix => false
          return
        end

        local_data = @env.local_data
        if !local_data.empty?
          if local_data[:active]
            @env.ui.confirm I18n.t("vagrant.commands.upgrade_to_060.already_done"), :prefix => false
            return
          end

          # Backup the previous file
          @env.ui.info I18n.t("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
          # active hash
          active = local_data.inject({}) do |acc, data|
            key, uuid = data
            acc[key.to_sym] = uuid
            acc
          end

          # Set the active hash to the active list and save it
          local_data.clear
          local_data[:active] = active
          local_data.commit
        end

        @env.ui.confirm I18n.t("vagrant.commands.upgrade_to_060.complete"), :prefix => false
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 5 rubygems

Version Path
vagrantup-0.8.9 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.8 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.7 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.6 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.5 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.4 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.3 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.2 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.10 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.1 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.8.0 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.8 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.7 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.6 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.5 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.4 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.3 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.2 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.1 lib/vagrant/command/upgrade_to_060.rb
vagrantup-0.7.0 lib/vagrant/command/upgrade_to_060.rb