mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws] fix ip/dns behaviour for booting instances, and cleanup terminate instances
This commit is contained in:
parent
d9a81b5e16
commit
8c4c28b1c5
3 changed files with 22 additions and 19 deletions
|
@ -75,8 +75,10 @@ module Fog
|
|||
case instance['instanceState']['name']
|
||||
when 'pending'
|
||||
if Time.now - instance['launchTime'] > Fog::Mock::DELAY
|
||||
instance['dnsName'] = Fog::AWS::Mock.ip_address
|
||||
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
||||
instance['dnsName'] = "ec2-#{Fog::AWS::Mock.ip_address.gsub('.','-')}.compute-1.amazonaws.com"
|
||||
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
||||
instance['privateDnsName'] = "ip-#{instance['privateDnsName'].gsub('.','-')}.ec2.internal"
|
||||
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
||||
end
|
||||
when 'rebooting'
|
||||
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
||||
|
|
|
@ -122,6 +122,7 @@ module Fog
|
|||
'ownerId' => @owner_id,
|
||||
'placement' => { 'availabilityZone' => options['Placement.AvailabilityZone'] || Fog::AWS::Mock.availability_zone },
|
||||
'privateDnsName' => '',
|
||||
'privateIpAddress' => '',
|
||||
'productCodes' => [],
|
||||
'ramdiskId' => options['RamdiskId'] || Fog::AWS::Mock.ramdisk_id,
|
||||
'reason' => '',
|
||||
|
|
|
@ -38,14 +38,14 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
instance_id = [*instance_id]
|
||||
if (@data[:instances].keys & instance_id).length == instance_id.length
|
||||
for instance_id in instance_id
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'instancesSet' => []
|
||||
}
|
||||
instance = @data[:instances][instance_id]
|
||||
@data[:deleted_at][instance_id] = Time.now
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'instancesSet' => []
|
||||
}
|
||||
response.status = 200
|
||||
for id in instance_id
|
||||
instance = @data[:instances][id]
|
||||
@data[:deleted_at][id] = Time.now
|
||||
# TODO: the codes are mostly educated guessing, not certainty
|
||||
code = case instance['state']
|
||||
when 'pending'
|
||||
|
@ -61,22 +61,22 @@ module Fog
|
|||
end
|
||||
state = { 'name' => 'shutting-down', 'code' => 32}
|
||||
response.body['instancesSet'] << {
|
||||
'instanceId' => instance_id,
|
||||
'instanceId' => id,
|
||||
'previousState' => instance['instanceState'],
|
||||
'currentState' => state
|
||||
}
|
||||
instance['instanceState'] = state
|
||||
end
|
||||
|
||||
describe_addresses.body['addressesSet'].each do |address|
|
||||
if address['instanceId'] == instance_id
|
||||
disassociate_address(address['publicIp'])
|
||||
end
|
||||
describe_addresses.body['addressesSet'].each do |address|
|
||||
if instance_id.include?(address['instanceId'])
|
||||
disassociate_address(address['publicIp'])
|
||||
end
|
||||
end
|
||||
|
||||
describe_volumes.body['volumeSet'].each do |volume|
|
||||
if volume['attachmentSet'].first && volume['attachmentSet'].first['instanceId'] == instance_id
|
||||
detach_volume(volume['volumeId'])
|
||||
end
|
||||
describe_volumes.body['volumeSet'].each do |volume|
|
||||
if volume['attachmentSet'].first && instance_id.include?(volume['attachmentSet'].first['instanceId'])
|
||||
detach_volume(volume['volumeId'])
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue