class VagrantPlugins::ProviderLibvirt::Action::ShareFolders
Public Class Methods
new(app, env)
click to toggle source
# File lib/vagrant-libvirt/action/share_folders.rb, line 9 def initialize(app, env) @logger = Log4r::Logger.new("vagrant::action::vm::share_folders") @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/vagrant-libvirt/action/share_folders.rb, line 14 def call(env) @env = env prepare_folders create_metadata @app.call(env) end
create_metadata()
click to toggle source
# File lib/vagrant-libvirt/action/share_folders.rb, line 57 def create_metadata @env[:ui].info I18n.t("vagrant.actions.vm.share_folders.creating") folders = [] shared_folders.each do |id, data| folders << { :name => id, :hostpath => File.expand_path(data[:hostpath], @env[:root_path]), :transient => data[:transient] } end end
prepare_folders()
click to toggle source
Prepares the shared folders by verifying they exist and creating them if they don't.
# File lib/vagrant-libvirt/action/share_folders.rb, line 39 def prepare_folders shared_folders.each do |id, options| hostpath = Pathname.new(options[:hostpath]).expand_path(@env[:root_path]) if !hostpath.directory? && options[:create] # Host path doesn't exist, so let's create it. @logger.debug("Host path doesn't exist, creating: #{hostpath}") begin hostpath.mkpath rescue Errno::EACCES raise Vagrant::Errors::SharedFolderCreateFailed, :path => hostpath.to_s end end end end