Class: VagrantPlugins::SyncedFolderNFSGuest::Action::MountNFS
- Inherits:
-
Object
- Object
- VagrantPlugins::SyncedFolderNFSGuest::Action::MountNFS
- Defined in:
- lib/vagrant-nfs_guest_vbfix/action/mount_nfs.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ MountNFS
constructor
A new instance of MountNFS.
Constructor Details
#initialize(app, env) ⇒ MountNFS
Returns a new instance of MountNFS.
6 7 8 9 |
# File 'lib/vagrant-nfs_guest_vbfix/action/mount_nfs.rb', line 6 def initialize(app,env) @app = app @logger = Log4r::Logger.new("vagrant-nfs_guest::action::unmount_nfs") end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vagrant-nfs_guest_vbfix/action/mount_nfs.rb', line 11 def call(env) @machine = env[:machine] # because we're hooked into Vagrant::Action::Builtin::SyncedFolders and # Vagrant::Action::Builtin::WaitForCommunicator we need to figure out # if we're 'up'ing from 'poweroff' or 'up'ing from 'suspend' # If 'poweroff' we get called twice once with state.id = 'poweroff' and # again with state.id = 'running'. This toggle around @app.call() allows # the second call to actually do the mount after the SyncFolder setup # has completed properly. If 'running' well then we just do the mount # as we're obvioulsy coming from a 'suspended' instance. Stupid bug. if !env[:nfs_guest_first_state] env[:nfs_guest_first_state] = @machine.state.id end @app.call(env) # ... and also deal with 'reload' :weary: if env[:nfs_guest_first_state] == :poweroff and env[:action_name] != :machine_action_reload env[:nfs_guest_first_state] = @machine.state.id return end if @machine.state.id == :running if !@machine.provider.capability?(:nfs_settings) raise SyncedFolderNFSGuest::Errors::ProviderNFSSettingsCapMissing end # grab the ips from the provider host_ip, machine_ip = @machine.provider.capability(:nfs_settings) raise Vagrant::Errors::NFSNoHostIP if !host_ip raise Vagrant::Errors::NFSNoGuestIP if !machine_ip machine_ip = [machine_ip] if !machine_ip.is_a?(Array) if @machine.config.nfs_guest.verify_installed if @machine.guest.capability?(:nfs_server_installed) installed = @machine.guest.capability(:nfs_server_installed) if installed # Mount guest NFS folders @machine.ui.info(I18n.t("vagrant_nfs_guest.actions.vm.nfs.mounting")) folders = @machine.config.vm.synced_folders @machine.env.host.capability(:nfs_mount, @machine.ui, @machine.id, machine_ip, folders) end end end end end |