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 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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 network_interface_public_ip = .delete(:network_interface_public_ip) network_interface = BuildCloud::NetworkInterface.search( :name => network_interface_public_ip ).first unless network_interface raise "Can't find Network Interface ID #{network_interface_id} for Instance #{instance_public_ip}" end [:value] = network_interface.read.association['publicIp'] 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
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/build-cloud/r53recordset.rb', line 95 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
87 88 89 90 91 |
# File 'lib/build-cloud/r53recordset.rb', line 87 def read if zone zone.records.get @options[:name] end end |
#wait_until_ready ⇒ Object
107 108 109 |
# File 'lib/build-cloud/r53recordset.rb', line 107 def wait_until_ready @log.debug("Can't wait on r53 record set creation") end |