2010-09-08 13:56:38 -04:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Linode
|
2010-09-08 13:56:38 -04:00
|
|
|
class Real
|
2011-05-24 18:02:59 -04:00
|
|
|
|
|
|
|
# Get available distributions
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * distributionId<~Integer>: id to limit results to
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Array>:
|
2012-05-17 14:31:15 -04:00
|
|
|
# TODO: docs
|
2010-09-08 13:56:38 -04:00
|
|
|
def avail_distributions(distribution_id=nil)
|
|
|
|
options = {}
|
|
|
|
if distribution_id
|
|
|
|
options.merge!(:distributionId => distribution_id)
|
|
|
|
end
|
|
|
|
request(
|
|
|
|
:expects => 200,
|
|
|
|
:method => 'GET',
|
|
|
|
:query => { :api_action => 'avail.distributions' }.merge!(options)
|
|
|
|
)
|
|
|
|
end
|
2011-06-16 19:28:54 -04:00
|
|
|
|
2010-09-08 13:56:38 -04:00
|
|
|
end
|
2012-05-17 14:31:15 -04:00
|
|
|
|
|
|
|
class Mock
|
|
|
|
def avail_distributions(distribution_id=nil)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
|
|
|
|
body = {
|
|
|
|
"ERRORARRAY" => [],
|
|
|
|
"ACTION" => "avail.distributions"
|
|
|
|
}
|
|
|
|
if distribution_id
|
|
|
|
mock_distribution = create_mock_distribution(distribution_id)
|
|
|
|
response.body = body.merge("DATA" => [mock_distribution])
|
|
|
|
else
|
|
|
|
mock_distributions = []
|
|
|
|
10.times do
|
|
|
|
distribution_id = rand(1..99)
|
|
|
|
mock_distributions << create_mock_distribution(distribution_id)
|
|
|
|
end
|
|
|
|
response.body = body.merge("DATA" => mock_distributions)
|
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_mock_distribution(distribution_id)
|
|
|
|
{
|
|
|
|
"CREATE_DT" => "2012-04-26 17:25:16.0",
|
|
|
|
"DISTRIBUTIONID" => distribution_id,
|
|
|
|
"IS64BIT" => 0,
|
|
|
|
"LABEL" => "Ubuntu 12.04 LTS",
|
|
|
|
"MINIMAGESIZE" => 600,
|
|
|
|
"REQUIRESPVOPSKERNEL" => 1
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2010-09-08 13:56:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|