From a09429738a0d38df8fea3707122864f3cff7d835 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Thu, 23 Oct 2014 11:18:55 +0400 Subject: [PATCH] Port changes from mitchellh/vagrant@7ccec33 --- lib/vagrant-parallels/action.rb | 7 ++++--- .../action/prepare_nfs_settings.rb | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/vagrant-parallels/action.rb b/lib/vagrant-parallels/action.rb index 64015ab3..b9916067 100644 --- a/lib/vagrant-parallels/action.rb +++ b/lib/vagrant-parallels/action.rb @@ -304,8 +304,9 @@ def self.action_simple_reboot end end - # This action sync folders on a running provider. It is used by the docker provider - # to link synced folders on the host machine as volumes into the docker containers + # This is the action that is called to sync folders to a running machine + # without a reboot. It is used by the docker provider to link synced + # folders on the host machine as volumes into the docker containers. def self.action_sync_folders Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate @@ -320,7 +321,7 @@ def self.action_sync_folders b2.use Message, I18n.t("vagrant.commands.common.vm_not_running") next end - + b2.use PrepareNFSValidIds b2.use SyncedFolders b2.use PrepareNFSSettings end diff --git a/lib/vagrant-parallels/action/prepare_nfs_settings.rb b/lib/vagrant-parallels/action/prepare_nfs_settings.rb index 414ae196..7ff1263c 100644 --- a/lib/vagrant-parallels/action/prepare_nfs_settings.rb +++ b/lib/vagrant-parallels/action/prepare_nfs_settings.rb @@ -1,9 +1,11 @@ require 'ipaddr' +require "vagrant/action/builtin/mixin_synced_folders" module VagrantPlugins module Parallels module Action class PrepareNFSSettings + include Vagrant::Action::Builtin::MixinSyncedFolders include Vagrant::Util::Retryable def initialize(app, env) @@ -15,19 +17,19 @@ def call(env) @machine = env[:machine] @app.call(env) - if using_nfs?(@machine.config.vm) || using_nfs?(env[:synced_folders_config]) + opts = { + cached: !!env[:synced_folders_cached], + config: env[:synced_folders_config], + disable_usable_check: !!env[:test], + } + 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 end - # 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. - def using_nfs?(env) - env && env.synced_folders.any? { |_, opts| opts[:type] == :nfs } - end - # 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.