2011-09-07 16:22:31 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class Elasticache
|
|
|
|
|
|
|
|
class Cluster < Fog::Model
|
|
|
|
# simple attributes
|
|
|
|
identity :id, :aliases => 'CacheClusterId'
|
|
|
|
attribute :auto_upgrade, :aliases => 'AutoMinorVersionUpgrade'
|
|
|
|
attribute :status, :aliases => 'CacheClusterStatus'
|
|
|
|
attribute :node_type, :aliases => 'CacheNodeType'
|
|
|
|
attribute :engine, :aliases => 'Engine'
|
|
|
|
attribute :engine_version, :aliases => 'EngineVersion'
|
|
|
|
attribute :num_nodes, :aliases => 'NumCacheNodes'
|
|
|
|
attribute :zone, :aliases => 'PreferredAvailabilityZone'
|
2011-09-12 11:47:40 -04:00
|
|
|
attribute :port, :aliases => 'Port'
|
2011-09-07 16:22:31 -04:00
|
|
|
attribute :maintenance_window, :aliases => 'PreferredMaintenanceWindow'
|
|
|
|
# complex attributes
|
|
|
|
attribute :nodes, :aliases => 'CacheNodes', :type => :array
|
|
|
|
attribute :parameter_group,
|
|
|
|
:aliases => 'CacheParameterGroup', :type => :hash
|
|
|
|
attribute :pending_values,
|
|
|
|
:aliases => 'PendingModifiedValues', :type => :hash
|
|
|
|
attribute :create_time,
|
|
|
|
:aliases => 'CacheClusterCreateTime', :type => :date_time
|
|
|
|
attribute :security_groups,
|
2011-09-09 13:10:16 -04:00
|
|
|
:aliases => 'CacheSecurityGroups', :type => :array
|
2011-09-07 16:22:31 -04:00
|
|
|
attribute :notification_config,
|
|
|
|
:aliases => 'NotificationConfiguration', :type => :hash
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
status == 'available'
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.delete_cache_cluster(id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :id
|
|
|
|
|
2011-09-09 10:52:40 -04:00
|
|
|
parameter_group ||= Hash.new
|
2011-09-07 16:22:31 -04:00
|
|
|
notification_config ||= Hash.new
|
|
|
|
|
|
|
|
connection.create_cache_cluster(
|
2011-09-09 10:52:40 -04:00
|
|
|
id, {
|
|
|
|
:node_type => node_type,
|
|
|
|
:security_group_names => security_groups,
|
|
|
|
:num_nodes => num_nodes,
|
|
|
|
:auto_minor_version_upgrade => auto_upgrade,
|
|
|
|
:engine => engine,
|
|
|
|
:engine_version => engine_version,
|
2012-02-27 16:15:25 -05:00
|
|
|
:notification_topic_arn => (notification_config['TopicArn']).strip,
|
2011-09-09 10:52:40 -04:00
|
|
|
:port => port,
|
|
|
|
:preferred_availablility_zone => zone,
|
|
|
|
:preferred_maintenance_window => maintenance_window,
|
|
|
|
:parameter_group_name => parameter_group['CacheParameterGroupName'],
|
|
|
|
}
|
2011-09-07 16:22:31 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|