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
29 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 |
# File 'lib/tenderloin/actions/vm/shared_folders.rb', line 29 def after_boot if Tenderloin.config.shared_folders.enabled logger.info "Creating shared folders metadata..." shared_folders.each do |name, hostpath, guestpath| for i in 0..3 begin status = Timeout::timeout(10) { @runner.fusion_vm.share_folder(name, File.(hostpath)) @runner.fusion_vm.enable_shared_folders 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| logger.info "-- #{name}: #{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
25 26 27 |
# File 'lib/tenderloin/actions/vm/shared_folders.rb', line 25 def before_boot end |
#shared_folders ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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) && folder.length == 3 folder else nil end end#.compact end |