You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:25:13 UTC

svn commit: r962139 - in /incubator/deltacloud/trunk/rimudriver/lib: rimu_hosting_driver.rb rimuhosting_client.rb

Author: lutter
Date: Thu Jul  8 23:25:13 2010
New Revision: 962139

URL: http://svn.apache.org/viewvc?rev=962139&view=rev
Log:
Implemented some new features of the driver

Modified:
    incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb   (contents, props changed)
    incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb   (contents, props changed)

Modified: incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb?rev=962139&r1=962138&r2=962139&view=diff
==============================================================================
--- incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb (original)
+++ incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb Thu Jul  8 23:25:13 2010
@@ -4,7 +4,7 @@ require "deltacloud/base_driver"
 class RimuHostingDriver < DeltaCloud::BaseDriver
   def images(credentails, opts=nil)
     rh = new_client(credentails)
-    res = rh.list_images.map do | image |
+    images = rh.list_images.map do | image |
       Image.new({
                   :id => image["distro_code"],
                   :name => image["distro_code"],
@@ -13,18 +13,14 @@ class RimuHostingDriver < DeltaCloud::Ba
                   :architecture => "x86"
               })
     end
-    #res.sort_by{|e| [e.description]}
-    res  
+    images.sort_by{|e| [e.description]}
+    images = filter_on( images, :id, opts)
+    images
   end
 
-  def flavor(credentials, opts=nil)
-    flav = flavors(credentials, opts)  
-    flav.each { |x| return x if x.id == opts[:id] }
-    nil
-  end
   def flavors(credentials, opts=nil)
     rh = new_client(credentials)
-    res = rh.list_plans.map do | flavor |
+    flavors = rh.list_plans.map do | flavor |
       Flavor.new({
                   :id => flavor["pricing_plan_code"],
                   :memory => flavor["minimum_memory_mb"].to_f/1024,
@@ -32,11 +28,21 @@ class RimuHostingDriver < DeltaCloud::Ba
                   :architecture => "x86"
                 })
     end
+    flavors = filter_on( flavors, :id, opts)
+    flavors
   end
 
+  def realms(credentials, opts=nil)
+    [Realm.new( {
+      :id=>"rimu",
+      :name=>"RimuHosting",
+      :state=> "AVAILABLE"
+    } )]
+  end
+  
   def instances(credentials, opts=nil)
     rh = new_client(credentials)
-    res = rh.list_nodes.map do | inst |
+    instances = rh.list_nodes.map do | inst |
       Instance.new({
                   :id => inst["order_oid"],
                   :name => inst["domain_name"],
@@ -49,8 +55,24 @@ class RimuHostingDriver < DeltaCloud::Ba
                   :actions => instance_actions_for("RUNNING")
               })
     end
+    instances = filter_on( instances, :id, opts)
+    instances
+  end
+  def reboot_instance(credentials, id)
+    rh = new_client(credentials)
+    rh.reboot_server(id)
   end
 
+  def stop_instance(credentials, id)
+    rh = new_client(credentials)
+    rh.stop_server(id)
+  end
+
+  def destroy_instance(credentials, id)
+    rh = new_client(credentials)
+    rh.delete_server(id)
+  end
+  
   def instance_states
     [
       [ :begin, { :running => :_auto_ }],

Propchange: incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb?rev=962139&r1=962138&r2=962139&view=diff
==============================================================================
--- incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb (original)
+++ incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb Thu Jul  8 23:25:13 2010
@@ -10,7 +10,7 @@ class RimuHostingClient
 
     @service = Net::HTTP.new(@uri.host, @uri.port)
     @service.use_ssl = false
-    @auth = "rimuhosting username=%s;password=%s" % [name, password]
+    @auth = "rimuhosting apikey=" % [password]
   end
 
   def request(resource, data='', method='GET')
@@ -31,5 +31,14 @@ class RimuHostingClient
   def list_nodes
     request('/orders;include_inactive=N')["about_orders"]
   end
+
+  def set_server_state(id, state)
+    json = {:reboot_request => {:running_state => state}}
+    request('/orders/order-#{id}/vps/running-state', json, 'PUT')
+  end
+
+  def delete_server(id)
+    request('/orders/order-#{id}/vps','', 'DELETE')
+  end
 end
 

Propchange: incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb
------------------------------------------------------------------------------
    svn:executable = *