mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parent
ea9c82c6f1
commit
4c24e5fe5c
8 changed files with 45 additions and 27 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue