From 7bdd9fa67cf3dbaa929648f34d60f0041e250a5e Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Mon, 1 Apr 2013 15:03:32 -0400 Subject: [PATCH] [aws] Handle the "phantom" security group that exists for elbs --- .../aws/requests/compute/describe_security_groups.rb | 6 ++++-- lib/fog/aws/requests/elb/create_load_balancer.rb | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/requests/compute/describe_security_groups.rb b/lib/fog/aws/requests/compute/describe_security_groups.rb index cff146aca..d76d33ab4 100644 --- a/lib/fog/aws/requests/compute/describe_security_groups.rb +++ b/lib/fog/aws/requests/compute/describe_security_groups.rb @@ -55,7 +55,9 @@ module Fog response = Excon::Response.new - security_group_info = self.data[:security_groups].values + security_groups = self.data[:security_groups].dup + security_groups.delete('amazon-elb-sg') + security_group_info = security_groups.values aliases = { 'description' => 'groupDescription', @@ -71,7 +73,7 @@ module Fog } for filter_key, filter_value in filters if permission_key = filter_key.split('ip-permission.')[1] - if permission_key == 'group-name' + if permission_key == 'group-name' security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions']['groups'].detect {|group| [*filter_value].include?(group['groupName'])}} elsif permission_key == 'group-id' security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions']['groups'].detect {|group| [*filter_value].include?(group['groupId'])}} diff --git a/lib/fog/aws/requests/elb/create_load_balancer.rb b/lib/fog/aws/requests/elb/create_load_balancer.rb index 7db04bb29..60f6e0e84 100644 --- a/lib/fog/aws/requests/elb/create_load_balancer.rb +++ b/lib/fog/aws/requests/elb/create_load_balancer.rb @@ -73,6 +73,16 @@ module Fog end dns_name = Fog::AWS::ELB::Mock.dns_name(lb_name, @region) + + Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:security_groups]['amazon-elb-sg'] ||= { + 'groupDescription' => 'amazon-elb-sg', + 'groupName' => 'amazon-elb-sg', + 'groupId' => 'amazon-elb', + 'ownerId' => 'amazon-elb', + 'ipPermissionsEgree' => [], + 'ipPermissions' => [], + } + self.data[:load_balancers][lb_name] = { 'AvailabilityZones' => availability_zones, 'Subnets' => options[:subnet_ids] || [],