Class: CloudProviders::RdsInstance

Inherits:
Ec2Helper show all
Defined in:
lib/cloud_providers/ec2/helpers/rds_instance.rb

Instance Attribute Summary

Attributes inherited from CloudProvider

#init_opts, #name

Instance Method Summary collapse

Methods inherited from Ec2Helper

#as, #ec2, #elb, #initialize, #pool, property, #rds

Methods inherited from CloudProvider

#bootstrap_nodes!, #default_keypair_path, default_keypair_path, #initialize, #method_missing

Constructor Details

This class inherits a constructor from CloudProviders::Ec2Helper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CloudProviders::CloudProvider

Instance Method Details

#authorize(options) ⇒ Object



5
6
7
8
9
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 5

def authorize(options)
  options.each do |key, value|
    authorizations[key.to_s] = value
  end
end

#available?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 44

def available?
  exists? && current_status.DBInstanceStatus == 'available'
end

#create!Object



18
19
20
21
22
23
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 18

def create!
  if should_create_rds_instance?
    puts "-----> Creating RDS Instance: #{instance_id}"
    create_rds_instance!
  end
end

#current_statusObject



36
37
38
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 36

def current_status
  rds_instances.detect{|i| i.DBInstanceIdentifier == instance_id }
end

#database(*db_names) ⇒ Object Also known as: databases



11
12
13
14
15
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 11

def database(*db_names)
  @databases ||= []
  @databases = @databases + db_names unless db_names.empty?
  @databases
end

#exists?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 40

def exists?
  ! current_status.nil?
end

#instance_idObject



48
49
50
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 48

def instance_id
  name.to_s
end

#runObject



25
26
27
28
29
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 25

def run
  create! # Just for now, while we migrate to 2 commands
  authorize_access
  # TODO : wait until accessible?
end

#teardownObject



31
32
33
34
# File 'lib/cloud_providers/ec2/helpers/rds_instance.rb', line 31

def teardown
  puts "-----> Tearing down RDS Instance: #{instance_id}"
  delete_rds_instance!
end