mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|elasticache] implement modify_cache_cluster request
This commit is contained in:
parent
951f5f8fdd
commit
7c2e63075a
3 changed files with 95 additions and 1 deletions
|
@ -12,7 +12,7 @@ module Fog
|
|||
request :create_cache_cluster
|
||||
request :delete_cache_cluster
|
||||
request :describe_cache_clusters
|
||||
#request :modify_cache_cluster
|
||||
request :modify_cache_cluster
|
||||
#request :reboot_cache_cluster
|
||||
|
||||
#request :create_cache_parameter_group
|
||||
|
|
72
lib/fog/aws/requests/elasticache/modify_cache_cluster.rb
Normal file
72
lib/fog/aws/requests/elasticache/modify_cache_cluster.rb
Normal file
|
@ -0,0 +1,72 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Elasticache
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elasticache/single_cache_cluster'
|
||||
|
||||
# Modifies an existing cache cluster
|
||||
# Returns a cache cluster description
|
||||
#
|
||||
# === Required Parameters
|
||||
# * id <~String> - The ID of the existing cluster to be modified
|
||||
# === Optional Parameters
|
||||
# * options <~Hash> - All optional parameters should be set in this Hash:
|
||||
# * :apply_immediately <~TrueFalseClass> - whether to apply changes now
|
||||
# * :auto_minor_version_upgrade <~TrueFalseClass>
|
||||
# * :num_nodes <~Integer> - The number of nodes in the Cluster
|
||||
# * :nodes_to_remove <~Array> - Array of node IDs to delete
|
||||
# * :security_group_names <~Array> - Array of Elasticache::SecurityGroup names
|
||||
# * :parameter_group_name <~String> - Name of the Cluster's ParameterGroup
|
||||
# * :engine_version <~String> - The Cluster's caching software version
|
||||
# * :notification_topic_arn <~String> - Amazon SNS Resource Name
|
||||
# * :notification_topic_status <~String> - Amazon SNS Topic status
|
||||
# * :port <~Integer> - The memcached port number
|
||||
# * :preferred_maintenance_window <~String>
|
||||
# === Returns
|
||||
# * response <~Excon::Response>:
|
||||
# * body <~Hash>
|
||||
def modify_cache_cluster(id, options = {})
|
||||
# Construct Cache Security Group parameters in the format:
|
||||
# CacheSecurityGroupNames.member.N => "security_group_name"
|
||||
group_names = options[:security_group_names] || []
|
||||
sec_group_params = group_names.inject({}) do |group_hash, name|
|
||||
index = group_names.index(name) + 1
|
||||
group_hash["CacheSecurityGroupNames.member.#{index}"] = name
|
||||
group_hash
|
||||
end
|
||||
# Construct CacheNodeIdsToRemove parameters in the format:
|
||||
# CacheNodeIdsToRemove.member.N => "node_id"
|
||||
node_ids = options[:nodes_to_remove] || []
|
||||
node_id_params = node_ids.inject({}) do |node_hash, id|
|
||||
index = node_ids.index(name) + 1
|
||||
node_hash["CacheNodeIdsToRemove.member.#{index}"] = id
|
||||
node_hash
|
||||
end
|
||||
# Merge the Cache Security Group parameters with the normal options
|
||||
request(node_id_params.merge(sec_group_params.merge(
|
||||
'Action' => 'ModifyCacheCluster',
|
||||
'CacheClusterId' => id,
|
||||
'ApplyImmediately' => options[:apply_immediately],
|
||||
'NumCacheNodes' => options[:num_nodes],
|
||||
'AutoMinorVersionUpgrade' => options[:auto_minor_version_upgrade],
|
||||
'CacheParameterGroupName' => options[:parameter_group_name],
|
||||
'EngineVersion' => options[:engine_version],
|
||||
'NotificationTopicArn' => options[:notification_topic_arn],
|
||||
'NotificationTopicStatus' => options[:notification_topic_status],
|
||||
'Port' => options[:port],
|
||||
'PreferredMaintenanceWindow' => options[:preferred_maintenance_window],
|
||||
:parser => Fog::Parsers::AWS::Elasticache::SingleCacheCluster.new
|
||||
)))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def modify_cache_cluster
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -47,6 +47,28 @@ Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache']
|
|||
Formatador.display_line "Waiting for cluster #{cluster_id}..."
|
||||
AWS[:elasticache].clusters.get(cluster_id).wait_for {ready?}
|
||||
|
||||
tests(
|
||||
'#modify_cache_cluster - change a non-pending cluster attribute'
|
||||
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
||||
body = AWS[:elasticache].modify_cache_cluster(cluster_id,
|
||||
:auto_minor_version_upgrade => false
|
||||
).body
|
||||
# now check that parameter change is in place
|
||||
returns('false') { body['CacheCluster']['AutoMinorVersionUpgrade'] }
|
||||
body['CacheCluster']
|
||||
end
|
||||
|
||||
tests(
|
||||
'#modify_cache_cluster - change a pending cluster attribute'
|
||||
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
||||
body = AWS[:elasticache].modify_cache_cluster(cluster_id,
|
||||
:auto_minor_version_upgrade => false
|
||||
).body
|
||||
# now check that parameter change is in place
|
||||
returns('false') { body['CacheCluster']['AutoMinorVersionUpgrade'] }
|
||||
body['CacheCluster']
|
||||
end
|
||||
|
||||
tests(
|
||||
'#delete_cache_clusters'
|
||||
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
||||
|
|
Loading…
Reference in a new issue