vagrant-lxc-ng/lib/vagrant-lxc/action/compress_rootfs.rb
2013-04-05 22:10:48 -03:00

31 lines
714 B
Ruby

require "fileutils"
module Vagrant
module LXC
module Action
class CompressRootFS
def initialize(app, env)
@app = app
end
def call(env)
raise Vagrant::Errors::VMPowerOffToPackage if env[:machine].provider.state.id != :stopped
env[:ui].info I18n.t("vagrant.actions.lxc.compressing_rootfs")
@rootfs = env['package.rootfs'] = env[:machine].provider.driver.compress_rootfs
@app.call env
recover # called to remove the rootfs tarball
end
def recover(*)
if @rootfs && File.exist?(@rootfs)
FileUtils.rm_rf(File.dirname @rootfs)
end
end
end
end
end
end