lib/rubber/dns/aws.rb
# Convert from fog/aws model to rubber option hash that represents a dns record
Convert from fog/aws model to rubber option hash that represents a dns record
Convert from fog / aws model to rubber option hash that represents a dns record
def host_to_opts(host)
        opts = {}
        opts[:host] ||= host.name || ''
        opts[:domain] ||= host.zone.domain
        opts[:host], opts[:domain] = normalize_name(opts[:host], opts[:domain])
        opts[:type] ||= host.type
        opts[:ttl] ||= host.ttl.to_i if host.ttl
        opts[:data] ||= []
        if host.type =~ /MX/i
          host.value.each do |val|
            parts = val.split(" ")
            opts[:data] << {'priority' => parts[0], 'value' => parts[1]}
          end
        elsif ! host.alias_target.nil?
          opts[:data] << {
            'hosted_zone_id' => host.alias_target['HostedZoneId'],
            'dns_name' => host.alias_target['DNSName'].split('.')[0..-1].join('.')
          }
          opts.delete(:ttl)
        else
          opts[:data].concat(Array(host.value))
        end
        opts
      end
def host_to_opts ( host ) opts = { } opts [ :host ] ||= host . name || '' opts [ :domain ] ||= host . zone . domain opts [ :host ] , opts [ :domain ] = normalize_name ( opts [ :host ] , opts [ :domain ] ) opts [ :type ] ||= host . type opts [ :ttl ] ||= host . ttl . to_i if host . ttl opts [ :data ] ||= [ ] if host . type =~ / MX /i host . value . each do | val | parts = val . split ( " " ) opts [ :data ] << { 'priority' => parts [ 0 ] , 'value' => parts [ 1 ] } end elsif ! host . alias_target . nil? opts [ :data ] << { 'hosted_zone_id' => host . alias_target [ 'HostedZoneId' ] , 'dns_name' => host . alias_target [ 'DNSName' ] . split ( '.' ) [ 0 .. - 1 ] . join ( '.' ) } opts . delete ( :ttl ) else opts [ :data ] . concat ( Array ( host . value ) ) end opts end
Convert from fog/aws model to rubber option hash that represents a dns record
Convert from fog / aws model to rubber option hash that represents a dns record
# Convert from camel-case to snake-case for Route 53 ALIAS records # so the match the rubber config format. # Route 53 ALIAS records do not have a TTL, so delete the rubber-supplied default value.
host