diff --git a/lib/vagrant-parallels/action/prepare_nfs_settings.rb b/lib/vagrant-parallels/action/prepare_nfs_settings.rb index 7ff1263c..ee43ce16 100644 --- a/lib/vagrant-parallels/action/prepare_nfs_settings.rb +++ b/lib/vagrant-parallels/action/prepare_nfs_settings.rb @@ -36,40 +36,16 @@ def call(env) # # The ! indicates that this method modifies its argument. def add_ips_to_env!(env) - host_ip = @machine.provider.driver.read_shared_interface[:ip] + host_ip = @machine.provider.driver.read_shared_interface[:ip] + guest_ip = @machine.provider.driver.read_guest_ip - if !host_ip - # If we couldn't determine host's IP, then it is probably a bug. - # Display an appropriate error message. - raise Vagrant::Errors::NFSNoHostIP - end + # If we couldn't determine either guest's or host's IP, then + # it is probably a bug. Display an appropriate error message. + raise Vagrant::Errors::NFSNoHostIP if !host_ip + raise Vagrant::Errors::NFSNoGuestIP if !guest_ip env[:nfs_host_ip] = host_ip - env[:nfs_machine_ip] = read_machine_ip - end - - # Returns the IPv4 addresses of the guest by looking at VM options. - # - # For DHCP interfaces, the ip address will be present at the option - # value only after VM boot - # - # @return [String] ip addresses - def read_machine_ip - # We need to wait for the guest's IP to show up as a VM option. - # Retry thresholds are relatively high since we might need to wait - # for DHCP, but even static IPs can take a second or two to appear. - retryable(retry_options.merge(on: Errors::ParallelsVMOptionNotFound)) do - ips = @machine.provider.driver.read_vm_option('ip').split(' ') - ips.select! { |ip| IPAddr.new(ip).ipv4? }.sort - end - rescue Errors::ParallelsVMOptionNotFound - # Display an appropriate error message. - raise Vagrant::Errors::NFSNoGuestIP - end - - # Separating these out so we can stub out the sleep in tests - def retry_options - {tries: 7, sleep: 2} + env[:nfs_machine_ip] = guest_ip end end end diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index 53503fd2..0004b597 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -88,6 +88,7 @@ def initialize(uuid=nil) :import, :read_bridged_interfaces, :read_forwarded_ports, + :read_guest_ip, :read_guest_tools_state, :read_guest_tools_iso_path, :read_host_only_interfaces, @@ -100,7 +101,6 @@ def initialize(uuid=nil) :read_state, :read_used_ports, :read_virtual_networks, - :read_vm_option, :read_vms, :read_vms_info, :read_vms_paths,