1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #815 from gscottrw/aws_dns_status

[aws|dns] Support for checking record sync status.
This commit is contained in:
Wesley Beary 2012-03-26 13:44:27 -07:00
commit 0960f8aa38
2 changed files with 31 additions and 0 deletions

View file

@ -17,6 +17,7 @@ module Fog
attribute :status, :aliases => ['Status']
attribute :created_at, :aliases => ['SubmittedAt']
attribute :alias_target, :aliases => ['AliasTarget']
attribute :change_id, :aliases => ['Id']
def initialize(attributes={})
self.ttl ||= 3600
@ -55,6 +56,24 @@ module Fog
true
end
# Returns true if record is insync. May only be called for newly created or modified records that
# have a change_id and status set.
def ready?
requires :change_id, :status
status == 'INSYNC'
end
def reload
# If we have a change_id (newly created or modified), then reload performs a get_change to update status.
if change_id
data = connection.get_change(change_id).body
merge_attributes(data)
self
else
super
end
end
private
def zone=(new_zone)

View file

@ -8,11 +8,23 @@ Shindo.tests("Fog::Dns[:aws] | record", ['aws', 'dns']) do
params = { :name => @zone.domain, :type => 'A', :ttl => 3600, :value => ['1.2.3.4'] }
model_tests(@zone.records, params, false) do
# Newly created records should have a change id
tests("#change_id") do
returns(true) { @instance.change_id != nil }
end
# Waits for changes to sync to all Route 53 DNS servers. Usually takes ~30 seconds to complete.
tests("#ready? - may take a minute to complete...").succeeds do
@instance.wait_for { ready? }
end
tests("#modify") do
new_value = ['5.5.5.5']
returns(true) { @instance.modify(:value => new_value) }
returns(new_value) { @instance.value }
end
end
tests("zones#destroy").succeeds do