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

[ec2] volume related mock fixes

This commit is contained in:
geemus (Wesley Beary) 2010-04-01 10:51:35 -07:00
parent 323cacb217
commit a432352a29
3 changed files with 20 additions and 2 deletions

View file

@ -49,12 +49,16 @@ module Fog
volume_set.each do |volume|
case volume['status']
when 'attaching'
if Time.now - volume['attachmentSet'].first['attachTime'] > 1
volume['status'] = 'attached'
end
when 'creating'
if Time.now - volume['createTime'] > 2
if Time.now - volume['createTime'] > 1
volume['status'] = 'available'
end
when 'deleting'
if Time.now - @data[:deleted_at][volume['volumeId']] > 2
if Time.now - @data[:deleted_at][volume['volumeId']] > 1
@data[:deleted_at].delete(volume['volumeId'])
@data[:volumes].delete(volume['volumeId'])
end

View file

@ -40,6 +40,7 @@ module Fog
response.status = 200
if volume = @data[:volumes][volume_id]
data = volume['attachmentSet'].pop
@data[:volumes][volume_id]['status'] = 'available'
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id

View file

@ -66,6 +66,19 @@ module Fog
'currentState' => state
}
instance['instanceState'] = state
describe_addresses.body['addressesSet'].each do |address|
if address['instanceId'] == instance_id
disassociate_address(address['publicIp'])
end
end
describe_volumes.body['volumeSet'].each do |volume|
if volume['instanceId'] == instance_id
detach_volume(volume['volumeId'])
end
end
end
else
response.status = 400