Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/vagrant-parallels/driver/meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class VMNotFound < StandardError; end
# We use forwardable to do all our driver forwarding
extend Forwardable

# We cache the Parallels Desktop version here once we have one,
# since during the execution of Vagrant, it likely doesn't change.
@@version = nil
@@version_lock = Mutex.new

# The UUID of the virtual machine we represent
attr_reader :uuid

Expand All @@ -29,12 +34,14 @@ def initialize(uuid=nil)

# Read and assign the version of Parallels Desktop we know which
# specific driver to instantiate.
@version = read_version || ''

@@version_lock.synchronize do
@@version = read_version
end

# Instantiate the proper version driver for Parallels Desktop
@logger.debug("Finding driver for Parallels Desktop version: #{@version}")
@logger.debug("Finding driver for Parallels Desktop version: #{@@version}")

major_ver = @version.split('.').first.to_i
major_ver = @@version.split('.').first.to_i
driver_klass =
case major_ver
when 1..7 then raise Errors::ParallelsUnsupportedVersion
Expand All @@ -55,6 +62,7 @@ def initialize(uuid=nil)

@logger.info("Using Parallels driver: #{driver_klass}")
@driver = driver_klass.new(@uuid)
@version = @@version

if @uuid
# Verify the VM exists, and if it doesn't, then don't worry
Expand Down