2010-03-16 18:46:21 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
module EC2
|
|
|
|
class Real
|
2009-08-14 14:28:57 -04:00
|
|
|
|
|
|
|
# Describe all or specified IP addresses.
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * public_ip<~Array> - List of ips to describe, defaults to all
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-14 14:28:57 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'addressesSet'<~Array>:
|
|
|
|
# * 'instanceId'<~String> - instance for ip address
|
|
|
|
# * 'publicIp'<~String> - ip address for instance
|
|
|
|
def describe_addresses(public_ip = [])
|
2010-01-31 17:07:26 -05:00
|
|
|
params = AWS.indexed_param('PublicIp', public_ip)
|
2009-08-14 14:28:57 -04:00
|
|
|
request({
|
2010-05-24 17:22:35 -04:00
|
|
|
'Action' => 'DescribeAddresses',
|
|
|
|
:idempotent => true,
|
|
|
|
:parser => Fog::Parsers::AWS::EC2::DescribeAddresses.new
|
2010-03-16 01:15:33 -04:00
|
|
|
}.merge!(params))
|
2009-08-14 14:28:57 -04:00
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
|
2010-03-16 18:46:21 -04:00
|
|
|
class Mock
|
2009-08-14 14:28:57 -04:00
|
|
|
|
|
|
|
def describe_addresses(public_ip = [])
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-08-20 22:25:52 -04:00
|
|
|
public_ip = [*public_ip]
|
2009-08-14 14:28:57 -04:00
|
|
|
if public_ip != []
|
2010-03-16 18:46:21 -04:00
|
|
|
addresses_set = @data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
|
2009-08-14 14:28:57 -04:00
|
|
|
else
|
2010-03-16 18:46:21 -04:00
|
|
|
addresses_set = @data[:addresses].values
|
2009-08-14 14:28:57 -04:00
|
|
|
end
|
|
|
|
if public_ip.length == 0 || public_ip.length == addresses_set.length
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'addressesSet' => addresses_set
|
|
|
|
}
|
2010-05-26 01:26:20 -04:00
|
|
|
response
|
2009-08-14 14:28:57 -04:00
|
|
|
else
|
2010-05-26 01:26:20 -04:00
|
|
|
raise Fog::AWS::EC2::Error.new("InvalidAddress.NotFound => Address #{public_ip.inspect} not found.")
|
2009-08-14 14:28:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|