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:
parent
323cacb217
commit
a432352a29
3 changed files with 20 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue