deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1199727 - /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb
Date Wed, 09 Nov 2011 12:59:35 GMT
Author: marios
Date: Wed Nov  9 12:59:35 2011
New Revision: 1199727

URL: http://svn.apache.org/viewvc?rev=1199727&view=rev
Log:
Fixes for google storage driver - blob metadata listing and valid_credentials method

Signed-off-by: marios <marios@redhat.com>

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb?rev=1199727&r1=1199726&r2=1199727&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/google/google_driver.rb Wed Nov
 9 12:59:35 2011
@@ -83,12 +83,14 @@ class GoogleDriver < Deltacloud::BaseDri
     google_client = new_client(credentials)
     safely do
       google_blob = google_client.head_object(opts['bucket'], opts[:id]).headers
+      meta_hash = google_blob.inject({}){|result, (k,v)| result[k]=v if k=~/^x-goog-meta-/i
; result}
+      meta_hash.gsub_keys("x-goog-meta-", "")
       blobs << Blob.new({   :id => opts[:id],
                  :bucket => opts['bucket'],
                  :content_length => google_blob['Content-Length'],
                  :content_type => google_blob['Content-Type'],
                  :last_modified => google_blob['Last-Modified'],
-                 :user_metadata => google_blob.select{|k,v| k.match(/^x-goog-meta-/i)}
+                 :user_metadata => meta_hash
               })
 
     end
@@ -193,6 +195,14 @@ class GoogleDriver < Deltacloud::BaseDri
     end
   end
 
+  def valid_credentials?(credentials)
+    begin
+      new_client(credentials)
+    rescue
+      return false
+    end
+    return true
+  end
 
   private
 



Mime
View raw message