Class: BuildCloud::RDSServer

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

Constant Summary collapse

@@objects =
[]

Instance Method Summary collapse

Methods included from Component

included

Constructor Details

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

Returns a new instance of RDSServer.



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

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

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

    @log.debug( options.inspect )

    required_options(:id, :engine, :allocated_storage, :backup_retention_period,
                     :flavor_id, :db_name, :master_username, :password, :vpc_security_group_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
46
47
48
49
50
# File 'lib/build-cloud/rdsserver.rb', line 21

def create

    return if exists?

    @log.info( "Creating RDS Server #{@options[:id]}" )

    options = @options.dup

    options[:db_security_groups] = []

    unless options[:vpc_security_groups]

        options[:vpc_security_groups] = []

        options[:vpc_security_group_names].each do |sg|
            options[:vpc_security_groups] << BuildCloud::SecurityGroup.get_id_by_name( sg )
        end

        options.delete(:vpc_security_group_names)

    end

    @log.debug( options.inspect)

    rds_server = @rds.servers.new( options )
    rds_server.save

    @log.debug( rds_server.inspect )

end

#deleteObject



62
63
64
65
66
67
68
69
70
# File 'lib/build-cloud/rdsserver.rb', line 62

def delete

    return unless exists?

    @log.info( "Deleting RDS Server #{@options[:id]}" )

    fog_object.destroy

end

#readObject Also known as: fog_object



56
57
58
# File 'lib/build-cloud/rdsserver.rb', line 56

def read
    @rds.servers.select { |r| r.id == @options[:id] }.first
end

#ready_timeoutObject



52
53
54
# File 'lib/build-cloud/rdsserver.rb', line 52

def ready_timeout
    20 * 60 # RDS instances take a while
end