Class: Vagrant::Smartos::Zones::Action::ConfigureZoneSyncedFolders

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/vagrant/smartos/zones/action/configure_zone_synced_folders.rb

Instance Attribute Summary

Attributes included from Helper

#app, #env

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConfigureZoneSyncedFolders

Returns a new instance of ConfigureZoneSyncedFolders.



14
15
16
17
# File 'lib/vagrant/smartos/zones/action/configure_zone_synced_folders.rb', line 14

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant/smartos/zones/action/configure_zone_synced_folders.rb', line 19

def call(env)
  app.call(env)

  if zones_supported?
    zone = Vagrant::Smartos::Zones::Models::Zone.find(machine, machine.config.zone.name)
    machine.config.zone.synced_folders.each do |folder|
      configure_synced_folder(zone, folder)
    end
  end
end

#configure_synced_folder(zone, folder) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vagrant/smartos/zones/action/configure_zone_synced_folders.rb', line 30

def configure_synced_folder(zone, folder)
  host_path, guest_path, args = folder
  path = "/zones/#{zone.uuid}/root#{guest_path}"
  type = args.delete(:type) { |el| :rsync }

  username = args[:owner] || 'vagrant'
  groupname = args[:group] || 'vagrant'
  user = Vagrant::Smartos::Zones::Util::ZoneUser.new(machine, zone).find(username)
  group = Vagrant::Smartos::Zones::Util::ZoneGroup.new(machine, zone).find(groupname)

  machine.config.vm.synced_folders[path] = {
    disabled: false,
    guestpath: path,
    hostpath: host_path,
    type: type.to_sym,
    owner: user.uid,
    group: group.gid
  }.merge(args || {})
end