1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|elasticache] add cache node info to describe_cache_clusters

This commit is contained in:
Benton Roberts 2011-09-13 05:00:45 -04:00 committed by geemus
parent b6cd76046d
commit 7d19d43117
3 changed files with 30 additions and 7 deletions

View file

@ -14,6 +14,7 @@ module Fog
def reset_cache_cluster def reset_cache_cluster
@cache_cluster = { @cache_cluster = {
'CacheSecurityGroups' => [], 'CacheSecurityGroups' => [],
'CacheNodes' => [],
'CacheParameterGroup' => {} 'CacheParameterGroup' => {}
} }
end end
@ -22,6 +23,7 @@ module Fog
super super
case name case name
when 'CacheSecurityGroup'; then @security_group = {} when 'CacheSecurityGroup'; then @security_group = {}
when 'CacheNode'; then @cache_node = {}
end end
end end
@ -40,6 +42,11 @@ module Fog
@cache_cluster["#{name}s"] << @security_group unless @security_group.empty? @cache_cluster["#{name}s"] << @security_group unless @security_group.empty?
when 'CacheSecurityGroupName', 'Status' when 'CacheSecurityGroupName', 'Status'
@security_group[name] = value @security_group[name] = value
when 'CacheNode'
@cache_cluster["#{name}s"] << @cache_node unless @cache_node.empty?
when 'CacheNodeCreateTime', 'CacheNodeId', 'CacheNodeStatus',
'Endpoint', 'ParameterGroupStatus'
@cache_node[name] = value.strip
when 'CacheNodeIdsToReboots', 'CacheParameterGroupName', 'ParameterApplyStatus' when 'CacheNodeIdsToReboots', 'CacheParameterGroupName', 'ParameterApplyStatus'
@cache_cluster['CacheParameterGroup'][name] = value @cache_cluster['CacheParameterGroup'][name] = value
else else

View file

@ -5,11 +5,14 @@ Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache']
# Randomize the cluster ID so tests can be fequently re-run # Randomize the cluster ID so tests can be fequently re-run
cluster_id = "fog-test-cluster-#{rand(999).to_s}" # 20 chars max! cluster_id = "fog-test-cluster-#{rand(999).to_s}" # 20 chars max!
num_nodes = 2
tests( tests(
'#create_cache_cluster' '#create_cache_cluster'
).formats(AWS::Elasticache::Formats::SINGLE_CACHE_CLUSTER) do ).formats(AWS::Elasticache::Formats::SINGLE_CACHE_CLUSTER) do
body = AWS[:elasticache].create_cache_cluster(cluster_id).body body = AWS[:elasticache].create_cache_cluster(cluster_id,
:num_nodes => num_nodes
).body
cluster = body['CacheCluster'] cluster = body['CacheCluster']
returns(cluster_id) { cluster['CacheClusterId'] } returns(cluster_id) { cluster['CacheClusterId'] }
returns('creating') { cluster['CacheClusterStatus'] } returns('creating') { cluster['CacheClusterStatus'] }
@ -47,6 +50,18 @@ Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache']
Formatador.display_line "Waiting for cluster #{cluster_id}..." Formatador.display_line "Waiting for cluster #{cluster_id}..."
AWS[:elasticache].clusters.get(cluster_id).wait_for {ready?} AWS[:elasticache].clusters.get(cluster_id).wait_for {ready?}
tests(
'#describe_cache_clusters with node info'
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
cluster = AWS[:elasticache].describe_cache_clusters(cluster_id,
:show_node_info => true
).body['CacheClusters'].first
returns(num_nodes, "has #{num_nodes} nodes") do
cluster['CacheNodes'].count
end
cluster
end
tests( tests(
'#modify_cache_cluster - change a non-pending cluster attribute' '#modify_cache_cluster - change a non-pending cluster attribute'
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do ).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do

View file

@ -28,15 +28,16 @@ class AWS
'CacheParameterGroup' => Hash, 'CacheParameterGroup' => Hash,
'NumCacheNodes' => Integer, 'NumCacheNodes' => Integer,
'PreferredMaintenanceWindow' => String, 'PreferredMaintenanceWindow' => String,
'CacheNodes' => Array,
} }
CACHE_CLUSTER_RUNNING = CACHE_CLUSTER.merge( CACHE_CLUSTER_RUNNING = CACHE_CLUSTER.merge({
'CacheClusterCreateTime' => DateTime, 'CacheClusterCreateTime' => DateTime,
'PreferredAvailabilityZone' => String 'PreferredAvailabilityZone' => String,
) })
CACHE_CLUSTER_MODIFIED = CACHE_CLUSTER_RUNNING.merge( CACHE_CLUSTER_MODIFIED = CACHE_CLUSTER_RUNNING.merge({
'NotificationConfiguration' => Hash, 'NotificationConfiguration' => Hash,
'PendingModifiedValues' => Hash 'PendingModifiedValues' => Hash,
) })
SINGLE_CACHE_CLUSTER = BASIC.merge('CacheCluster' => CACHE_CLUSTER) SINGLE_CACHE_CLUSTER = BASIC.merge('CacheCluster' => CACHE_CLUSTER)
DESCRIBE_CACHE_CLUSTERS = BASIC.merge('CacheClusters' => [CACHE_CLUSTER]) DESCRIBE_CACHE_CLUSTERS = BASIC.merge('CacheClusters' => [CACHE_CLUSTER])
end end