Sha256: 075740cfbe191b0afff4b177095cd82682f77a44d467c18b42345cf527ff38f9

Contents?: true

Size: 1.24 KB

Versions: 32

Compression:

Stored size: 1.24 KB

Contents

class BuildCloud::CacheSubnetGroup

    include ::BuildCloud::Component

    @@objects = []

    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

    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

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

    alias_method :fog_object, :read

    def delete

        return unless exists?

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

        fog_object.destroy

    end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
build-cloud-0.0.13 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.12 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.11 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.10 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.9 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.8 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.7 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.6 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.5 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.4 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.3 lib/build-cloud/cachesubnetgroup.rb
build-cloud-0.0.1 lib/build-cloud/cachesubnetgroup.rb