Skip to content

Commit

Permalink
[aws|elasticache] add pending_values to modified nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
benton authored and geemus committed Sep 27, 2011
1 parent 7bf0fa6 commit c544d85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
20 changes: 18 additions & 2 deletions lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb
Expand Up @@ -24,18 +24,29 @@ def start_element(name, attrs = [])
case name
when 'CacheSecurityGroup'; then @security_group = {}
when 'CacheNode'; then @cache_node = {}
when 'PendingModifiedValues'; then @pending_values = {}
end

end

def end_element(name)
case name
when 'AutoMinorVersionUpgrade', 'CacheClusterId',
'CacheClusterStatus', 'CacheNodeType', 'Engine', 'EngineVersion',
'CacheClusterStatus', 'CacheNodeType', 'Engine',
'PreferredAvailabilityZone', 'PreferredMaintenanceWindow'
@cache_cluster[name] = value
when 'EngineVersion', 'CacheNodeIdsToRemoves'
if @pending_values
@pending_values[name] = value ? value.strip : name
else
@cache_cluster[name] = value
end
when 'NumCacheNodes'
@cache_cluster[name] = value.to_i
if @pending_values
@pending_values[name] = value.to_i
else
@cache_cluster[name] = value.to_i
end
when 'CacheClusterCreateTime'
@cache_cluster[name] = DateTime.parse(value)
when 'CacheSecurityGroup'
Expand All @@ -45,10 +56,15 @@ def end_element(name)
when 'CacheNode'
@cache_cluster["#{name}s"] << @cache_node unless @cache_node.empty?
@cache_node = nil
when'PendingModifiedValues'
@cache_cluster[name] = @pending_values
@pending_values = nil
when 'CacheNodeCreateTime', 'CacheNodeStatus', 'Address',
'ParameterGroupStatus', 'Port', 'CacheNodeId'
if @cache_node
@cache_node[name] = value ? value.strip : name
elsif @pending_values
@pending_values[name] = value ? value.strip : name
end
when 'CacheNodeIdsToReboots', 'CacheParameterGroupName', 'ParameterApplyStatus'
@cache_cluster['CacheParameterGroup'][name] = value
Expand Down
5 changes: 1 addition & 4 deletions tests/aws/requests/elasticache/cache_cluster_tests.rb
Expand Up @@ -85,11 +85,8 @@
:nodes_to_remove => node_id,
:apply_immediately => true,
}).body
Formatador.display_line "Waiting for cluster #{CLUSTER_ID}..."
AWS[:elasticache].clusters.get(CLUSTER_ID).wait_for {ready?}
c.reload
node = c.nodes.find {|n| n['CacheNodeId'] == node_id}
#returns('deleting') { node['CacheNodeStatus'] }
returns(NUM_NODES - 1) { c.pending_values['NumCacheNodes'] }
body['CacheCluster']
end

Expand Down
1 change: 1 addition & 0 deletions tests/aws/requests/elasticache/helper.rb
Expand Up @@ -29,6 +29,7 @@ module Formats
'NumCacheNodes' => Integer,
'PreferredMaintenanceWindow' => String,
'CacheNodes' => Array,
'PendingModifiedValues' => Hash,
}
CACHE_CLUSTER_RUNNING = CACHE_CLUSTER.merge({
'CacheClusterCreateTime' => DateTime,
Expand Down

0 comments on commit c544d85

Please sign in to comment.