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 04/10] Return an instance from the gogrid *_instance methods.
Date Fri, 06 Aug 2010 09:38:52 GMT
On 05/08/10 15:57 -0400, Chris Lalancette wrote:
>Signed-off-by: Chris Lalancette <clalance@redhat.com>
>---
> .../lib/deltacloud/drivers/gogrid/gogrid_driver.rb |   20 ++++++++------------
> 1 files changed, 8 insertions(+), 12 deletions(-)
>
>diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>index c0103c9..750e1cd 100644
>--- a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>+++ b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
>@@ -177,27 +177,23 @@ class GogridDriver < Deltacloud::BaseDriver
>   end
>
>   def reboot_instance(credentials, id)
>-    safely do
>-      new_client(credentials).request('grid/server/power', { 'id' => id, 'power' =>
'reboot'})
>-    end
>+    inst = new_client(credentials).request('grid/server/power', { 'name' => id, 'power'
=> 'reboot'})['list'].first
>+    convert_instance(inst, credentials.user)
>   end
>
>   def destroy_instance(credentials, id)
>-    safely do
>-      new_client(credentials).request('grid/server/delete', { 'id' => id})
>-    end
>+    inst = new_client(credentials).request('grid/server/delete', { 'name' => id})['list'].first
>+    convert_instance(inst, credentials.user)
>   end
>
>   def stop_instance(credentials, id)
>-    safely do
>-      new_client(credentials).request('grid/server/power', { 'id' => id, 'power' =>
'off'})
>-    end
>+    inst = new_client(credentials).request('grid/server/power', { 'name' => id, 'power'
=> 'off'})['list'].first
>+    convert_instance(inst, credentials.user)
>   end
>
>   def start_instance(credentials, id)
>-    safely do
>-      new_client(credentials).request('grid/server/power', { 'id' => id, 'power' =>
'on'})
>-    end
>+    inst = new_client(credentials).request('grid/server/power', { 'name' => id, 'power'
=> 'on'})['list'].first
>+    convert_instance(inst, credentials.user)
>   end
>
>   def key(credentials, opts=nil)

NAK. Please preserve 'safely do; end' blocks, they are extra usefull, for
catching backend exceptions:

    def start_instance(credentials, id)
     safely do
       inst = new_client(credentials).request('grid/server/power', { 'name' => id, 'power'
=> 'on'})['list'].first
       convert_instance(inst, credentials.user)
     end
    end

  -- Michal

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

Mime
View raw message