Return-Path: Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: (qmail 22756 invoked from network); 8 Jul 2010 23:26:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jul 2010 23:26:12 -0000 Received: (qmail 65040 invoked by uid 500); 8 Jul 2010 23:26:12 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 65019 invoked by uid 500); 8 Jul 2010 23:26:12 -0000 Mailing-List: contact deltacloud-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-commits@incubator.apache.org Received: (qmail 65012 invoked by uid 99); 8 Jul 2010 23:26:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 23:26:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 23:26:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E28D82388A3B; Thu, 8 Jul 2010 23:25:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r962140 - in /incubator/deltacloud/trunk/rimudriver/lib: rimu_hosting_driver.rb rimuhosting_client.rb Date: Thu, 08 Jul 2010 23:25:16 -0000 To: deltacloud-commits@incubator.apache.org From: lutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100708232516.E28D82388A3B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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