Class: Tenderloin::Actions::VM::SharedFolders
- Defined in:
- lib/tenderloin/actions/vm/shared_folders.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#cleanup, #execute!, #initialize, #prepare, #rescue
Methods included from Util
#error_and_exit, included, #logger, #wrap_output
Constructor Details
This class inherits a constructor from Tenderloin::Actions::Base
Instance Method Details
#after_boot ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/tenderloin/actions/vm/shared_folders.rb', line 30 def after_boot if Tenderloin.config.shared_folders.enabled logger.info "Creating shared folders metadata..." # Enable Shared Folders. It fails if it's already enabled. # If it's a real error the command to add a shared folder will fail, # so we can ignore this one. @runner.fusion_vm.enable_shared_folders rescue nil shared_folders.each do |name, hostpath, guestpath| 4.times do begin Timeout::timeout(10) { @runner.fusion_vm.share_folder(name, File.(hostpath)) break } rescue Timeout::Error logger.warn "Sharing folder #{name} timed out" end end end logger.info "Linking shared folders..." Tenderloin::SSH.execute(@runner.fusion_vm.ip) do |ssh| shared_folders.each do |name, hostpath, guestpath| next unless guestpath logger.info "-- #{name}: #{guestpath}" ssh.exec!("sudo rm -rf #{guestpath}") ssh.exec!("sudo ln -s /mnt/hgfs/#{name} #{guestpath}") ssh.exec!("sudo chown #{Tenderloin.config.ssh.username} #{guestpath}") end end end end |
#before_boot ⇒ Object
26 27 28 |
# File 'lib/tenderloin/actions/vm/shared_folders.rb', line 26 def before_boot end |
#shared_folders ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tenderloin/actions/vm/shared_folders.rb', line 7 def shared_folders shared_folders = @runner.invoke_callback(:collect_shared_folders) shared_folders = shared_folders + Tenderloin.config.shared_folders.folders # Basic filtering of shared folders. Basically only verifies that # the result is an array of 3 elements. In the future this should # also verify that the host path exists, the name is valid, # and that the guest path is valid. shared_folders.collect do |folder| if folder.is_a?(Array) && [2, 3].include?(folder.length) folder else logger.warn("Ignoring invalid shared folder: #{folder}") nil end end.compact end |