From 0c88e3fe63439aa9f16e8cc7850be61c61dbe9ba Mon Sep 17 00:00:00 2001 From: Andreas Gerauer Date: Tue, 11 Dec 2012 17:09:21 +0100 Subject: [PATCH] [rackspace|dns] creating a record now uses specified ttl --- lib/fog/rackspace/models/dns/record.rb | 5 +++++ lib/fog/rackspace/requests/dns/add_records.rb | 6 +++++- tests/rackspace/requests/dns/records_tests.rb | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/fog/rackspace/models/dns/record.rb b/lib/fog/rackspace/models/dns/record.rb index f0e5fc5b8..fc6e5ce2c 100644 --- a/lib/fog/rackspace/models/dns/record.rb +++ b/lib/fog/rackspace/models/dns/record.rb @@ -51,6 +51,10 @@ module Fog :data => value } + if ttl + options[:ttl] = ttl + end + if priority options[:priority] = priority end @@ -80,6 +84,7 @@ module Fog options[:type] = type if type options[:data] = value if value options[:priority] = priority if priority + options[:ttl] = ttl if ttl wait_for_job connection.modify_record(@zone.identity, identity, options).body['jobId'] true diff --git a/lib/fog/rackspace/requests/dns/add_records.rb b/lib/fog/rackspace/requests/dns/add_records.rb index ca43925b9..ee67f4d9b 100644 --- a/lib/fog/rackspace/requests/dns/add_records.rb +++ b/lib/fog/rackspace/requests/dns/add_records.rb @@ -13,7 +13,11 @@ module Fog 'type' => record[:type], 'data' => record[:data] } - + + if record.has_key? :ttl + record_data['ttl'] = record[:ttl] + end + if record.has_key? :priority record_data['priority'] = record[:priority] end diff --git a/tests/rackspace/requests/dns/records_tests.rb b/tests/rackspace/requests/dns/records_tests.rb index fffa5c34f..ea9bb36d4 100644 --- a/tests/rackspace/requests/dns/records_tests.rb +++ b/tests/rackspace/requests/dns/records_tests.rb @@ -12,8 +12,8 @@ Shindo.tests('Fog::DNS[:rackspace] | dns records requests', ['rackspace', 'dns'] Fog::DNS[:rackspace].list_records(@domain_id).body end - tests("add_records(#{@domain_id}, [{ :name => 'test1.#{domain_name}', :type => 'A', :data => '192.168.2.1'}])").formats(RECORD_LIST_FORMAT) do - response = wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].add_records(@domain_id, [{ :name => 'test1.' + domain_name, :type => 'A', :data => '192.168.2.1'}]) + tests("add_records(#{@domain_id}, [{ :name => 'test1.#{domain_name}', :type => 'A', :data => '192.168.2.1', :ttl => 550}])").formats(RECORD_LIST_FORMAT) do + response = wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].add_records(@domain_id, [{ :name => 'test1.' + domain_name, :type => 'A', :data => '192.168.2.1', :ttl => 550}]) @record_id = response.body['response']['records'].first['id'] response.body['response'] end