2010-03-16 18:46:21 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
module EC2
|
|
|
|
class Real
|
2009-08-27 00:31:53 -04:00
|
|
|
|
|
|
|
# Describe all or specified regions
|
|
|
|
#
|
|
|
|
# ==== Params
|
|
|
|
# * region_name<~String> - List of regions to describe, defaults to all
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-27 00:31:53 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'regionInfo'<~Array>:
|
|
|
|
# * 'regionName'<~String> - Name of region
|
|
|
|
# * 'regionEndpoint'<~String> - Service endpoint for region
|
|
|
|
def describe_regions(region_name = [])
|
2010-01-31 17:07:26 -05:00
|
|
|
params = AWS.indexed_param('RegionName', region_name)
|
2009-08-27 00:31:53 -04:00
|
|
|
request({
|
2010-05-24 17:22:35 -04:00
|
|
|
'Action' => 'DescribeRegions',
|
|
|
|
:idempotent => true,
|
|
|
|
:parser => Fog::Parsers::AWS::EC2::DescribeRegions.new
|
2010-03-16 01:15:33 -04:00
|
|
|
}.merge!(params))
|
2009-08-27 00:31:53 -04:00
|
|
|
end
|
|
|
|
|
2009-07-24 01:52:17 -04:00
|
|
|
end
|
2009-08-27 00:31:53 -04:00
|
|
|
|
2010-03-16 18:46:21 -04:00
|
|
|
class Mock
|
2009-08-27 00:31:53 -04:00
|
|
|
|
|
|
|
def describe_regions(region_name = [])
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-08-27 00:31:53 -04:00
|
|
|
region_name = [*region_name]
|
|
|
|
regions = {
|
|
|
|
'eu-west-1' => {"regionName"=>"eu-west-1", "regionEndpoint"=>"eu-west-1.ec2.amazonaws.com"},
|
|
|
|
'us-east-1' => {"regionName"=>"us-east-1", "regionEndpoint"=>"us-east-1.ec2.amazonaws.com"}
|
|
|
|
}
|
|
|
|
if region_name != []
|
|
|
|
region_info = regions.reject {|key, value| !region_name.include?(key)}.values
|
|
|
|
else
|
|
|
|
region_info = regions.values
|
|
|
|
end
|
|
|
|
|
2010-05-24 20:41:01 -04:00
|
|
|
if region_name.length == 0 || region_name.length == region_info.length
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'regionInfo' => region_info
|
|
|
|
}
|
2010-05-26 01:26:20 -04:00
|
|
|
response
|
2010-05-24 20:41:01 -04:00
|
|
|
else
|
2010-05-26 01:26:20 -04:00
|
|
|
raise Fog::AWS::EC2::Error.new("InvalidParameterValue => Invalid region: #{region_name.inspect}")
|
2010-05-24 20:41:01 -04:00
|
|
|
end
|
2009-08-27 00:31:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-24 01:52:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|