From fcffcb2ee0b2b103b2547f2a7236fe5ba3971c13 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 15 Aug 2012 21:55:25 -0700 Subject: [PATCH] Delete more unused actions --- lib/vagrant/action/env/set.rb | 21 -------- lib/vagrant/action/vm/export.rb | 57 -------------------- lib/vagrant/action/vm/package.rb | 23 -------- lib/vagrant/action/vm/package_vagrantfile.rb | 36 ------------- 4 files changed, 137 deletions(-) delete mode 100644 lib/vagrant/action/env/set.rb delete mode 100644 lib/vagrant/action/vm/export.rb delete mode 100644 lib/vagrant/action/vm/package.rb delete mode 100644 lib/vagrant/action/vm/package_vagrantfile.rb diff --git a/lib/vagrant/action/env/set.rb b/lib/vagrant/action/env/set.rb deleted file mode 100644 index 38e23915f..000000000 --- a/lib/vagrant/action/env/set.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Vagrant - module Action - module Env - # A middleware which just sets up the environment with some - # options which are passed to it. - class Set - def initialize(app, env, options=nil) - @app = app - @options = options || {} - end - - def call(env) - # Merge the options that were given to us - env.merge!(@options) - - @app.call(env) - end - end - end - end -end diff --git a/lib/vagrant/action/vm/export.rb b/lib/vagrant/action/vm/export.rb deleted file mode 100644 index 8228f86df..000000000 --- a/lib/vagrant/action/vm/export.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'fileutils' - -module Vagrant - module Action - module VM - class Export - attr_reader :temp_dir - - def initialize(app, env) - @app = app - @env = env - end - - def call(env) - @env = env - - raise Errors::VMPowerOffToPackage if @env["vm"].state != :poweroff - - setup_temp_dir - export - - @app.call(env) - - recover(env) # called to cleanup temp directory - end - - def recover(env) - if temp_dir && File.exist?(temp_dir) - FileUtils.rm_rf(temp_dir) - end - end - - def setup_temp_dir - @env[:ui].info I18n.t("vagrant.actions.vm.export.create_dir") - @temp_dir = @env["export.temp_dir"] = @env[:tmp_path].join(Time.now.to_i.to_s) - FileUtils.mkpath(@env["export.temp_dir"]) - end - - def export - @env[:ui].info I18n.t("vagrant.actions.vm.export.exporting") - @env[:vm].driver.export(ovf_path) do |progress| - @env[:ui].clear_line - @env[:ui].report_progress(progress.percent, 100, false) - end - - # Clear the line a final time so the next data can appear - # alone on the line. - @env[:ui].clear_line - end - - def ovf_path - File.join(@env["export.temp_dir"], "box.ovf") - end - end - end - end -end diff --git a/lib/vagrant/action/vm/package.rb b/lib/vagrant/action/vm/package.rb deleted file mode 100644 index d392d6514..000000000 --- a/lib/vagrant/action/vm/package.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'vagrant/action/general/package' - -module Vagrant - module Action - module VM - # A subclass of {General::Package} which simply makes sure that - # the package directory is set to the directory which the VM - # was exported to. - class Package < General::Package - # Doing this so that we can test that the parent is properly - # called in the unit tests. - alias_method :general_call, :call - def call(env) - # Just match up a couple environmental variables so that - # the superclass will do the right thing. Then, call the - # superclass - env["package.directory"] = env["export.temp_dir"] - general_call(env) - end - end - end - end -end diff --git a/lib/vagrant/action/vm/package_vagrantfile.rb b/lib/vagrant/action/vm/package_vagrantfile.rb deleted file mode 100644 index 17869091f..000000000 --- a/lib/vagrant/action/vm/package_vagrantfile.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'vagrant/util/template_renderer' - -module Vagrant - module Action - module VM - # Puts a generated Vagrantfile into the package directory so that - # it can be included in the package. - class PackageVagrantfile - # For TemplateRenderer - include Util - - def initialize(app, env) - @app = app - @env = env - end - - def call(env) - @env = env - create_vagrantfile - @app.call(env) - end - - # This method creates the auto-generated Vagrantfile at the root of the - # box. This Vagrantfile contains the MAC address so that the user doesn't - # have to worry about it. - def create_vagrantfile - File.open(File.join(@env["export.temp_dir"], "Vagrantfile"), "w") do |f| - f.write(TemplateRenderer.render("package_Vagrantfile", { - :base_mac => @env["vm"].driver.read_mac_address - })) - end - end - end - end - end -end