incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/3] Fixed Rackspace driver error code when you're trying to get non-existing instance Removed extra call to images when you're starting a new instance.
Date Wed, 30 Mar 2011 13:31:12 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 .../drivers/rackspace/rackspace_driver.rb          |   15 +++++++++------
 server/server.rb                                   |    8 +++-----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
index 4363580..c0c93e4 100644
--- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
+++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
@@ -154,13 +154,16 @@ class RackspaceDriver < Deltacloud::BaseDriver
     insts = []
 
     safely do
-      if opts[:id]
-        server = rs.get_server(opts[:id].to_i)
-        insts << convert_instance_after_create(server, credentials.user)
-      else
-        insts = rs.list_servers_detail.collect do |server|
-          convert_instance(server, credentials.user)
+      begin
+        if opts[:id]
+          server = rs.get_server(opts[:id].to_i)
+          insts << convert_instance_after_create(server, credentials.user)
+        else
+          insts = rs.list_servers_detail.collect do |server|
+            convert_instance(server, credentials.user)
+          end
         end
+      rescue CloudServers::Exception::ItemNotFound
       end
     end
 
diff --git a/server/server.rb b/server/server.rb
index 3c4273c..05b715c 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -363,17 +363,15 @@ END
     param :realm_id,     :string, :optional
     param :hwp_id,       :string, :optional
     control do
-      @image = driver.image(credentials, :id => params[:image_id])
-      instance = driver.create_instance(credentials, @image.id, params)
+      @instance = driver.create_instance(credentials, params[:image_id], params)
       respond_to do |format|
         format.xml do
           response.status = 201  # Created
-          response['Location'] = instance_url(instance.id)
-          @instance = instance
+          response['Location'] = instance_url(@instance.id)
           haml :"instances/show"
         end
         format.html do
-          redirect instance_url(instance.id) if instance and instance.id
+          redirect instance_url(@instance.id) if @instance and @instance.id
           redirect instances_url
         end
       end
-- 
1.7.4.1


Mime
View raw message