Class: Vagrant::LXC::Action::ShareFolders
- Inherits:
-
Object
- Object
- Vagrant::LXC::Action::ShareFolders
- Defined in:
- lib/vagrant-lxc/action/share_folders.rb
Instance Method Summary collapse
- #add_override_configs ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ShareFolders
constructor
A new instance of ShareFolders.
-
#prepare_folders ⇒ Object
Prepares the shared folders by verifying they exist and creating them if they don’t.
-
#shared_folders ⇒ Object
This method returns an actual list of VirtualBox shared folders to create and their proper path.
Constructor Details
#initialize(app, env) ⇒ ShareFolders
Returns a new instance of ShareFolders.
5 6 7 |
# File 'lib/vagrant-lxc/action/share_folders.rb', line 5 def initialize(app, env) @app = app end |
Instance Method Details
#add_override_configs ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vagrant-lxc/action/share_folders.rb', line 47 def add_override_configs @env[:ui].info I18n.t("vagrant.actions.lxc.share_folders.preparing") folders = [] shared_folders.each do |id, data| folders << { :name => id, :hostpath => File.(data[:hostpath], @env[:root_path]), :guestpath => data[:guestpath] } @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", :guest_path => data[:guestpath])) end @env[:machine].provider.driver.share_folders(folders) end |
#call(env) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/vagrant-lxc/action/share_folders.rb', line 9 def call(env) @env = env prepare_folders add_override_configs @app.call env end |
#prepare_folders ⇒ Object
Prepares the shared folders by verifying they exist and creating them if they don’t.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-lxc/action/share_folders.rb', line 29 def prepare_folders shared_folders.each do |id, | hostpath = Pathname.new([:hostpath]).(@env[:root_path]) if !hostpath.directory? && [: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 |
#shared_folders ⇒ Object
This method returns an actual list of VirtualBox shared folders to create and their proper path.
18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-lxc/action/share_folders.rb', line 18 def shared_folders {}.tap do |result| @env[:machine].config.vm.synced_folders.each do |id, data| # This to prevent overwriting the actual shared folders data result[id] = data.dup end end end |