From 39ac0365c1767999a9f1fef6cd170c6e086da81a Mon Sep 17 00:00:00 2001 From: Patrick Debois Date: Thu, 18 Aug 2011 15:25:24 +0200 Subject: [PATCH] added openauth support thanks to @rubiojr --- lib/fog/compute/libvirt.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/fog/compute/libvirt.rb b/lib/fog/compute/libvirt.rb index 323c3627c..d059d9dcb 100644 --- a/lib/fog/compute/libvirt.rb +++ b/lib/fog/compute/libvirt.rb @@ -41,7 +41,19 @@ module Fog require 'libvirt' begin - @connection = ::Libvirt::open(@uri.uri) + if options[:libvirt_user] and options[:libvirt_password] + @connection = ::Libvirt::open_auth(@uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred| + if cred['type'] == ::Libvirt::CRED_AUTHNAME + res = options[:libvirt_user] + elsif cred["type"] == ::Libvirt::CRED_PASSPHRASE + res = options[:libvirt_password] + else + end + end + else + @connection = ::Libvirt::open(@uri.uri) + end + rescue ::Libvirt::ConnectionError raise Fog::Errors::Error.new("Error making a connection to libvirt URI #{@uri.uri}:\n#{$!}") end