1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws] mock errors on too many addresses

This commit is contained in:
geemus (Wesley Beary) 2010-04-09 10:59:56 -07:00
parent 1dae004587
commit a2a1a6ab6c
2 changed files with 19 additions and 12 deletions

View file

@ -77,6 +77,7 @@ module Fog
:addresses => {},
:instances => {},
:key_pairs => {},
:limits => { :addresses => 5 },
:security_groups => {
'default' => {
'groupDescription' => 'default group',

View file

@ -25,18 +25,24 @@ module Fog
def allocate_address
response = Excon::Response.new
response.status = 200
public_ip = Fog::AWS::Mock.ip_address
data ={
'instanceId' => '',
'publicIp' => public_ip
}
@data[:addresses][public_ip] = data
response.body = {
'publicIp' => public_ip,
'requestId' => Fog::AWS::Mock.request_id
}
response
if describe_addresses.body['addressesSet'].size < @data[:limits][:addresses]
response.status = 200
public_ip = Fog::AWS::Mock.ip_address
data ={
'instanceId' => '',
'publicIp' => public_ip
}
@data[:addresses][public_ip] = data
response.body = {
'publicIp' => public_ip,
'requestId' => Fog::AWS::Mock.request_id
}
response
else
response.status = 400
response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>AddressLimitExceeded</Code><Message>Too many addresses allocated</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestID></Response>"
raise(Excon::Errors.status_error({:expects => 200}, response))
end
end
end