From 7ccec334606bb6a306bcecc6c9a7e2562be3a694 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 22 Oct 2014 09:26:38 -0700 Subject: [PATCH] providers/virtualbox: define a sync_folders action to setup NFS [GH-4344] --- CHANGELOG.md | 1 + plugins/providers/virtualbox/action.rb | 10 ++++++++++ .../virtualbox/action/prepare_nfs_settings.rb | 11 ++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0d93c0a8..065faa34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ BUG FIXES: - providers/docker: Protocol is now honored in direct `ports settings. - providers/docker: Images built using `build\_dir` will more robustly capture the final image. [GH-4598] + - providers/docker: NFS synced folders now work. [GH-4344] - providers/virtualbox: Show a human-friendly error if VirtualBox didn't clean up an existing VM. [GH-4681] - provisioners/docker: Search for docker binary in multiple places. [GH-4580] diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index 668cbe0ef..83eb3aec9 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -292,6 +292,16 @@ module VagrantPlugins end end + # This is the action that is called to sync folders to a running + # machine without a reboot. + def self.action_sync_folders + Vagrant::Action::Builder.new.tap do |b| + b.use PrepareNFSValidIds + b.use SyncedFolders + b.use PrepareNFSSettings + end + end + # This action brings the machine up from nothing, including importing # the box, configuring metadata, and booting. def self.action_up diff --git a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb index b88cee99f..b7a92d1ac 100644 --- a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +++ b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb @@ -1,7 +1,10 @@ +require "vagrant/action/builtin/mixin_synced_folders" + module VagrantPlugins module ProviderVirtualBox module Action class PrepareNFSSettings + include Vagrant::Action::Builtin::MixinSyncedFolders include Vagrant::Util::Retryable def initialize(app, env) @@ -14,7 +17,13 @@ module VagrantPlugins @app.call(env) - if using_nfs? + opts = { + cached: !!env[:synced_folders_cached], + config: env[:synced_folders_config], + } + folders = synced_folders(env[:machine], **opts) + + if folders.has_key?(:nfs) @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP") add_ips_to_env!(env) end