Created
August 18, 2011 11:18
-
-
Save rubiojr/1153869 to your computer and use it in GitHub Desktop.
open_auth support for libvirt fog provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/fog/compute/libvirt.rb b/lib/fog/compute/libvirt.rb | |
index 323c362..930be4f 100644 | |
--- a/lib/fog/compute/libvirt.rb | |
+++ b/lib/fog/compute/libvirt.rb | |
@@ -41,7 +41,18 @@ module Fog | |
require 'libvirt' | |
begin | |
- @connection = ::Libvirt::open(@uri.uri) | |
+ if options[:user] and options[:password] | |
+ @connection = ::Libvirt::open_auth(@uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred| | |
+ if cred['type'] == ::Libvirt::CRED_AUTHNAME | |
+ res = options[:user] | |
+ elsif cred["type"] == ::Libvirt::CRED_PASSPHRASE | |
+ res = options[: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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment