Class: Fog::Compute::Linode::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Linode::Real
- Defined in:
- lib/fog/linode/compute.rb,
lib/fog/linode/requests/compute/image_list.rb,
lib/fog/linode/requests/compute/linode_boot.rb,
lib/fog/linode/requests/compute/linode_list.rb,
lib/fog/linode/requests/compute/image_delete.rb,
lib/fog/linode/requests/compute/avail_kernels.rb,
lib/fog/linode/requests/compute/linode_create.rb,
lib/fog/linode/requests/compute/linode_delete.rb,
lib/fog/linode/requests/compute/linode_reboot.rb,
lib/fog/linode/requests/compute/linode_update.rb,
lib/fog/linode/requests/compute/linode_ip_list.rb,
lib/fog/linode/requests/compute/linode_shutdown.rb,
lib/fog/linode/requests/compute/linode_disk_list.rb,
lib/fog/linode/requests/compute/stackscript_list.rb,
lib/fog/linode/requests/compute/avail_datacenters.rb,
lib/fog/linode/requests/compute/avail_linodeplans.rb,
lib/fog/linode/requests/compute/avail_stackscripts.rb,
lib/fog/linode/requests/compute/linode_config_list.rb,
lib/fog/linode/requests/compute/linode_disk_create.rb,
lib/fog/linode/requests/compute/linode_disk_delete.rb,
lib/fog/linode/requests/compute/linode_disk_resize.rb,
lib/fog/linode/requests/compute/linode_disk_update.rb,
lib/fog/linode/requests/compute/avail_distributions.rb,
lib/fog/linode/requests/compute/avail_nodebalancers.rb,
lib/fog/linode/requests/compute/linode_disk_imagize.rb,
lib/fog/linode/requests/compute/linode_config_create.rb,
lib/fog/linode/requests/compute/linode_config_delete.rb,
lib/fog/linode/requests/compute/linode_config_update.rb,
lib/fog/linode/requests/compute/linode_ip_addprivate.rb,
lib/fog/linode/requests/compute/linode_disk_duplicate.rb,
lib/fog/linode/requests/compute/linode_disk_createfromimage.rb,
lib/fog/linode/requests/compute/linode_disk_createfromstackscript.rb,
lib/fog/linode/requests/compute/linode_disk_createfromdistribution.rb
Instance Method Summary collapse
-
#avail_datacenters ⇒ Object
Get available data centers.
-
#avail_distributions(distribution_id = nil) ⇒ Object
Get available distributions.
-
#avail_kernels(options = {}) ⇒ Object
Get available kernels.
-
#avail_linodeplans(linodeplan_id = nil) ⇒ Object
Get available plans.
-
#avail_nodebalancers ⇒ Object
Get NodeBalancer pricing information.
- #avail_stackscripts(options = {}) ⇒ Object
- #image_delete(image_id) ⇒ Object
- #image_list(pending = nil, image_id = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #linode_boot(linode_id, config_id) ⇒ Object
- #linode_config_create(linode_id, kernel_id, name, disk_list) ⇒ Object
- #linode_config_delete(linode_id, config_id) ⇒ Object
- #linode_config_list(linode_id, config_id = nil, options = {}) ⇒ Object
-
#linode_config_update(linode_id, config_id, options = {}) ⇒ Object
api docs say LinodeID is optional, turns out its required.
-
#linode_create(datacenter_id, plan_id, payment_term) ⇒ Object
Creates a linode and assigns you full privileges.
-
#linode_delete(linode_id, options = {}) ⇒ Object
List all linodes user has access or delete to.
- #linode_disk_create(linode_id, name, type, size) ⇒ Object
- #linode_disk_createfromdistribution(linode_id, distro_id, name, size, password) ⇒ Object
- #linode_disk_createfromimage(linode_id, image_id, label, size, password, sshkey) ⇒ Object
- #linode_disk_createfromstackscript(linode_id, script_id, distro_id, name, size, password, options = {}) ⇒ Object
- #linode_disk_delete(linode_id, disk_id) ⇒ Object
- #linode_disk_duplicate(linode_id, disk_id) ⇒ Object
- #linode_disk_imagize(linode_id, disk_id, description, label) ⇒ Object
- #linode_disk_list(linode_id, disk_id = nil) ⇒ Object
- #linode_disk_resize(linode_id, disk_id, size) ⇒ Object
- #linode_disk_update(linode_id, disk_id, label, isreadonly) ⇒ Object
- #linode_ip_addprivate(linode_id) ⇒ Object
- #linode_ip_list(linode_id, ip_id = nil) ⇒ Object
-
#linode_list(linode_id = nil) ⇒ Object
List all linodes user has access or delete to.
-
#linode_reboot(linode_id, options = {}) ⇒ Object
Issues a shutdown, and then a boot job for a given linode.
- #linode_shutdown(linode_id) ⇒ Object
- #linode_update(linode_id, options = {}) ⇒ Object
- #reload ⇒ Object
- #request(params) ⇒ Object
-
#stackscript_list(script_id = nil) ⇒ Object
Get available stack scripts.
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
89 90 91 92 93 94 95 |
# File 'lib/fog/linode/compute.rb', line 89 def initialize(={}) @linode_api_key = [:linode_api_key] @host = [:host] || "api.linode.com" @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", [:persistent]) end |
Instance Method Details
#avail_datacenters ⇒ Object
Get available data centers
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/compute/avail_datacenters.rb', line 11 def avail_datacenters request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.datacenters' } ) end |
#avail_distributions(distribution_id = nil) ⇒ Object
Get available distributions
Parameters
-
distributionId<~Integer>: id to limit results to
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/linode/requests/compute/avail_distributions.rb', line 14 def avail_distributions(distribution_id=nil) = {} if distribution_id .merge!(:distributionId => distribution_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.distributions' }.merge!() ) end |
#avail_kernels(options = {}) ⇒ Object
Get available kernels
Parameters
-
options<~Hash>
-
isXen<~Boolean> Show or hide Xen compatible kernels
-
isKVM<~Boolean> Show or hide KVM compatible kernels
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/linode/requests/compute/avail_kernels.rb', line 16 def avail_kernels(={}) # avail.kernels used to accept a kernelId parameter (now removed) raise Fog::Errors::Error.new('avail_kernels no longer accepts a kernelId parameter') unless ! || .is_a?(Hash) request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.kernels' }.merge!( || {}) ) end |
#avail_linodeplans(linodeplan_id = nil) ⇒ Object
Get available plans
Parameters
-
linodeplanId<~Integer>: id to limit results to
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/linode/requests/compute/avail_linodeplans.rb', line 14 def avail_linodeplans(linodeplan_id = nil) = {} if linodeplan_id .merge!(:planId => linodeplan_id) end result = request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.linodeplans' }.merge!() ) result end |
#avail_nodebalancers ⇒ Object
Get NodeBalancer pricing information.
Parameters
Returns
-
response<~Excon::Response>:
-
body<~Array>:
* 'MONTHLY'<~Float> - Monthly price * 'HOURLY'<~Float>: - Hourly price * 'CONNECTIONS'<~Integer>: - Maximum concurrent connections
-
15 16 17 18 19 20 21 |
# File 'lib/fog/linode/requests/compute/avail_nodebalancers.rb', line 15 def avail_nodebalancers request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.nodebalancers' } ) end |
#avail_stackscripts(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/linode/requests/compute/avail_stackscripts.rb', line 5 def avail_stackscripts(={}) result = request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.stackscripts' }.merge!() ) result.body['DATA'].each { |r| r['DISTRIBUTIONIDLIST'] = r['DISTRIBUTIONIDLIST'].to_s } result end |
#image_delete(image_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/linode/requests/compute/image_delete.rb', line 5 def image_delete(image_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'image.delete', :imageId => image_id } ) end |
#image_list(pending = nil, image_id = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/linode/requests/compute/image_list.rb', line 5 def image_list(pending=nil, image_id=nil) = {} if pending .merge!(:pending => pending) end if image_id .merge!(:imageId => image_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'image.list' }.merge!() ) end |
#linode_boot(linode_id, config_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/linode/requests/compute/linode_boot.rb', line 5 def linode_boot(linode_id, config_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.boot', :linodeId => linode_id, :configId => config_id } ) end |
#linode_config_create(linode_id, kernel_id, name, disk_list) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/compute/linode_config_create.rb', line 5 def linode_config_create(linode_id, kernel_id, name, disk_list) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.config.create', :linodeId => linode_id, :kernelId => kernel_id, :label => name, :diskList => disk_list } ) end |
#linode_config_delete(linode_id, config_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/linode/requests/compute/linode_config_delete.rb', line 5 def linode_config_delete(linode_id, config_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.config.delete', :linodeId => linode_id, :configId => config_id } ) end |
#linode_config_list(linode_id, config_id = nil, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/linode/requests/compute/linode_config_list.rb', line 5 def linode_config_list(linode_id, config_id=nil, ={}) if config_id .merge!(:configid => config_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.config.list', :linodeId => linode_id }.merge!() ) end |
#linode_config_update(linode_id, config_id, options = {}) ⇒ Object
api docs say LinodeID is optional, turns out its required
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/linode/requests/compute/linode_config_update.rb', line 6 def linode_config_update(linode_id, config_id, ={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.config.update', :configId => config_id, :linodeID => linode_id }.merge!() ) end |
#linode_create(datacenter_id, plan_id, payment_term) ⇒ Object
Creates a linode and assigns you full privileges
Parameters
-
datacenter_id<~Integer>: id of datacenter to place new linode in
-
plan_id<~Integer>: id of plan to boot new linode with
-
payment_term<~Integer>: Subscription term in months, in [1, 12, 24]
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/linode/requests/compute/linode_create.rb', line 16 def linode_create(datacenter_id, plan_id, payment_term) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.create', :datacenterId => datacenter_id, :paymentTerm => payment_term, :planId => plan_id } ) end |
#linode_delete(linode_id, options = {}) ⇒ Object
List all linodes user has access or delete to
Parameters
-
linode_id<~Integer>: id of linode to delete
-
options<~Hash>:
-
skipChecks<~Boolean>: skips safety checks and always deletes
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 |
# File 'lib/fog/linode/requests/compute/linode_delete.rb', line 16 def linode_delete(linode_id, ={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.delete', :linodeId => linode_id }.merge!() ) end |
#linode_disk_create(linode_id, name, type, size) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/compute/linode_disk_create.rb', line 5 def linode_disk_create(linode_id, name, type, size) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.create', :linodeId => linode_id, :label => name, :type => type, :size => size } ) end |
#linode_disk_createfromdistribution(linode_id, distro_id, name, size, password) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/linode/requests/compute/linode_disk_createfromdistribution.rb', line 5 def linode_disk_createfromdistribution(linode_id, distro_id, name, size, password) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.createfromdistribution', :linodeId => linode_id, :distributionId => distro_id, :label => name, :size => size, :rootPass => password } ) end |
#linode_disk_createfromimage(linode_id, image_id, label, size, password, sshkey) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/linode/requests/compute/linode_disk_createfromimage.rb', line 5 def linode_disk_createfromimage(linode_id, image_id, label, size, password, sshkey) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.createfromimage', :linodeId => linode_id, :imageId => image_id, :label => label, :size => size, :rootPass => password, :rootSSHKey => sshkey } ) end |
#linode_disk_createfromstackscript(linode_id, script_id, distro_id, name, size, password, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/linode/requests/compute/linode_disk_createfromstackscript.rb', line 5 def linode_disk_createfromstackscript(linode_id, script_id, distro_id, name, size, password, ={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.createfromstackscript', :linodeId => linode_id, :stackScriptID => script_id, :distributionId => distro_id, :label => name, :size => size, :rootPass => password, :stackScriptUDFResponses => Fog::JSON.encode() } ) end |
#linode_disk_delete(linode_id, disk_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/linode/requests/compute/linode_disk_delete.rb', line 5 def linode_disk_delete(linode_id, disk_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.delete', :linodeId => linode_id, :diskId => disk_id } ) end |
#linode_disk_duplicate(linode_id, disk_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/linode/requests/compute/linode_disk_duplicate.rb', line 5 def linode_disk_duplicate(linode_id, disk_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.duplicate', :linodeId => linode_id, :diskID => disk_id, } ) end |
#linode_disk_imagize(linode_id, disk_id, description, label) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/compute/linode_disk_imagize.rb', line 5 def linode_disk_imagize(linode_id, disk_id, description, label) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.imagize', :linodeId => linode_id, :diskId => disk_id, :description => description, :label => label } ) end |
#linode_disk_list(linode_id, disk_id = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/linode/requests/compute/linode_disk_list.rb', line 5 def linode_disk_list(linode_id, disk_id=nil) = {} if disk_id .merge!(:diskId => disk_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.list', :linodeId => linode_id }.merge!() ) end |
#linode_disk_resize(linode_id, disk_id, size) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/linode/requests/compute/linode_disk_resize.rb', line 5 def linode_disk_resize(linode_id, disk_id, size) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.resize', :linodeId => linode_id, :diskId => disk_id, :size => size } ) end |
#linode_disk_update(linode_id, disk_id, label, isreadonly) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/compute/linode_disk_update.rb', line 5 def linode_disk_update(linode_id, disk_id, label, isreadonly) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.disk.update', :linodeId => linode_id, :diskId => disk_id, :label => label, :isReadOnly => isreadonly } ) end |
#linode_ip_addprivate(linode_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/linode/requests/compute/linode_ip_addprivate.rb', line 5 def linode_ip_addprivate(linode_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.ip.addprivate', :linodeId => linode_id } ) end |
#linode_ip_list(linode_id, ip_id = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/linode/requests/compute/linode_ip_list.rb', line 5 def linode_ip_list(linode_id, ip_id=nil) = {} if ip_id .merge!(:ipaddressId => ip_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.ip.list', :linodeId => linode_id }.merge!() ) end |
#linode_list(linode_id = nil) ⇒ Object
List all linodes user has access or delete to
Parameters
-
linodeId<~Integer>: Limit the list to the specified LinodeID
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/linode/requests/compute/linode_list.rb', line 14 def linode_list(linode_id=nil) = {} if linode_id .merge!(:linodeId => linode_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.list' }.merge!() ) end |
#linode_reboot(linode_id, options = {}) ⇒ Object
Issues a shutdown, and then a boot job for a given linode
Parameters
-
linode_id<~Integer>: id of linode to reboot
-
options<~Hash>:
-
configId<~Boolean>: id of config to boot server with
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 |
# File 'lib/fog/linode/requests/compute/linode_reboot.rb', line 16 def linode_reboot(linode_id, ={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.reboot', :linodeId => linode_id }.merge!() ) end |
#linode_shutdown(linode_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/linode/requests/compute/linode_shutdown.rb', line 5 def linode_shutdown(linode_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.shutdown', :linodeId => linode_id } ) end |
#linode_update(linode_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/linode/requests/compute/linode_update.rb', line 5 def linode_update(linode_id, ={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'linode.update', :linodeId => linode_id }.merge!() ) end |
#reload ⇒ Object
97 98 99 |
# File 'lib/fog/linode/compute.rb', line 97 def reload @connection.reset end |
#request(params) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/fog/linode/compute.rb', line 101 def request(params) params[:query] ||= {} params[:query].merge!(:api_key => @linode_api_key) response = @connection.request(params) unless response.body.empty? response.body = Fog::JSON.decode(response.body) if data = response.body['ERRORARRAY'].first error = case data['ERRORCODE'] when 5 Fog::Compute::Linode::NotFound else Fog::Compute::Linode::Error end raise error.new(data['ERRORMESSAGE']) end end response end |
#stackscript_list(script_id = nil) ⇒ Object
Get available stack scripts
Parameters
-
scriptId<~Integer>: id to limit results to
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/linode/requests/compute/stackscript_list.rb', line 14 def stackscript_list(script_id=nil) = {} if script_id .merge!(:stackScriptID => script_id) end result = request( :expects => 200, :method => 'GET', :query => { :api_action => 'stackscript.list' }.merge!() ) result.body['DATA'].each { |r| r['DISTRIBUTIONIDLIST'] = r['DISTRIBUTIONIDLIST'].to_s } result end |