2010-12-22 23:36:53 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class Zerigo
|
2010-12-22 23:36:53 -05:00
|
|
|
|
|
|
|
class Record < Fog::Model
|
2011-05-27 13:30:20 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate :ip, :value
|
|
|
|
deprecate :ip=, :value=
|
2010-12-22 23:36:53 -05:00
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :created_at, :aliases => 'created-at'
|
2011-05-27 13:30:20 -04:00
|
|
|
attribute :value, :aliases => 'data'
|
2010-12-22 23:36:53 -05:00
|
|
|
attribute :domain, :aliases => 'fqdn'
|
|
|
|
attribute :name, :aliases => 'hostname'
|
2010-12-23 19:47:47 -05:00
|
|
|
attribute :description, :aliases => 'notes'
|
2010-12-22 23:36:53 -05:00
|
|
|
attribute :priority
|
|
|
|
attribute :ttl
|
|
|
|
attribute :type, :aliases => 'host-type'
|
|
|
|
attribute :updated_at, :aliases => 'updated-at'
|
|
|
|
attribute :zone_id, :aliases => 'zone-id'
|
|
|
|
|
2010-12-23 18:36:08 -05:00
|
|
|
def initialize(attributes={})
|
|
|
|
self.ttl ||= 3600
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2010-12-22 23:36:53 -05:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
|
|
|
connection.delete_host(identity)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2011-05-27 13:30:20 -04:00
|
|
|
requires :zone, :type, :value
|
2010-12-22 23:36:53 -05:00
|
|
|
options = {}
|
|
|
|
options[:hostname] = name if name
|
2011-01-03 18:39:38 -05:00
|
|
|
options[:notes] = description if description
|
2010-12-22 23:36:53 -05:00
|
|
|
options[:priority] = priority if priority
|
|
|
|
options[:ttl] = ttl if ttl
|
2012-01-08 21:21:56 -05:00
|
|
|
|
|
|
|
if identity
|
2010-12-23 17:21:05 -05:00
|
|
|
options[:host_type] = type
|
2011-10-09 11:49:50 -04:00
|
|
|
options[:data] = value
|
2010-12-23 17:21:05 -05:00
|
|
|
connection.update_host(identity, options)
|
2012-01-08 21:21:56 -05:00
|
|
|
else
|
|
|
|
data = connection.create_host(@zone.id, type, value, options)
|
|
|
|
merge_attributes(data.body)
|
2010-12-23 17:21:05 -05:00
|
|
|
end
|
2012-01-08 21:21:56 -05:00
|
|
|
|
2010-12-22 23:36:53 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2012-01-08 21:21:56 -05:00
|
|
|
|
2010-12-22 23:36:53 -05:00
|
|
|
def zone=(new_zone)
|
|
|
|
@zone = new_zone
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|