incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1091380 - in /incubator/deltacloud/trunk/server/lib/deltacloud: drivers/gogrid/gogrid_client.rb drivers/gogrid/gogrid_driver.rb helpers.rb
Date Tue, 12 Apr 2011 11:53:33 GMT
Author: mfojtik
Date: Tue Apr 12 11:53:33 2011
New Revision: 1091380

URL: http://svn.apache.org/viewvc?rev=1091380&view=rev
Log:
Fixed SSL bug in GoGrid driver

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb?rev=1091380&r1=1091379&r2=1091380&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb Tue Apr
12 11:53:33 2011
@@ -20,6 +20,16 @@ require 'digest/md5'
 require 'cgi'
 require 'open-uri'
 
+module OpenURI
+  def self.without_ssl_verification
+    old = ::OpenSSL::SSL::VERIFY_PEER
+    suppress_warnings { ::OpenSSL::SSL.const_set :VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE
}
+    yield
+  ensure
+    suppress_warnings { ::OpenSSL::SSL.const_set :VERIFY_PEER, old }
+  end
+end
+
 class GoGridClient
 
   def initialize(server='https://api.gogrid.com/api',
@@ -44,7 +54,9 @@ class GoGridClient
   end
   
   def sendAPIRequest(method,params={})
-    open(getRequestURL(method,params)).read
+    OpenURI.without_ssl_verification do
+      open(getRequestURL(method,params)).read
+    end
   end
 
   def request(method, params={}, version=nil)

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb?rev=1091380&r1=1091379&r2=1091380&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb Tue Apr
12 11:53:33 2011
@@ -320,6 +320,14 @@ class GogridDriver < Deltacloud::BaseDri
     stopped.to( :finish )       .on( :destroy )
   end
 
+  def catched_exceptions_list
+    {
+      :auth => [ /Forbidden/ ],
+      :error => [ /Error/ ],
+      :glob => [ /(.*)/ ]
+    }
+  end
+
   private
 
   def new_client(credentials)
@@ -386,9 +394,9 @@ class GogridDriver < Deltacloud::BaseDri
   def convert_image(gg_image, owner_id=nil)
     Image.new( {
       :id=>gg_image['id'],
-      :name => gg_image['friendlyName'],
-      :description=> convert_description(gg_image),
-      :owner_id=>gg_image['owner']['name'],
+      :name => "#{gg_image['friendlyName']}",
+      :description=> convert_description(gg_image).to_s,
+      :owner_id=>gg_image['owner']['name'].to_s,
       :architecture=>convert_arch(gg_image['description']),
       :state => gg_image['state']['name'].upcase
     } )
@@ -412,6 +420,7 @@ class GogridDriver < Deltacloud::BaseDri
   end
 
   def convert_arch(description)
+    return 'i386' unless description
     description.include?('64-bit') ? 'x86_64' : 'i386'
   end
 
@@ -437,7 +446,7 @@ class GogridDriver < Deltacloud::BaseDri
        # to uniquely identify this instance.
       :id => instance['name'],
       :owner_id => owner_id,
-      :image_id => instance['image']['id'],
+      :image_id => "#{instance['image']['id']}",
       :instance_profile => prof,
       :name => instance['name'],
       :realm_id => instance['ip']['datacenter']['id'],
@@ -471,6 +480,8 @@ class GogridDriver < Deltacloud::BaseDri
     end
     return ip
   end
+
+
 end
 
     end

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers.rb?rev=1091380&r1=1091379&r2=1091380&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers.rb Tue Apr 12 11:53:33 2011
@@ -20,4 +20,14 @@ require 'deltacloud/helpers/application_
 require 'deltacloud/helpers/conversion_helper'
 require 'deltacloud/helpers/hardware_profiles_helper'
 
+module Kernel
+  def suppress_warnings
+    original_verbosity = $VERBOSE
+    $VERBOSE = nil
+    result = yield
+    $VERBOSE = original_verbosity
+    return result
+  end
+end
+
 helpers ApplicationHelper, ConversionHelper, HardwareProfilesHelper



Mime
View raw message