incubator-deltacloud-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=962291&view=rev
Log:
Rackspace driver: use hardware profiles

  - Query list of hardware profiles form Rackspace
  - Expect parameter hwp_id for create_instance
  - Store InstanceProfile with instances

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=962291&r1=962290&r2=962291&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:43:47 2010
@@ -41,6 +41,18 @@ class RackspaceDriver < Deltacloud::Base
     results
   end
 
+  def hardware_profiles(credentials, opts = nil)
+    racks = new_client( credentials )
+    results = racks.list_flavors.map do |flav|
+      HardwareProfile.new(flav["id"].to_s) do
+        architecture 'x86_64'
+        memory flav["ram"].to_i
+        storage flav["disk"].to_i
+      end
+    end
+    filter_hardware_profiles(results, opts)
+  end
+
   def images(credentials, opts=nil)
     racks = new_client( credentials )
     results = racks.list_images.map do |img|
@@ -87,11 +99,10 @@ class RackspaceDriver < Deltacloud::Base
   #
   def create_instance(credentials, image_id, opts)
     racks = new_client( credentials )
-    flavor_id = 1
-    if (opts[:flavor_id]) then flavor_id = opts[:flavor_id] end
+    hwp_id = opts[:hwp_id] || 1
     name = Time.now.to_s
     if (opts[:name]) then name = opts[:name] end
-    convert_srv_to_instance(racks.start_server(image_id, flavor_id, name))
+    convert_srv_to_instance(racks.start_server(image_id, hwp_id, name))
   end
 
   #
@@ -123,6 +134,7 @@ class RackspaceDriver < Deltacloud::Base
     inst.actions = instance_actions_for(inst.state)
     inst.image_id = srv["imageId"].to_s
     inst.flavor_id = srv["flavorId"].to_s
+    inst.instance_profile = InstanceProfile.new(srv["flavorId"].to_s)
     if srv["addresses"]
       inst.public_addresses  = srv["addresses"]["public"]
       inst.private_addresses = srv["addresses"]["private"]



Mime
View raw message