class VagrantPlugins::DockerProvider::Action::PrepareNFSSettings
Public Class Methods
new(app, env)
click to toggle source
# File lib/docker-provider/action/prepare_nfs_settings.rb, line 9 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::action::vm::nfs") end
Public Instance Methods
add_ips_to_env!(env)
click to toggle source
Extracts the proper host and guest IPs for NFS mounts and stores them in the environment for the SyncedFolder
action to use them in mounting.
The ! indicates that this method modifies its argument.
# File lib/docker-provider/action/prepare_nfs_settings.rb, line 45 def add_ips_to_env!(env) provider = env[:machine].provider host_ip = provider.driver.docker_bridge_ip machine_ip = provider.ssh_info[:host] raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip env[:nfs_host_ip] = host_ip env[:nfs_machine_ip] = machine_ip end
call(env)
click to toggle source
# File lib/docker-provider/action/prepare_nfs_settings.rb, line 14 def call(env) @machine = env[:machine] @app.call(env) if using_nfs? && !privileged_container? raise Errors::NfsWithoutPrivilegedError end if using_nfs? @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP") add_ips_to_env!(env) end end
privileged_container?()
click to toggle source
# File lib/docker-provider/action/prepare_nfs_settings.rb, line 36 def privileged_container? @machine.provider.driver.privileged?(@machine.id) end
using_nfs?()
click to toggle source
We’re using NFS if we have any synced folder with NFS configured. If we are not using NFS we don’t need to do the extra work to populate these fields in the environment.
# File lib/docker-provider/action/prepare_nfs_settings.rb, line 32 def using_nfs? @machine.config.vm.synced_folders.any? { |_, opts| opts[:type] == :nfs } end