2009-08-14 14:28:57 -04:00
|
|
|
unless Fog.mocking?
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
# Describe all or specified IP addresses.
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * public_ip<~Array> - List of ips to describe, defaults to all
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Fog::AWS::Response>:
|
|
|
|
# * 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 = [])
|
|
|
|
params = indexed_params('PublicIp', public_ip)
|
|
|
|
request({
|
|
|
|
'Action' => 'DescribeAddresses'
|
|
|
|
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
2009-08-14 14:28:57 -04:00
|
|
|
end
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
|
2009-08-14 14:28:57 -04:00
|
|
|
else
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
def describe_addresses(public_ip = [])
|
|
|
|
response = Fog::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 != []
|
2009-08-20 22:25:52 -04:00
|
|
|
addresses_set = Fog::AWS::EC2.data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
|
2009-08-14 14:28:57 -04:00
|
|
|
else
|
2009-08-20 22:25:52 -04:00
|
|
|
addresses_set = Fog::AWS::EC2.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
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response.status = 400
|
2009-08-17 01:19:35 -04:00
|
|
|
raise(Fog::Errors.status_error(200, 400, response))
|
2009-08-14 14:28:57 -04:00
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
2009-08-14 14:28:57 -04:00
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|