Class: BuildCloud::CacheCluster
- Inherits:
-
Object
- Object
- BuildCloud::CacheCluster
- Includes:
- Component
- Defined in:
- lib/build-cloud/cachecluster.rb
Constant Summary collapse
- @@objects =
[]
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ CacheCluster
constructor
A new instance of CacheCluster.
- #read ⇒ Object (also: #fog_object)
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ CacheCluster
Returns a new instance of CacheCluster.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/build-cloud/cachecluster.rb', line 8 def initialize ( fog_interfaces, log, = {} ) @elasticache = fog_interfaces[:elasticache] @log = log @options = @log.debug( .inspect ) (:id, :node_type, :num_nodes, :auto_minor_version_upgrade, :engine, :cache_subnet_group_name) require_one_of(:vpc_security_groups, :vpc_security_group_names) end |
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/build-cloud/cachecluster.rb', line 22 def create return if exists? @log.info( "Creating Elasticache Cluster #{@options[:id]}" ) = @options.dup unless [:vpc_security_groups] [:vpc_security_groups] = [] [:vpc_security_group_names].each do |sg| [:vpc_security_groups] << BuildCloud::SecurityGroup. get_id_by_name( sg ) end .delete(:vpc_security_group_names) end cluster = @elasticache.clusters.new( ) cluster.save @log.debug( cluster.inspect ) end |
#delete ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/build-cloud/cachecluster.rb', line 55 def delete return unless exists? @log.info( "Deleting Elasticache cluster #{@options[:id]}" ) fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
49 50 51 |
# File 'lib/build-cloud/cachecluster.rb', line 49 def read @elasticache.clusters.select { |c| c.id == @options[:id] }.first end |