Class: VagrantPlugins::DigitalOcean::Actions::SetupNFS
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Actions::SetupNFS
- Includes:
- Helpers::File
- Defined in:
- lib/vagrant-digitalocean/actions/setup_nfs.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#determine_host_ip ⇒ Object
TODO not thread safe :( TODO google ip seems like a bad idea.
-
#initialize(app, env) ⇒ SetupNFS
constructor
A new instance of SetupNFS.
- #nfs_install(guest) ⇒ Object
Methods included from Helpers::File
Constructor Details
#initialize(app, env) ⇒ SetupNFS
Returns a new instance of SetupNFS.
9 10 11 12 |
# File 'lib/vagrant-digitalocean/actions/setup_nfs.rb', line 9 def initialize(app, env) @app, @env = app, env @translator = Helpers::Translator.new("actions.setup_nfs") end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-digitalocean/actions/setup_nfs.rb', line 14 def call(env) # set the nfs machine ip env[:nfs_machine_ip] = env[:machine].provider.ssh_info[:host] env[:ui].info @translator.t("machine_ip", :ip => env[:nfs_machine_ip]) # get the host ip from the local adapters raise Errors::LocalIPError if !(host_ip = determine_host_ip) env[:nfs_host_ip] = host_ip env[:ui].info @translator.t("host_ip", :ip => env[:nfs_host_ip]) # make sure the nfs server is setup env[:ui].info @translator.t("install") env[:machine].communicate.execute(nfs_install(env[:machine].guest)) vm = env[:machine].config.vm # force all shard folders to use nfs env[:ui].warn @translator.t("force_shared_folders") folders = vm.synced_folders.keys.each do |key| vm.synced_folders[key][:nfs] = true end @app.call(env) end |
#determine_host_ip ⇒ Object
TODO not thread safe :( TODO google ip seems like a bad idea
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vagrant-digitalocean/actions/setup_nfs.rb', line 43 def determine_host_ip # turn off reverse DNS resolution temporarily orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end |
#nfs_install(guest) ⇒ Object
55 56 57 |
# File 'lib/vagrant-digitalocean/actions/setup_nfs.rb', line 55 def nfs_install(guest) read_script("nfs", guest) end |