From b539bf9f85ee4f1db26d5d709d4fb50e3a9ae6c3 Mon Sep 17 00:00:00 2001 From: Benton Roberts Date: Fri, 9 Sep 2011 11:21:56 -0400 Subject: [PATCH] [aws|elasticache] change parameters for describe_cache_security_groups to ruby-friendly values --- .../aws/models/elasticache/security_groups.rb | 2 +- .../elasticache/create_cache_cluster.rb | 6 +++--- .../describe_cache_security_groups.rb | 20 +++++++++---------- .../elasticache/security_group_tests.rb | 10 +++------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/fog/aws/models/elasticache/security_groups.rb b/lib/fog/aws/models/elasticache/security_groups.rb index 22acfa411..2578ff67b 100644 --- a/lib/fog/aws/models/elasticache/security_groups.rb +++ b/lib/fog/aws/models/elasticache/security_groups.rb @@ -17,7 +17,7 @@ module Fog def get(identity) new( connection.describe_cache_security_groups( - 'CacheSecurityGroupName' => identity + identity ).body['CacheSecurityGroups'].first ) rescue Fog::AWS::Elasticache::NotFound diff --git a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb index eee82a059..6ac85f7f9 100644 --- a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +++ b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb @@ -8,8 +8,8 @@ module Fog # # === Required Parameters # * id <~String> - A unique cluster ID - 20 characters max. - # === Optional Parameters (passed into the options hash) - # * options <~Hash> - The all parameters should be set in this Hash: + # === Optional Parameters + # * options <~Hash> - All optional parameters should be set in this Hash: # * :node_type <~String> - The size (flavor) of the cache Nodes # * :security_group_names <~Array> - Array of Elasticache::SecurityGroup names # * :num_nodes <~Integer> - The number of nodes in the Cluster @@ -39,7 +39,7 @@ module Fog 'CacheClusterId' => id, 'CacheNodeType' => options[:node_type] || 'cache.m1.large', 'Engine' => options[:engine] || 'memcached', - 'NumCacheNodes' => options[:num_nodes] || 1 , + 'NumCacheNodes' => options[:num_nodes] || 1, 'AutoMinorVersionUpgrade' => options[:auto_minor_version_upgrade], 'CacheParameterGroupName' => options[:parameter_group_name], 'EngineVersion' => options[:engine_version], diff --git a/lib/fog/aws/requests/elasticache/describe_cache_security_groups.rb b/lib/fog/aws/requests/elasticache/describe_cache_security_groups.rb index 707c96fca..e09b7344f 100644 --- a/lib/fog/aws/requests/elasticache/describe_cache_security_groups.rb +++ b/lib/fog/aws/requests/elasticache/describe_cache_security_groups.rb @@ -7,17 +7,17 @@ module Fog # Returns a list of CacheSecurityGroup descriptions # - # === Parameters + # === Parameters (optional) + # * name <~String> - The name of an existing cache security group # * options <~Hash> (optional): - # * CacheSecurityGroupName<~String> - The name of the cache security group - # * Marker <~String> - marker provided in the previous request - # * MaxRecords <~String> - the maximum number of records to include - # === Returns - # * response <~Excon::Response>: - # * body <~Hash> - def describe_cache_security_groups(options = {}) + # * :marker <~String> - marker provided in the previous request + # * :max_records <~Integer> - the maximum number of records to include + def describe_cache_security_groups(name = nil, options = {}) request({ - 'Action' => 'DescribeCacheSecurityGroups', + 'Action' => 'DescribeCacheSecurityGroups', + 'CacheSecurityGroupName' => name, + 'Marker' => options[:marker], + 'MaxRecords' => options[:max_records], :parser => Fog::Parsers::AWS::Elasticache::DescribeSecurityGroups.new }.merge(options)) end @@ -25,7 +25,7 @@ module Fog end class Mock - def describe_cache_security_groups + def describe_cache_security_groups(name = nil, options = {}) Fog::Mock.not_implemented end end diff --git a/tests/aws/requests/elasticache/security_group_tests.rb b/tests/aws/requests/elasticache/security_group_tests.rb index ff1fa2cc7..774e5b1da 100644 --- a/tests/aws/requests/elasticache/security_group_tests.rb +++ b/tests/aws/requests/elasticache/security_group_tests.rb @@ -32,9 +32,7 @@ Shindo.tests('AWS::Elasticache | security group requests', ['aws', 'elasticache' tests( '#describe_cache_security_groups with name' ).formats(AWS::Elasticache::Formats::DESCRIBE_SECURITY_GROUPS) do - body = AWS[:elasticache].describe_cache_security_groups( - 'CacheSecurityGroupName' => name - ).body + body = AWS[:elasticache].describe_cache_security_groups(name).body returns(1, "size of 1") { body['CacheSecurityGroups'].size } returns(name, "has #{name}") do body['CacheSecurityGroups'].first['CacheSecurityGroupName'] @@ -68,9 +66,8 @@ Shindo.tests('AWS::Elasticache | security group requests', ['aws', 'elasticache' # Wait for the state to be active Fog.wait_for do - group = AWS[:elasticache].describe_cache_security_groups( - 'CacheSecurityGroupName' => name - ).body['CacheSecurityGroups'].first + response = AWS[:elasticache].describe_cache_security_groups(name) + group = response.body['CacheSecurityGroups'].first group['EC2SecurityGroups'].all? {|ec2| ec2['Status'] == 'authorized'} end @@ -91,7 +88,6 @@ Shindo.tests('AWS::Elasticache | security group requests', ['aws', 'elasticache' body end - ec2_group.destroy end