Class: BuildCloud::R53RecordSet
- Inherits:
-
Object
- Object
- BuildCloud::R53RecordSet
- Includes:
- Component
- Defined in:
- lib/build-cloud/r53recordset.rb
Constant Summary collapse
- @@objects =
[]
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ R53RecordSet
constructor
A new instance of R53RecordSet.
- #read ⇒ Object (also: #fog_object)
- #wait_until_ready ⇒ Object
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ R53RecordSet
Returns a new instance of R53RecordSet.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/build-cloud/r53recordset.rb', line 7 def initialize ( fog_interfaces, log, = {} ) @log = log @options = @log.debug( .inspect ) (:name, :type, :zone) @zone_name = .delete(:zone) end |
Instance Method Details
#create ⇒ Object
19 20 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/build-cloud/r53recordset.rb', line 19 def create return if exists? @log.info( "Creating record set #{@options[:name]}" ) = @options.dup if .has_key?(:alias_target) unless [:alias_target][:dns_name] and [:alias_target][:hosted_zone_id] elb_name = [:alias_target].delete(:elb) elb = BuildCloud::LoadBalancer.search( :id => elb_name ).first unless elb raise "Can't find ELB object for #{elb_name}" end [:alias_target][:dns_name] = elb.read.dns_name [:alias_target][:hosted_zone_id] = elb.read.hosted_zone_name_id end end if rds_server = .delete(:rds_server) rds = BuildCloud::RDSServer.search( :id => rds_server ).first unless rds raise "Can't find RDS Server for #{rds_server}" end [:value] = [ rds.read.endpoint["Address"] ] end if cache_cluster = .delete(:cache_cluster) cache = BuildCloud::CacheCluster.search( :id => cache_cluster ).first unless cache raise "Can't find cache cluster for #{cache_cluster}" end [:value] = [ cache.read.nodes.first["Address"] ] end record = zone.records.create( ) @log.debug(record.inspect) end |
#delete ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/build-cloud/r53recordset.rb', line 84 def delete return unless exists? @log.info( "Deleting record #{@options[:name]}" ) # Fog errors unless ttl is set: fog_object.ttl = 1 fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
75 76 77 78 79 80 |
# File 'lib/build-cloud/r53recordset.rb', line 75 def read if zone return zone.records.select { |r| r.name == @options[:name] }.first end nil end |
#wait_until_ready ⇒ Object
96 97 98 |
# File 'lib/build-cloud/r53recordset.rb', line 96 def wait_until_ready @log.debug("Can't wait on r53 record set creation") end |