diff --git a/lib/fog/aws/models/elasticache/cluster.rb b/lib/fog/aws/models/elasticache/cluster.rb index f7a9c89e7..4918910b6 100644 --- a/lib/fog/aws/models/elasticache/cluster.rb +++ b/lib/fog/aws/models/elasticache/cluster.rb @@ -18,7 +18,8 @@ module Fog attribute :parameter_group, :aliases => 'CacheParameterGroup' attribute :pending_values, :aliases => 'PendingModifiedValues' attribute :create_time, :aliases => 'CacheClusterCreateTime', :type => :timestamp - attribute :security_groups, :aliases => 'CacheSecurityGroups', :type => :array + attribute :cache_security_groups, :aliases => 'CacheSecurityGroups', :type => :array + attribute :security_groups, :aliases => 'SecurityGroups', :type => :array attribute :notification_config, :aliases => 'NotificationConfiguration' attribute :cache_subnet_group_name, :aliases => 'CacheSubnetGroupName' attribute :vpc_security_groups, :aliases => 'VpcSecurityGroups', :type => :array diff --git a/lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb b/lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb index bfc1fd028..b52fbe8c7 100644 --- a/lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb +++ b/lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb @@ -15,17 +15,26 @@ module Fog 'CacheSecurityGroups' => [], 'CacheNodes' => [], 'CacheParameterGroup' => {}, - 'ConfigurationEndpoint' => {} + 'ConfigurationEndpoint' => {}, + 'SecurityGroups' => [] } end def start_element(name, attrs = []) super case name - when 'CacheSecurityGroup'; then @security_group = {} + when 'CacheSecurityGroup'; then @cache_security_group = {} when 'CacheNode'; then @cache_node = {} when 'PendingModifiedValues'; then @pending_values = {} when 'ConfigurationEndpoint'; then @configuration_endpoint = {} + when 'SecurityGroups' + @in_security_groups = true + @security_group_members = [] + when 'member' + if @in_security_groups + @in_security_group_member = true + @security_group_member = {} + end end end @@ -50,11 +59,17 @@ module Fog when 'CacheClusterCreateTime' @cache_cluster[name] = DateTime.parse(value) when 'CacheSecurityGroup' - @cache_cluster["#{name}s"] << @security_group unless @security_group.empty? + @cache_cluster["#{name}s"] << @cache_security_group unless @cache_security_group.empty? when 'ConfigurationEndpoint' @cache_cluster['ConfigurationEndpoint'] = @configuration_endpoint - when 'CacheSecurityGroupName', 'Status', 'CacheSubnetGroupName' + when 'CacheSecurityGroupName', 'CacheSubnetGroupName' @cache_cluster[name] = value + when 'Status' + if @in_security_group_member + @security_group_member[name] = value + else + @cache_cluster[name] = value + end when 'CacheNode' @cache_cluster["#{name}s"] << @cache_node unless @cache_node.empty? @cache_node = nil @@ -78,6 +93,16 @@ module Fog end when 'CacheNodeIdsToReboots', 'CacheParameterGroupName', 'ParameterApplyStatus' @cache_cluster['CacheParameterGroup'][name] = value + when 'SecurityGroups' + @in_security_groups = false + @cache_cluster['SecurityGroups'] = @security_group_members + when 'SecurityGroupId' + @security_group_member[name] = value if @in_security_group_member + when 'member' + if @in_security_groups + @in_security_group_member = false + @security_group_members << @security_group_member + end else super end diff --git a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb index 7fcf11517..db085ccbb 100644 --- a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +++ b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb @@ -72,6 +72,7 @@ module Fog 'CacheClusterStatus' => 'available', 'CacheNodes' => create_cache_nodes(id.strip, options[:num_nodes]), 'CacheSecurityGroups' => [], + 'SecurityGroups' => [], 'CacheParameterGroup' => { 'CacheParameterGroupName' => options[:parameter_group_name] || 'default.memcached1.4' }, 'CacheSubnetGroupName' => options[:cache_subnet_group_name],