Class: BuildCloud::CacheSubnetGroup

Inherits:
Object
  • Object
show all
Includes:
Component
Defined in:
lib/build-cloud/cachesubnetgroup.rb

Constant Summary collapse

@@objects =
[]

Instance Method Summary collapse

Methods included from Component

included

Constructor Details

#initialize(fog_interfaces, log, options = {}) ⇒ CacheSubnetGroup

Returns a new instance of CacheSubnetGroup.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/build-cloud/cachesubnetgroup.rb', line 8

def initialize ( fog_interfaces, log, options = {} )

    @elasticache = fog_interfaces[:elasticache]
    @log         = log
    @options     = options

    @log.debug( options.inspect )

    required_options(:name)
    require_one_of(:subnet_ids, :subnet_names)

end

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/build-cloud/cachesubnetgroup.rb', line 21

def create
    
    return if exists?

    @log.info( "Creating Cache Subnet Group #{@options[:id]}" )

    options = @options.dup

    unless options[:subnet_ids]

        options[:subnet_ids] = []

        options[:subnet_names].each do |sn|
            options[:subnet_ids] << BuildCloud::Subnet.get_id_by_name( sn )
        end

        options.delete(:subnet_names)

    end

    group = @elasticache.create_cache_subnet_group( options[:name], options[:subnet_ids] )

    @log.debug( group.inspect )

end

#deleteObject



53
54
55
56
57
58
59
60
61
# File 'lib/build-cloud/cachesubnetgroup.rb', line 53

def delete

    return unless exists?

    @log.info( "Deleting Cache Subnet Group #{@options[:name]}" )

    fog_object.destroy

end

#readObject Also known as: fog_object



47
48
49
# File 'lib/build-cloud/cachesubnetgroup.rb', line 47

def read
    @elasticache.subnet_groups.select { |g| g.id == @options[:name] }.first
end