Move libvirt connection setup to driver

Handle libvirt connection through a driver located within the provider
so it can be reached via the machine settings. Adopt the format followed
by the docker/virtualbox providers as this is likely to remain well
supported.

Will allow queries to be made without needing to setup a specific action
which is important when dealing with parallel machine provisioning.
Calling actions from other threads to retrieve information on the state
of the other running machines currently will cause vagrant to complain
about the machine being locked.
This commit is contained in:
Darragh Bailey
2015-07-28 09:57:48 +01:00
parent a46545e66c
commit db440907f7
29 changed files with 103 additions and 123 deletions

View File

@@ -8,20 +8,6 @@ module VagrantPlugins
autoload :Errors, lib_path.join('errors')
autoload :Util, lib_path.join('util')
# Hold connection handler so there is no need to connect more times than
# one. This can be annoying when there are more machines to create, or when
# doing state action first and then some other.
#
# TODO Don't sure if this is the best solution
@@libvirt_connection = nil
def self.libvirt_connection
@@libvirt_connection
end
def self.libvirt_connection=(conn)
@@libvirt_connection = conn
end
def self.source_root
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
end