incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH core] Fixed GoGrid driver
Date Mon, 09 Aug 2010 17:08:28 GMT
On 09/08/10 19:01 +0200, mfojtik@redhat.com wrote:
>---
> .../lib/deltacloud/drivers/gogrid/gogrid_client.rb |   15 +++-
> .../lib/deltacloud/drivers/gogrid/gogrid_driver.rb |   87 ++++++++-----------
> server/lib/deltacloud/drivers/gogrid/test.rb       |   13 +++
> 3 files changed, 62 insertions(+), 53 deletions(-)
> create mode 100644 server/lib/deltacloud/drivers/gogrid/test.rb
>
>diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb b/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
>index f4f5796..c37f061 100644
>--- a/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
>+++ b/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
>@@ -9,7 +9,7 @@ class GoGridClient
>                  apikey='YOUR API KEY',
>                  secret='YOUR SHARED SECRET',
>                  format='json',
>-                 version='1.4')
>+                 version='1.5')
>     @server = server
>     @secret = secret
>     @default_params = {'format'=>format, 'v'=>version,'api_key' => apikey}
>@@ -30,8 +30,17 @@ class GoGridClient
>     open(getRequestURL(method,params)).read
>   end
>
>-  def request(method, params={})
>-    JSON::parse(sendAPIRequest(method, params))
>+  def request(method, params={}, version=nil)
>+    if version
>+      @default_params['v'] = version
>+    else
>+      @default_params['v'] = '1.5'
>+    end
>+    begin
>+      JSON::parse(sendAPIRequest(method, params))
>+    rescue Exception => e
>+      STDERR.puts("ERROR: #{e.message}")
>+    end
>   end
>
>   def encode_params(params)
>diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>index 72d91b6..e6c99c5 100644
>--- a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>+++ b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>@@ -37,34 +37,10 @@ class GogridDriver < Deltacloud::BaseDriver
>
>   feature :instances, :authentication_password
>
>-  define_hardware_profile '512MB' do
>-    cpu            0.5
>-    memory         512
>-    storage        30
>-  end
>-
>-  define_hardware_profile '1GB' do
>-    cpu            1
>-    memory         1
>-    storage        60
>-  end
>-
>-  define_hardware_profile '2GB' do
>+  define_hardware_profile 'server' do
>     cpu            2
>-    memory         2
>-    storage        120
>-  end
>-
>-  define_hardware_profile '4GB' do
>-    cpu            4
>-    memory         4
>-    storage        240
>-  end
>-
>-  define_hardware_profile '8GB' do
>-    cpu            8
>-    memory         8
>-    storage        480
>+    memory         [512, 1024, 2048, 4096, 8192]
>+    storage        10
>   end

Sorry for this, seems like I did something terrible to my GIT repository
;-)

>+user='fbb1de3897597ccf'
>+password='ngieth10'
>+
>+client=GoGridClient.new('https://api.gogrid.com/api', user, password)

Also I accedentialy post this test file with obsolete credentials ;-)

-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com, +420 532 294 4307
Ruby / Ruby On Rails Developer
Deltacloud API: http://deltacloud.org
--------------------------------------------------------

Mime
View raw message