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:20 UTC
svn commit: r962141 - in /incubator/deltacloud/trunk/rimudriver/lib:
rimu_hosting_driver.rb rimuhosting_client.rb
Author: lutter
Date: Thu Jul 8 23:25:19 2010
New Revision: 962141
URL: http://svn.apache.org/viewvc?rev=962141&view=rev
Log:
Lots of fixes to do with orders.
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=962141&r1=962140&r2=962141&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:19 2010
@@ -50,12 +50,16 @@ class RimuHostingDriver < DeltaCloud::Ba
end
def reboot_instance(credentials, id)
rh = new_client(credentials)
- rh.set_server_state(id, :REBOOTING)
+ rh.set_server_state(id, :RESTARTING)
end
- def stop_instance(credentials, id)
+ def start_instance(credentials, id)
rh = new_client(credentials)
- rh.set_server_state(id, :STOPPED)
+ rh.set_server_state(id, :STARTED)
+ end
+
+ def stop_instance(credentials, id)
+ destroy_instance(credentials, id)
end
def destroy_instance(credentials, id)
@@ -72,13 +76,15 @@ class RimuHostingDriver < DeltaCloud::Ba
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"],
+ :id => inst["order_oid"].to_s,
:name => inst["domain_name"],
- :image_id => inst["distro"],
+ :image_id => "lenny",
:state => "RUNNING",
:name => inst["domain_name"],
:realm_id => "RH",
@@ -100,7 +106,7 @@ class RimuHostingDriver < DeltaCloud::Ba
if (credentials[:password].nil? || credentials[:password] == '' || credentials[:name].nil? || credentials[:name] == '')
raise DeltaCloud::AuthException.new
end
-
+
RimuHostingClient.new(credentials[:name], credentials[:password])
end
end
\ No newline at end of file
Modified: incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb?rev=962141&r1=962140&r2=962141&view=diff
==============================================================================
--- incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb (original)
+++ incubator/deltacloud/trunk/rimudriver/lib/rimuhosting_client.rb Thu Jul 8 23:25:19 2010
@@ -5,18 +5,17 @@ require "json"
class RimuHostingClient
- def initialize(name, password ,baseuri = 'http://localhost:8080/rimuhosting/r')
+ def initialize(name, password ,baseuri = 'https://rimuhosting.com/r')
@uri = URI.parse(baseuri)
-
@service = Net::HTTP.new(@uri.host, @uri.port)
- @service.use_ssl = false
- @auth = "rimuhosting apikey=" % [password]
+ @service.use_ssl = true
+ @auth = "rimuhosting apikey=%s" % [password]
end
def request(resource, data='', method='GET')
headers = {"Accept" => "application/json", "Content-Type" => "application/json", "Authorization" => @auth}
r = @service.send_request(method, @uri.path + resource, data, headers)
- res = JSON.parse(r.body)
+ res = JSON.parse(r.body)
res[res.keys[0]]
end
@@ -33,17 +32,17 @@ class RimuHostingClient
end
def set_server_state(id, state)
- json = {:reboot_request => {:running_state => state}}
- request('/orders/order-#{id}/vps/running-state', json, 'PUT')
+ json = {"reboot_request" => {"running_state" => state}}.to_json
+ request("/orders/order-#{id}-a/vps/running-state", json, 'PUT')
end
def delete_server(id)
- request('/orders/order-#{id}/vps','', 'DELETE')
+ request("/orders/order-#{id}-a/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}}
+ :pricing_plan_code => flavor_id}}.to_json
request('/orders/new-vps',json, 'POST')[:about_order]
end
end