incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962253 - /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
Date Thu, 08 Jul 2010 23:41:08 GMT
Author: lutter
Date: Thu Jul  8 23:41:08 2010
New Revision: 962253

URL: http://svn.apache.org/viewvc?rev=962253&view=rev
Log:
Rackspace driver: make convert_srv_to_instance more robust

In particular,
  * do not expect srv["addresses"] to be set
  * turn various ints into strings

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb?rev=962253&r1=962252&r2=962253&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
(original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
Thu Jul  8 23:41:08 2010
@@ -114,21 +114,22 @@ class RackspaceDriver < Deltacloud::Base
 
 
   def convert_srv_to_instance(srv)
-            Instance.new( {
-                            :id=>srv["id"],
-                            :state=>srv["status"] == "ACTIVE" ? "RUNNING" : "PENDING",
-                            :name=>srv["name"],
-                            :image_id=>srv["imageId"],
-                            :owner_id=>"root",
-                            :realm_id=>"us",
-                            :public_addresses=>( srv["addresses"]["public"] ),
-                            :private_addresses=>( srv["addresses"]["private"] ),
-                            :flavor_id=>srv["flavorId"],
-                            :actions=>instance_actions_for(srv["status"] == "ACTIVE" ?
"RUNNING" : "PENDING"),
-                          } )
+    status = srv["status"] == "ACTIVE" ? "RUNNING" : "PENDING"
+    inst = Instance.new(:id => srv["id"].to_s,
+                        :owner_id => "root",
+                        :realm_id => "us")
+    inst.name = srv["name"]
+    inst.state = srv["status"] == "ACTIVE" ? "RUNNING" : "PENDING"
+    inst.actions = instance_actions_for(inst.state)
+    inst.image_id = srv["imageId"].to_s
+    inst.flavor_id = srv["flavorId"].to_s
+    if srv["addresses"]
+      inst.public_addresses  = srv["addresses"]["public"]
+      inst.private_addresses = srv["addresses"]["private"]
+    end
+    inst
   end
 
-
   def new_client(credentials)
     RackspaceClient.new(credentials.user, credentials.password)
   end



Mime
View raw message