Skip to content

Commit

Permalink
Release 'v1.0.2'
Browse files Browse the repository at this point in the history
* master:
  Fix NFSNoHostonlyNetwork error since v0.2.2
  Added unit test for 'read_guest_ip' driver method
  driver/pd_8: Handled the case when 'parallels_dhcp_leases' file is inaccessible [GH-74]
  • Loading branch information
legal90 committed Mar 13, 2014
2 parents 667d3e1 + b5bafb4 commit 56df5e2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/prepare_nfs_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def find_host_only_adapter
@machine.provider.driver.read_network_interfaces.each do |adapter, opts|
if opts[:type] == :hostonly
@machine.provider.driver.read_host_only_interfaces.each do |interface|
if interface[:bound_to] == opts[:hostonly]
if interface[:name] == opts[:hostonly]
return adapter, interface[:ip]
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant-parallels/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def clear_shared_folders
#
# @param [Hash] options Options to create the host only network.
# @return [Hash] The details of the host only network, including
# keys `:name`, `:bound_to`, `:ip`, `:netmask` and `:dhcp`
# keys `:name`, `:ip`, `:netmask` and `:dhcp`
def create_host_only_network(options)
end

Expand All @@ -68,7 +68,7 @@ def delete_unused_host_only_networks
# {
# :type => :hostonly,
# :hostonly => "vagrant-vnet0",
# :bound_to => "vnic2",
# :name => "vnic2",
# :nic_type => "virtio"
# }
#
Expand Down
7 changes: 5 additions & 2 deletions lib/vagrant-parallels/driver/pd_8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ def read_bridged_interfaces

def read_guest_ip
mac_addr = read_mac_address.downcase
File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
if line.include? mac_addr
leases_file = "/Library/Preferences/Parallels/parallels_dhcp_leases"
begin
File.open(leases_file).grep(/#{mac_addr}/) do |line|
return line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
end
rescue Errno::EACCES
raise Errors::DhcpLeasesNotAccessible, :leases_file => leases_file.to_s
end

nil
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Parallels
VERSION = "1.0.1"
VERSION = "1.0.2"
end
end
22 changes: 21 additions & 1 deletion test/unit/support/shared/pd_driver_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@
end
end

describe "read_guest_ip" do
let(:content) {'10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}

it "returns an IP address assigned to the specified MAC" do
driver.should_receive(:read_mac_address).and_return("001C420000FF")
File.should_receive(:open).with(an_instance_of(String)).
and_return(StringIO.new(content))

subject.read_guest_ip.should == "10.200.0.99"
end

it "rises DhcpLeasesNotAccessible exception when file is not accessible" do
File.stub(:open).and_call_original
File.should_receive(:open).with(an_instance_of(String)).
and_raise(Errno::EACCES)
expect { subject.read_guest_ip }.
to raise_error(VagrantPlugins::Parallels::Errors::DhcpLeasesNotAccessible)
end
end

describe "read_settings" do
it "returns a hash with detailed info about the VM" do
subject.read_settings.should be_kind_of(Hash)
Expand Down Expand Up @@ -230,7 +250,7 @@
subject.version.should match(/(#{parallels_version}[\d\.]+)/)
end

it "rises ParallelsInstallIncomplete exception when output is invalid" do
it "rises ParallelsInvalidVersion exception when output is invalid" do
subprocess.should_receive(:execute).
with("prlctl", "--version", an_instance_of(Hash)).
and_return(subprocess_result(exit_code: 0))
Expand Down

0 comments on commit 56df5e2

Please sign in to comment.