Class: VagrantPlugins::ProviderKvm::SyncedFolder
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderKvm::SyncedFolder
- Defined in:
- lib/vagrant-kvm/synced_folder.rb
Instance Method Summary collapse
- #cleanup(machine, opts) ⇒ Object
- #enable(machine, folders, _opts) ⇒ Object
- #prepare(machine, folders, _opts) ⇒ Object
- #usable?(machine) ⇒ Boolean
Instance Method Details
#cleanup(machine, opts) ⇒ Object
45 46 47 |
# File 'lib/vagrant-kvm/synced_folder.rb', line 45 def cleanup(machine, opts) driver(machine).clear_shared_folders if machine.id && machine.id != "" end |
#enable(machine, folders, _opts) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-kvm/synced_folder.rb', line 29 def enable(machine, folders, _opts) # Go through each folder and mount machine.ui.info("mounting p9 share in guest") # Only mount folders that have a guest path specified. mount_folders = {} folders.each do |id, opts| mount_folders[id] = opts.dup if opts[:guestpath] end common_opts = { :version => '9p2000.L', } # Mount the actual folder machine.guest.capability( :mount_p9_shared_folder, mount_folders, common_opts) end |
#prepare(machine, folders, _opts) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-kvm/synced_folder.rb', line 11 def prepare(machine, folders, _opts) defs = [] folders.each do |id, data| # access_mode can be squash, mapped, or passthrough accessmode = data.has_key?(:access_mode)? data[:access_mode] : 'squash' accessmode = 'squash' unless accessmode == 'mapped' || accessmode == 'passthrough' # tag maximum len is 31 tag = Digest::MD5.new.update(id).to_s[0,31] defs << { :mount_tag => tag, :hostpath => data[:hostpath].to_s, :accessmode => accessmode } end driver(machine).share_folders(defs) end |
#usable?(machine) ⇒ Boolean
6 7 8 9 |
# File 'lib/vagrant-kvm/synced_folder.rb', line 6 def usable?(machine) # These synced folders only work if the provider if KVM machine.provider_name == :kvm end |