mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|aws] Fix associate_address mock to detach/revert previous addresses properly.
This commit is contained in:
parent
927267d0c0
commit
84ae5b7293
2 changed files with 7 additions and 4 deletions
|
@ -38,11 +38,13 @@ module Fog
|
||||||
instance = self.data[:instances][instance_id]
|
instance = self.data[:instances][instance_id]
|
||||||
address = self.data[:addresses][public_ip]
|
address = self.data[:addresses][public_ip]
|
||||||
if instance && address
|
if instance && address
|
||||||
|
if current_instance = self.data[:instances][address['instanceId']]
|
||||||
|
current_instance['ipAddress'] = current_instance['originalIpAddress']
|
||||||
|
end
|
||||||
address['instanceId'] = instance_id
|
address['instanceId'] = instance_id
|
||||||
instance['originalIpAddress'] = instance['ipAddress']
|
|
||||||
# detach other address (if any)
|
# detach other address (if any)
|
||||||
if self.data[:addresses][instance['originalIpAddress']]
|
if self.data[:addresses][instance['ipAddress']]
|
||||||
self.data[:addresses][instance['originalIpAddress']]['instanceId'] = nil
|
self.data[:addresses][instance['ipAddress']]['instanceId'] = nil
|
||||||
end
|
end
|
||||||
instance['ipAddress'] = public_ip
|
instance['ipAddress'] = public_ip
|
||||||
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)
|
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)
|
||||||
|
|
|
@ -85,7 +85,7 @@ module Fog
|
||||||
|
|
||||||
instance_set = self.data[:instances].values
|
instance_set = self.data[:instances].values
|
||||||
instance_set = apply_tag_filters(instance_set, filters)
|
instance_set = apply_tag_filters(instance_set, filters)
|
||||||
|
|
||||||
aliases = {
|
aliases = {
|
||||||
'architecture' => 'architecture',
|
'architecture' => 'architecture',
|
||||||
'availability-zone' => 'availabilityZone',
|
'availability-zone' => 'availabilityZone',
|
||||||
|
@ -158,6 +158,7 @@ module Fog
|
||||||
when 'pending'
|
when 'pending'
|
||||||
if Time.now - instance['launchTime'] >= Fog::Mock.delay
|
if Time.now - instance['launchTime'] >= Fog::Mock.delay
|
||||||
instance['ipAddress'] = Fog::AWS::Mock.ip_address
|
instance['ipAddress'] = Fog::AWS::Mock.ip_address
|
||||||
|
instance['originalIpAddress'] = instance['ipAddress']
|
||||||
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
|
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
|
||||||
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
||||||
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
|
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue