def initialize(options={})
@uri = ::Fog::Compute::LibvirtUtil::URI.new(enhance_uri(options[:libvirt_uri]))
@ip_command = options[:libvirt_ip_command]
begin
require 'libvirt'
rescue LoadError => e
retry if require('rubygems')
raise e.message
end
begin
if options[:libvirt_username] and options[:libvirt_password]
@client = ::Libvirt::open_auth(uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred|
case cred['type']
when ::Libvirt::CRED_AUTHNAME
options[:libvirt_username]
when ::Libvirt::CRED_PASSPHRASE
options[:libvirt_password]
end
end
else
@client = ::Libvirt::open(uri.uri)
end
rescue ::Libvirt::ConnectionError
raise Fog::Errors::Error.new("Error making a connection to libvirt URI #{uri.uri}:\n#{$!}")
end
end