Return-Path: Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: (qmail 12491 invoked from network); 30 Sep 2010 12:49:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Sep 2010 12:49:07 -0000 Received: (qmail 45966 invoked by uid 500); 30 Sep 2010 12:49:07 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 45931 invoked by uid 500); 30 Sep 2010 12:49:07 -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 45924 invoked by uid 99); 30 Sep 2010 12:49:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 12:49:07 +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, 30 Sep 2010 12:48:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6A4512388C02; Thu, 30 Sep 2010 12:48:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1003045 [11/24] - in /incubator/deltacloud/trunk: server/ site/api-docs/ site/api-docs/CloudClient/ site/api-docs/Deltacloud/ site/api-docs/Deltacloud/BaseDriver/ site/api-docs/Deltacloud/Drivers/ site/api-docs/Deltacloud/Drivers/Azure/ si... Date: Thu, 30 Sep 2010 12:48:04 -0000 To: deltacloud-commits@incubator.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100930124806.6A4512388C02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingClient.html URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingClient.html?rev=1003045&view=auto ============================================================================== --- incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingClient.html (added) +++ incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingClient.html Thu Sep 30 12:48:00 2010 @@ -0,0 +1,571 @@ + + + + +Class: Deltacloud::Drivers::RimuHosting::RimuHostingClient + + + + + + + + + + + + + + + +

Class: Deltacloud::Drivers::RimuHosting::RimuHostingClient + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
+ +
+
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (RimuHostingClient) initialize(credentials, baseuri = 'https://rimuhosting.com/r') + + + +

+
+

+A new instance of RimuHostingClient +

+ + +
+
+
+ +
+ + + + +
+
+
+
+31
+32
+33
+34
+35
+36
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 31
+
+def initialize(credentials ,baseuri = 'https://rimuhosting.com/r')
+  @uri = URI.parse(baseuri)
+  @service = Net::HTTP.new(@uri.host, @uri.port)
+  @service.use_ssl = true
+  @auth = "rimuhosting apikey=#{credentials.password}"
+end
+
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) create_server(image_id, plan_code, name) + + + +

+ + + + +
+
+
+
+76
+77
+78
+79
+80
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 76
+
+def create_server(image_id, plan_code, name)
+  json = {:new_vps => {:instantiation_options => {:domain_name => name, :distro => image_id},
+                      :pricing_plan_code => plan_code}}.to_json
+  request('/orders/new-vps',json, 'POST')[:about_order]
+end
+
+
+
+ +
+

+ + - (Object) delete_server(id) + + + +

+ + + + +
+
+
+
+72
+73
+74
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 72
+
+def delete_server(id)
+  request("/orders/order-#{id}-a/vps",'', 'DELETE')
+end
+
+
+
+ +
+

+ + - (Object) list_images + + + +

+ + + + +
+
+
+
+55
+56
+57
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 55
+
+def list_images
+  request('/distributions')["distro_infos"]
+end
+
+
+
+ +
+

+ + - (Object) list_nodes + + + +

+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 63
+
+def list_nodes
+  request('/orders;include_inactive=N')["about_orders"]
+end
+
+
+
+ +
+

+ + - (Object) list_plans + + + +

+ + + + +
+
+
+
+59
+60
+61
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 59
+
+def list_plans
+  request('/pricing-plans;server-type=VPS')["pricing_plan_infos"]
+end
+
+
+
+ +
+

+ + - (Object) request(resource, data = '', method = 'GET') + + + +

+ + + + +
+
+
+
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 38
+
+def request(resource, data='', method='GET')
+  headers = {"Accept" => "application/json", "Content-Type" => "application/json"}
+  if(!@auth.nil?)
+    headers["Authorization"] = @auth
+  end
+  r = @service.send_request(method, @uri.path + resource, data, headers)
+       puts r.body
+  res = JSON.parse(r.body)
+  res = res[res.keys[0]]
+
+  if(res['response_type'] == "ERROR" and ( (res['error_info']['error_class'] == "PermissionException") or
+             (res['error_info']['error_class'] == "LoginRequired") )) 
+    raise Deltacloud::AuthException.new
+  end
+  res
+end
+
+
+
+ +
+

+ + - (Object) set_server_state(id, state) + + + +

+ + + + +
+
+
+
+67
+68
+69
+70
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb', line 67
+
+def set_server_state(id, state)
+  json = {"reboot_request" => {"running_state" => state}}.to_json
+  request("/orders/order-#{id}-a/vps/running-state", json, 'PUT')
+end
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file Added: incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingDriver.html URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingDriver.html?rev=1003045&view=auto ============================================================================== --- incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingDriver.html (added) +++ incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/RimuHosting/RimuHostingDriver.html Thu Sep 30 12:48:00 2010 @@ -0,0 +1,825 @@ + + + + +Class: Deltacloud::Drivers::RimuHosting::RimuHostingDriver + + + + + + + + + + + + + + + +

Class: Deltacloud::Drivers::RimuHosting::RimuHostingDriver + + + +

+ +
+ +
Inherits:
+
+ BaseDriver + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
+ +
+
+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + +

Methods inherited from BaseDriver

+

#blob, #blob_data, #blobs, #bucket, #buckets, #catched_exceptions_list, #create_bucket, declare_feature, define_hardware_profile, define_instance_states, #delete_bucket, feature, feature_decl_for, feature_decls, #features, features, #filter_hardware_profiles, #filter_on, #find_hardware_profile, #hardware_profile, hardware_profiles, #has_collection?, #image, #instance, #instance_actions_for, instance_state_machine, #instance_state_machine, #realm, #storage_snapshot, #storage_snapshots, #storage_volume, #storage_volumes, #supported_collections

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) convert_srv_to_instance(inst) + + + +

+ + + + +
+
+
+
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 124
+
+def convert_srv_to_instance( inst )
+  Instance.new({
+          :id => inst["order_oid"].to_s,
+          :name => inst["domain_name"],
+          :image_id => "lenny",
+          :state => "RUNNING",
+          :name => inst["domain_name"],
+          :realm_id => "RH",
+          :owner_id => "root",
+          :instance_profile => InstanceProfile.new("none"),
+          :actions => instance_actions_for("RUNNING"),
+          :public_addresses => inst["allocated_ips"]["primary_ip"],
+          :launch_time => inst["billing_info"]["order_date"]["iso_format"]
+  })
+end
+
+
+
+ +
+

+ + - (Object) create_instance(credentials, image_id, opts) + + + +

+ + + + +
+
+
+
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 111
+
+def create_instance(credentials, image_id, opts)
+   rh = RimuHostingClient.new(credentials)
+  # really need to raise an exception here.
+  hwp_id = opts[:hwp_id] || 1
+  # 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.create_server(image_id, hwp_id, name))
+
+end
+
+
+
+ +
+

+ + - (Object) destroy_instance(credentials, id) + + + +

+ + + + +
+
+
+
+104
+105
+106
+107
+108
+109
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 104
+
+def destroy_instance(credentials, id)
+  safely do
+    rh = RimuHostingClient.new(credentials)
+    return rh.delete_server(id)
+  end
+end
+
+
+
+ +
+

+ + - (Object) hardware_profiles(credentials, opts = nil) + + + +

+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 49
+
+def hardware_profiles(credentials, opts = nil)
+  safely do
+    rh = RimuHostingClient.new(credentials)
+    results = rh.list_plans.map do |plan|
+      # FIXME: x86 is not a valid architecture; what is Rimu offering ?
+      # FIXME: VPS plans offer a range of memory/storage, but that's
+      #        not contained in hte pricing_plan_infos
+      HardwareProfile.new(plan["pricing_plan_code"]) do
+        memory plan["minimum_memory_mb"].to_f
+        storage plan["minimum_disk_gb"].to_i
+        architecture "x86"
+      end
+    end
+  end
+  filter_hardware_profiles(results, opts)
+end
+
+
+
+ +
+

+ + - (Object) images(credentails, opts = nil) + + + +

+ + + + +
+
+
+
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 31
+
+def images(credentails, opts=nil)
+  safely do
+    rh = RimuHostingClient.new(credentails)
+    images = rh.list_images.map do | image |
+      Image.new({
+              :id => image["distro_code"].gsub(/\./,"-"),
+              :name => image["distro_code"],
+              :description => image["distro_description"],
+              :owner_id => "root",
+              :architecture => "x86"
+      })
+    end
+  end
+  images.sort_by{|e| [e.description]}
+  images = filter_on( images, :id, opts)
+  images
+end
+
+
+
+ +
+

+ + - (Object) instances(credentials, opts = nil) + + + +

+ + + + +
+
+
+
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 74
+
+def instances(credentials, opts=nil)
+  safely do
+    rh = RimuHostingClient.new(credentials)
+    instances = rh.list_nodes.map do | inst |
+      convert_srv_to_instance(inst)
+    end
+  end
+  instances = filter_on( instances, :id, opts)
+  instances = filter_on( instances, :state, opts )
+  instances
+end
+
+
+
+ +
+

+ + - (Object) realms(credentials, opts = nil) + + + +

+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+72
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 66
+
+def realms(credentials, opts=nil)
+  [Realm.new( {
+          :id=>"rimu",
+          :name=>"RimuHosting",
+          :state=> "AVAILABLE"
+  } )]
+end
+
+
+
+ +
+

+ + - (Object) reboot_instance(credentials, id) + + + +

+ + + + +
+
+
+
+86
+87
+88
+89
+90
+91
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 86
+
+def reboot_instance(credentials, id)
+  safely do
+    rh = RimuHostingClient.new(credentials)
+    rh.set_server_state(id, :RESTARTING)
+  end
+end
+
+
+
+ +
+

+ + - (Object) safely(&block) + + + +

+ + + + +
+
+
+
+153
+154
+155
+156
+157
+158
+159
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 153
+
+def safely(&block)
+  begin
+    block.call
+  rescue Exception => e
+    raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, e.backtrace)
+  end
+end
+
+
+
+ +
+

+ + - (Object) start_instance(credentials, id) + + + +

+ + + + +
+
+
+
+93
+94
+95
+96
+97
+98
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 93
+
+def start_instance(credentials, id)
+  safely do
+    rh = RimuHostingClient.new(credentials)
+    rh.set_server_state(id, :STARTED)
+  end
+end
+
+
+
+ +
+

+ + - (Object) stop_instance(credentials, id) + + + +

+ + + + +
+
+
+
+100
+101
+102
+
+
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 100
+
+def stop_instance(credentials, id)
+  destroy_instance(credentials, id)
+end
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file Added: incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/Terremark.html URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/Terremark.html?rev=1003045&view=auto ============================================================================== --- incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/Terremark.html (added) +++ incubator/deltacloud/trunk/site/api-docs/Deltacloud/Drivers/Terremark.html Thu Sep 30 12:48:00 2010 @@ -0,0 +1,91 @@ + + + + +Module: Deltacloud::Drivers::Terremark + + + + + + + + + + + + + + + +

Module: Deltacloud::Drivers::Terremark + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/deltacloud/drivers/terremark/terremark_driver.rb
+ +
+
+ +

Defined Under Namespace

+

+ + + + + Classes: TerremarkDriver + + +

+ + + + + +
+ + + + + \ No newline at end of file