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:16 UTC
svn commit: r962140 - in /incubator/deltacloud/trunk/rimudriver/lib:
rimu_hosting_driver.rb rimuhosting_client.rb
Author: lutter
Date: Thu Jul 8 23:25:16 2010
New Revision: 962140
URL: http://svn.apache.org/viewvc?rev=962140&view=rev
Log:
Added the create server methods
Modified:
incubator/deltacloud/trunk/rimudriver/lib/rimu_hosting_driver.rb
incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb
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=962140&r1=962139&r2=962140&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:16 2010
@@ -43,29 +43,19 @@ class RimuHostingDriver < DeltaCloud::Ba
def instances(credentials, opts=nil)
rh = new_client(credentials)
instances = rh.list_nodes.map do | inst |
- Instance.new({
- :id => inst["order_oid"],
- :name => inst["domain_name"],
- :image_id => inst["distro"],
- :state => "RUNNING",
- :name => inst["domain_name"],
- :realm_id => "RH",
- :owner_id => "root",
- :flavor_id => "none",
- :actions => instance_actions_for("RUNNING")
- })
+ convert_srv_to_instance(inst)
end
instances = filter_on( instances, :id, opts)
instances
end
def reboot_instance(credentials, id)
rh = new_client(credentials)
- rh.reboot_server(id)
+ rh.set_server_state(id, :REBOOTING)
end
def stop_instance(credentials, id)
rh = new_client(credentials)
- rh.stop_server(id)
+ rh.set_server_state(id, :STOPPED)
end
def destroy_instance(credentials, id)
@@ -73,6 +63,30 @@ class RimuHostingDriver < DeltaCloud::Ba
rh.delete_server(id)
end
+ def create_instance(credentials, image_id, opts)
+ rh = new_client( credentials )
+ # really need to raise an exception here.
+ flavor_id = 1
+ if (opts[:flavor_id]) then flavor_id = opts[:flavor_id] end
+ # really bad, but at least its a fqdn
+ name = Time.now.to_s + '.com'
+ if (opts[:name]) then name = opts[:name] end
+ convert_srv_to_instance(rh.start_server(image_id, flavor_id, name))
+ end
+
+ def convert_srv_to_instance( inst )
+ Instance.new({
+ :id => inst["order_oid"],
+ :name => inst["domain_name"],
+ :image_id => inst["distro"],
+ :state => "RUNNING",
+ :name => inst["domain_name"],
+ :realm_id => "RH",
+ :owner_id => "root",
+ :flavor_id => "none",
+ :actions => instance_actions_for("RUNNING")
+ })
+ end
def instance_states
[
[ :begin, { :running => :_auto_ }],
Modified: incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb?rev=962140&r1=962139&r2=962140&view=diff
==============================================================================
--- incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb (original)
+++ incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb Thu Jul 8 23:25:16 2010
@@ -40,5 +40,11 @@ class RimuHostingClient
def delete_server(id)
request('/orders/order-#{id}/vps','', 'DELETE')
end
+
+ def create_server(image_id, flavor_id, name)
+ json = {:new_vps => {:instantiation_options => {:domain_name => name, :distro => image_id},
+ :pricing_plan_code => flavor_id}}
+ request('/orders/new-vps',json, 'POST')[:about_order]
+ end
end