From 01d156c16bd4f1a75dcb5a5c5049d12341e2f845 Mon Sep 17 00:00:00 2001 From: David Faber Date: Tue, 29 Oct 2013 17:55:43 -0700 Subject: [PATCH] Add support to #create_tags mock for internet gateways --- lib/fog/aws/compute.rb | 1 - lib/fog/aws/requests/compute/create_internet_gateway.rb | 9 +++++---- lib/fog/aws/requests/compute/create_tags.rb | 2 ++ lib/fog/aws/requests/compute/delete_internet_gateway.rb | 2 +- .../aws/requests/compute/describe_internet_gateways.rb | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/fog/aws/compute.rb b/lib/fog/aws/compute.rb index c503fb636..124202293 100644 --- a/lib/fog/aws/compute.rb +++ b/lib/fog/aws/compute.rb @@ -223,7 +223,6 @@ module Fog :subnets => [], :vpcs => [], :dhcp_options => [], - :internet_gateways => [], :route_tables => [], :account_attributes => [ { diff --git a/lib/fog/aws/requests/compute/create_internet_gateway.rb b/lib/fog/aws/requests/compute/create_internet_gateway.rb index 34263e939..503d8bd11 100644 --- a/lib/fog/aws/requests/compute/create_internet_gateway.rb +++ b/lib/fog/aws/requests/compute/create_internet_gateway.rb @@ -33,16 +33,17 @@ module Fog class Mock def create_internet_gateway() - self.data[:internet_gateways].push({ - 'internetGatewayId' => Fog::AWS::Mock.request_id, + gateway_id = Fog::AWS::Mock.internet_gateway_id + self.data[:internet_gateways][gateway_id] = { + 'internetGatewayId' => gateway_id, 'attachmentSet' => {}, 'tagSet' => {} - }) + } Excon::Response.new( :status => 200, :body => { 'requestId' => Fog::AWS::Mock.request_id, - 'internetGatewaySet' => self.data[:internet_gateways] + 'internetGatewaySet' => [self.data[:internet_gateways][gateway_id]] } ) end diff --git a/lib/fog/aws/requests/compute/create_tags.rb b/lib/fog/aws/requests/compute/create_tags.rb index 354036057..35c8173d6 100644 --- a/lib/fog/aws/requests/compute/create_tags.rb +++ b/lib/fog/aws/requests/compute/create_tags.rb @@ -53,6 +53,8 @@ module Fog 'snapshot' when /^vol\-[a-z0-9]{8}$/i 'volume' + when /^igw\-[a-z0-9]{8}$/i + 'internet_gateway' end if type && ((type == 'image' && visible_images[resource_id]) || self.data[:"#{type}s"][resource_id]) { 'resourceId' => resource_id, 'resourceType' => type } diff --git a/lib/fog/aws/requests/compute/delete_internet_gateway.rb b/lib/fog/aws/requests/compute/delete_internet_gateway.rb index e7b385a05..271b4a4f7 100644 --- a/lib/fog/aws/requests/compute/delete_internet_gateway.rb +++ b/lib/fog/aws/requests/compute/delete_internet_gateway.rb @@ -30,7 +30,7 @@ module Fog Excon::Response.new.tap do |response| if internet_gateway_id response.status = 200 - self.data[:internet_gateways].reject! { |v| v['internetGatewayId'] == internet_gateway_id } + self.data[:internet_gateways].delete(internet_gateway_id) response.body = { 'requestId' => Fog::AWS::Mock.request_id, diff --git a/lib/fog/aws/requests/compute/describe_internet_gateways.rb b/lib/fog/aws/requests/compute/describe_internet_gateways.rb index 987a599da..a2d7fa51f 100644 --- a/lib/fog/aws/requests/compute/describe_internet_gateways.rb +++ b/lib/fog/aws/requests/compute/describe_internet_gateways.rb @@ -40,7 +40,7 @@ module Fog class Mock def describe_internet_gateways(filters = {}) - internet_gateways = self.data[:internet_gateways] + internet_gateways = self.data[:internet_gateways].values if filters['internet-gateway-id'] internet_gateways = internet_gateways.reject {|internet_gateway| internet_gateway['internetGatewayId'] != filters['internet-gateway-id']}