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

added support for managing DNS records through Slicehost

added for functions that work on DNS records.  The full Slicehost DNS API is now supported.
This commit is contained in:
Athir Nuaimi 2010-12-09 16:12:32 -05:00
parent b1ddc8bf7a
commit 5d78577099
10 changed files with 201 additions and 21 deletions

View file

@ -28,10 +28,10 @@ module Fog
request :delete_zone
request :get_zones
request :get_zone
# request :create_record
# request :delete_record
# request :get_records
# request :get_record
request :create_record
request :delete_record
request :get_records
request :get_record
class Mock

View file

@ -0,0 +1,26 @@
module Fog
module Parsers
module Slicehost
module Compute
class CreateRecord < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'zone-id', 'ttl', 'id'
@response[name] = @value.to_i
when 'record-type', 'name', 'data', 'active', 'aux'
@response[name] = @value
end
end
end
end
end
end
end

View file

@ -0,0 +1,25 @@
module Fog
module Parsers
module Slicehost
module Compute
class GetRecord < Fog::Parsers::Base
def reset
@response = { }
end
def end_element(name)
case name
when 'zone-id', 'ttl'
@response[name] = @value.to_i
when 'record-type', 'name', 'data', 'active', 'aux'
@response[name] = @value
end
end
end
end
end
end

View file

@ -0,0 +1,30 @@
module Fog
module Parsers
module Slicehost
module Compute
class GetRecords < Fog::Parsers::Base
def reset
@record = {}
@response = { 'records' => [] }
end
def end_element(name)
case name
when 'zone-id', 'ttl'
@record[name] = @value.to_i
when 'record-type', 'name', 'data', 'active', 'aux'
@record[name] = @value
when 'record'
@response['records'] << @record
@record = {}
end
end
end
end
end
end
end

View file

@ -0,0 +1,42 @@
module Fog
module Slicehost
class Compute
class Real
require 'fog/slicehost/parsers/compute/create_record'
# Create a new record in a DNS zone
# ==== Parameters
# * record_type<~String> - type of DNS record to create (A, CNAME, etc)
# * zone_id<~Integer> - ID of the zone record should be a part of
# * name<~String> - DNS name record should be for (ie for an A record, the host name)
# * data<~String> - data for the DNS record (ie for an A record, the IP address)
#
# ==== Returns
# * response<~Excon::Response>:
# * 'name'<~String> - domain added
# * 'id'<~Integer> - Id of zone/domain
# * 'ttl'<~Integer> - TimeToLive for zone (how long client can cache)
# * 'active'<~String> - whether zone is active or disabled
def create_record( record_type, zone_id, name, data)
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><record_type>#{record_type}</record_type><zone_id type="integer">#{zone_id}</zone_id><name>#{name}</name><data>#{data}</data></record>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Slicehost::Compute::CreateRecord.new,
:path => 'records.xml'
)
end
end
class Mock
def create_record( record_type, zone_id, name, data)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,31 @@
module Fog
module Slicehost
class Compute
class Real
# Delete a record from DNS zone
# ==== Parameters
# * record_id<~Integer> - Id of DNS record to delete
#
# ==== Returns
# * response<~Excon::Response>:
def delete_record(record_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "records/#{record_id}.xml"
)
end
end
class Mock
def delete_record(record_id)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -10,17 +10,6 @@ module Fog
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'addresses'<~Array> - Ip addresses for the slice
# * 'backup-id'<~Integer> - Id of backup slice was booted from
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
# * 'id'<~Integer> - Id of the slice
# * 'image-id'<~Integer> - Id of image slice was booted from
# * 'name'<~String> - Name of the slice
# * 'progress'<~Integer> - Progress of current action, in percentage
# * 'root-password'<~String> - Root password of slice
# * 'status'<~String> - Current status of the slice
def delete_zone(zone_id)
request(
:expects => 200,

View file

@ -0,0 +1,41 @@
module Fog
module Slicehost
class Compute
class Real
require 'fog/slicehost/parsers/compute/get_record'
# Get all the DNS records across all the DNS zones for this account
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'addresses'<~Array> - Ip addresses for the slice
# * 'backup-id'<~Integer> - Id of backup slice was booted from
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
# * 'id'<~Integer> - Id of the slice
# * 'image-id'<~Integer> - Id of image slice was booted from
# * 'name'<~String> - Name of the slice
# * 'progress'<~Integer> - Progress of current action, in percentage
# * 'status'<~String> - Current status of the slice
def get_record( record_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Slicehost::Compute::GetRecords.new,
:path => "records/#{record_id}.xml"
)
end
end
class Mock
def get_record(record_id)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -5,15 +5,13 @@ module Fog
require 'fog/slicehost/parsers/compute/get_records'
# Get list of DNS zones
# Get all the DNS records across all the DNS zones for this account
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'addresses'<~Array> - Ip addresses for the slice
# * 'backup-id'<~Integer> - Id of backup slice was booted from
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
# * 'id'<~Integer> - Id of the slice
# * 'image-id'<~Integer> - Id of image slice was booted from
@ -25,7 +23,7 @@ module Fog
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Slicehost::Compute::GetRecords.new,
:path => 'records.xml'
:path => "records.xml"
)
end

View file

@ -12,8 +12,6 @@ module Fog
# * body<~Array>:
# * 'addresses'<~Array> - Ip addresses for the slice
# * 'backup-id'<~Integer> - Id of backup slice was booted from
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
# * 'id'<~Integer> - Id of the slice
# * 'image-id'<~Integer> - Id of image slice was booted from