From 4c24e5fe5c21466b6ad478ae1cbb5299b208fc48 Mon Sep 17 00:00:00 2001 From: geemus Date: Fri, 27 May 2011 10:30:20 -0700 Subject: [PATCH] [dns] rename ip to value for record closes #191 --- lib/fog/dns/models/aws/record.rb | 13 ++++++++----- lib/fog/dns/models/bluebox/record.rb | 11 +++++++---- lib/fog/dns/models/dnsimple/record.rb | 11 +++++++---- lib/fog/dns/models/linode/record.rb | 7 +++++-- lib/fog/dns/models/slicehost/record.rb | 9 ++++++--- lib/fog/dns/models/zerigo/record.rb | 9 ++++++--- tests/dns/models/record_tests.rb | 6 +++--- tests/dns/models/records_tests.rb | 6 +++--- 8 files changed, 45 insertions(+), 27 deletions(-) diff --git a/lib/fog/dns/models/aws/record.rb b/lib/fog/dns/models/aws/record.rb index 299b5f692..85bbe4c8e 100644 --- a/lib/fog/dns/models/aws/record.rb +++ b/lib/fog/dns/models/aws/record.rb @@ -5,10 +5,13 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id, :aliases => ['Id'] - attribute :ip, :aliases => ['ResourceRecords'] + attribute :value, :aliases => ['ResourceRecords'] attribute :name, :aliases => ['Name'] attribute :ttl, :aliases => ['TTL'] attribute :type, :aliases => ['Type'] @@ -21,11 +24,11 @@ module Fog end def destroy - requires :ip, :name, :ttl, :type, :zone + requires :name, :ttl, :type, :value, :zone options = { :action => 'DELETE', :name => name, - :resource_records => [*ip], + :resource_records => [*value], :ttl => ttl, :type => type } @@ -38,11 +41,11 @@ module Fog end def save - requires :ip, :name, :ttl, :type, :zone + requires :name, :ttl, :type, :value, :zone options = { :action => 'CREATE', :name => name, - :resource_records => [*ip], + :resource_records => [*value], :ttl => ttl, :type => type } diff --git a/lib/fog/dns/models/bluebox/record.rb b/lib/fog/dns/models/bluebox/record.rb index 962c705e1..e8d417e60 100644 --- a/lib/fog/dns/models/bluebox/record.rb +++ b/lib/fog/dns/models/bluebox/record.rb @@ -5,6 +5,9 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id @@ -12,7 +15,7 @@ module Fog attribute :domain_id, :aliases => 'domain-id' attribute :domain attribute :type - attribute :ip, :aliases => 'content' + attribute :value, :aliases => 'content' def initialize(attributes={}) super @@ -29,11 +32,11 @@ module Fog end def save - requires :zone, :type, :name, :ip + requires :zone, :type, :name, :value data = unless identity - connection.create_record(zone.identity, type, name, ip) + connection.create_record(zone.identity, type, name, value) else - connection.update_record(zone.identity, identity, {:type => type, :name => name, :content => ip}) + connection.update_record(zone.identity, identity, {:type => type, :name => name, :content => value}) end merge_attributes(data.body) true diff --git a/lib/fog/dns/models/dnsimple/record.rb b/lib/fog/dns/models/dnsimple/record.rb index b7f491719..ae59f1dc4 100644 --- a/lib/fog/dns/models/dnsimple/record.rb +++ b/lib/fog/dns/models/dnsimple/record.rb @@ -5,11 +5,14 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id attribute :name - attribute :ip, :aliases => "content" + attribute :value, :aliases => "content" attribute :ttl attribute :created_at attribute :updated_at @@ -32,17 +35,17 @@ module Fog end def save - requires :name, :type, :ip + requires :name, :type, :value options = {} options[:prio] = priority if priority options[:ttl] = ttl if ttl # decide whether its a new record or update of an existing if id.nil? - data = connection.create_record(zone.domain, name, type, ip, options) + data = connection.create_record(zone.domain, name, type, value, options) else options[:name] = name if name - options[:content] = ip if ip + options[:content] = value if value options[:type] = type if type data = connection.update_record(zone.domain, id, options) end diff --git a/lib/fog/dns/models/linode/record.rb b/lib/fog/dns/models/linode/record.rb index 300e634ff..e82c4e828 100644 --- a/lib/fog/dns/models/linode/record.rb +++ b/lib/fog/dns/models/linode/record.rb @@ -5,10 +5,13 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id, :aliases => ['ResourceID', 'RESOURCEID'] - attribute :ip, :aliases => 'TARGET' + attribute :value, :aliases => 'TARGET' attribute :name, :aliases => 'NAME' attribute :priority, :aliases => 'PRIORITY' attribute :ttl, :aliases => 'TTL_SEC' @@ -44,7 +47,7 @@ module Fog # types. default: udp options[:name] = name if name options[:priority] = priority if priority - options[:target] = ip if ip + options[:target] = value if value options[:ttl_sec] = ttl if ttl response = unless identity connection.domain_resource_create(zone.identity, type, options) diff --git a/lib/fog/dns/models/slicehost/record.rb b/lib/fog/dns/models/slicehost/record.rb index 977e3a5f3..f39333217 100644 --- a/lib/fog/dns/models/slicehost/record.rb +++ b/lib/fog/dns/models/slicehost/record.rb @@ -5,11 +5,14 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id attribute :active - attribute :ip, :aliases => 'ip' + attribute :value, :aliases => 'ip' attribute :name attribute :description, :aliases => 'aux' attribute :ttl @@ -43,12 +46,12 @@ module Fog def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity - requires :ip, :name, :type, :zone + requires :name, :type, :value, :zone options = {} options[:active] = active ? 'Y' : 'N' options[:aux] = description if description options[:ttl] = ttl if ttl - data = connection.create_record(type, zone.id, name, ip, options) + data = connection.create_record(type, zone.id, name, value, options) merge_attributes(data.body) true end diff --git a/lib/fog/dns/models/zerigo/record.rb b/lib/fog/dns/models/zerigo/record.rb index 4ad8aa961..6c0f364d6 100644 --- a/lib/fog/dns/models/zerigo/record.rb +++ b/lib/fog/dns/models/zerigo/record.rb @@ -5,11 +5,14 @@ module Fog class DNS class Record < Fog::Model + extend Fog::Deprecation + deprecate :ip, :value + deprecate :ip=, :value= identity :id attribute :created_at, :aliases => 'created-at' - attribute :ip, :aliases => 'data' + attribute :value, :aliases => 'data' attribute :domain, :aliases => 'fqdn' attribute :name, :aliases => 'hostname' attribute :description, :aliases => 'notes' @@ -35,14 +38,14 @@ module Fog end def save - requires :zone, :type, :ip + requires :zone, :type, :value options = {} options[:hostname] = name if name options[:notes] = description if description options[:priority] = priority if priority options[:ttl] = ttl if ttl data = unless identity - connection.create_host(@zone.id, type, ip, options) + connection.create_host(@zone.id, type, value, options) else options[:host_type] = type options[:data] = data diff --git a/tests/dns/models/record_tests.rb b/tests/dns/models/record_tests.rb index db98b606d..c0a2a1260 100644 --- a/tests/dns/models/record_tests.rb +++ b/tests/dns/models/record_tests.rb @@ -3,9 +3,9 @@ for provider, config in dns_providers Shindo.tests("#{provider}::DNS | record", [provider.to_s.downcase]) do record_attributes = { - :ip => '1.2.3.4', - :name => 'www.fogrecordtests.com', - :type => 'A' + :name => 'www.fogrecordtests.com', + :type => 'A', + :value => '1.2.3.4' }.merge!(config[:record_attributes] || {}) if !Fog.mocking? || config[:mocked] diff --git a/tests/dns/models/records_tests.rb b/tests/dns/models/records_tests.rb index 569ff3af2..c84f9b27c 100644 --- a/tests/dns/models/records_tests.rb +++ b/tests/dns/models/records_tests.rb @@ -3,9 +3,9 @@ for provider, config in dns_providers Shindo.tests("#{provider}::DNS | records", [provider.to_s.downcase]) do record_attributes = { - :ip => '1.2.3.4', - :name => 'www.fogrecordstests.com', - :type => 'A' + :name => 'www.fogrecordstests.com', + :type => 'A', + :value => '1.2.3.4' }.merge!(config[:record_attributes] || {}) if !Fog.mocking? || config[:mocked]