def initialize(options={})
@uri = ::Fog::Compute::LibvirtUtil::URI.new(enhance_uri(options[:libvirt_uri]))
@ip_command = options[:libvirt_ip_command]
require 'libvirt'
begin
if options[:libvirt_username] and options[:libvirt_password]
@raw = ::Libvirt::open_auth(@uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred|
if cred['type'] == ::Libvirt::CRED_AUTHNAME
res = options[:libvirt_username]
elsif cred["type"] == ::Libvirt::CRED_PASSPHRASE
res = options[:libvirt_password]
else
end
end
else
@raw = ::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