mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fixes for AWS Mocking
lib/fog/aws.rb Previously chose 4xRandom numbers between 0 and 999, now uses the Mock random_ip which returns numbers that will be within acceptable number range. Old method was returning invalid numbers that then failed to pass range checks. lib/fog/aws/requests/compute/associate_address.rb Re-fetch address if we have to look up public-ip using allocation-id, otherwise it remains nil and the ip-address/instance aren't updated correctly. lib/fog/aws/requests/compute/describe_addresses.rb The allocate-address request uses allocation-id to look up ip address if allocation-id is given instead of public-ip, so added that as searchable in mock data.
This commit is contained in:
parent
d3c513ed3e
commit
5e170965d2
3 changed files with 3 additions and 6 deletions
|
@ -192,11 +192,7 @@ module Fog
|
|||
end
|
||||
|
||||
def self.ip_address
|
||||
ip = []
|
||||
4.times do
|
||||
ip << Fog::Mock.random_numbers(rand(3) + 1).to_i.to_s # remove leading 0
|
||||
end
|
||||
ip.join('.')
|
||||
Fog::Mock.random_ip
|
||||
end
|
||||
|
||||
def self.private_ip_address
|
||||
|
|
|
@ -51,6 +51,7 @@ module Fog
|
|||
allocation_ip = describe_addresses( 'allocation-id' => "#{allocation_id}").body['addressesSet'].first
|
||||
if !allocation_ip.nil?
|
||||
public_ip = allocation_ip['publicIp']
|
||||
address = public_ip.nil? ? nil : self.data[:addresses][public_ip]
|
||||
end
|
||||
end
|
||||
if !address.nil?
|
||||
|
|
|
@ -46,7 +46,7 @@ module Fog
|
|||
|
||||
addresses_set = self.data[:addresses].values
|
||||
|
||||
aliases = {'public-ip' => 'publicIp', 'instance-id' => 'instanceId'}
|
||||
aliases = {'public-ip' => 'publicIp', 'instance-id' => 'instanceId', 'allocation-id' => 'allocationId'}
|
||||
for filter_key, filter_value in filters
|
||||
aliased_key = aliases[filter_key]
|
||||
addresses_set = addresses_set.reject{|address| ![*filter_value].include?(address[aliased_key])}
|
||||
|
|
Loading…
Reference in a new issue