Class: VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder
- Defined in:
- lib/vagrant-libvirt/action/clean_machine_folder.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env, options = nil) ⇒ CleanMachineFolder
constructor
A new instance of CleanMachineFolder.
Constructor Details
#initialize(app, env, options = nil) ⇒ CleanMachineFolder
Returns a new instance of CleanMachineFolder.
10 11 12 13 14 15 |
# File 'lib/vagrant-libvirt/action/clean_machine_folder.rb', line 10 def initialize(app, env, =nil) @logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain') @app = app @ui = env[:ui] @quiet = ( || {}).fetch(:quiet, false) end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-libvirt/action/clean_machine_folder.rb', line 17 def call(env) machine_folder = env[:machine].data_dir @ui.info("Deleting the machine folder") unless @quiet @logger.debug("Recursively removing: #{machine_folder}") FileUtils.rm_rf(machine_folder, :secure => true) # need to recreate to prevent exception during a cancelled up FileUtils.mkdir_p(machine_folder) @app.call(env) end |