complete work on Slicehost DNS functions. all functions now supported

all DNS functions are now working and tested.
any functions that have optional parameters can now accept these
comments cleaned up
note, no mocks or test cases.  will speak to geemus to learn more about how these work.
This commit is contained in:
Athir Nuaimi 2010-12-10 11:56:49 -05:00
parent 5d78577099
commit 3c69e06f07
10 changed files with 76 additions and 64 deletions

View File

@ -15,6 +15,7 @@ module Fog
@response[name] = @value.to_i
when 'record-type', 'name', 'data', 'active', 'aux'
@response[name] = @value
end
end
end

View File

@ -5,22 +5,41 @@ module Fog
require 'fog/slicehost/parsers/compute/create_record'
# Create a new record in a DNS zone
# Create a new record in a DNS zone - or update an existing one
# ==== 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)
# * zone_id<~Integer> - ID of the zone to update
# * name<~String> - host name this DNS record is for
# * data<~String> - data for the DNS record (ie for an A record, the IP address)
#
# * options<~Hash> - extra parameters that are not mandatory
# * ttl<~Integer> - time to live in seconds
# * active<~String> - whether this record is active or not ('Y' or 'N')
# * aux<~String> - extra data required by the record
# ==== 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)
# * body<~Hash>:
# * 'name'<~String> - as above
# * 'id'<~Integer> - Id of zone/domain - used in future API calls for this zone
# * 'ttl'<~Integer> - as above
# * 'data'<~String> - as above
# * 'active'<~String> - as above
# * 'aux'<~String> - as above
def create_record( record_type, zone_id, name, data, options = {})
optional_tags= ''
options.each { |option, value|
case option
when :ttl
optional_tags+= "<ttl type='integer'>#{value}</ttl>"
when :active
optional_tags+= "<active>#{value}</active>"
when :aux
optional_tags+= "<aux>#{value}</aux>"
end
}
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>},
: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>#{optional_tags}</record>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Slicehost::Compute::CreateRecord.new,

View File

@ -5,7 +5,7 @@ module Fog
require 'fog/slicehost/parsers/compute/create_slice'
# Get list of slices
# Create a new slice
# ==== Parameters
# * flavor_id<~Integer> - Id of flavor to create slice with
# * image_id<~Integer> - Id of image to create slice with
@ -13,7 +13,7 @@ module Fog
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * body<~Hash>:
# * '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

View File

@ -8,19 +8,31 @@ module Fog
# Create a new zone for Slicehost's DNS servers to serve/host
# ==== Parameters
# * origin<~String> - domain name to host (ie example.com)
# * ttl<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
# * active<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
# * options<~Hash> - optional paramaters
# * ttl<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
# * active<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'origin'<~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_zone(origin, ttl, active)
# * body<~Hash>:
# * 'origin'<~String> - as above
# * 'id'<~Integer> - Id of zone/domain - used in future API calls
# * 'ttl'<~Integer> - as above
# * 'active'<~String> - as above
def create_zone(origin, options = {})
optional_tags= ''
options.each { |option, value|
case option
when :ttl
optional_tags+= "<ttl type='interger'>#{value}</ttl>"
when :active
optional_tags+= "<active>#{value}</active>"
end
}
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin><ttl type="integer">#{ttl}</ttl><active>#{active}</active></zone>},
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin>#{optional_tags}</zone>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Slicehost::Compute::CreateZone.new,

View File

@ -3,12 +3,12 @@ module Fog
class Compute
class Real
# Delete a record from DNS zone
# Delete a record from the specified DNS zone
# ==== Parameters
# * record_id<~Integer> - Id of DNS record to delete
#
# ==== Returns
# * response<~Excon::Response>:
# * response<~Excon::Response>: - HTTP status code will be result
def delete_record(record_id)
request(
:expects => 200,

View File

@ -3,26 +3,12 @@ module Fog
class Compute
class Real
# Get list of slices
# Delete a given slice
# ==== Parameters
# * flavor_id<~Integer> - Id of flavor to create slice with
# * image_id<~Integer> - Id of image to create slice with
# * name<~String> - Name of slice
# * slice_id<~Integer> - Id of slice to delete
#
# ==== 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
# * response<~Excon::Response>: - HTTP status code is the return value
def delete_slice(slice_id)
request(
:expects => 200,

View File

@ -8,8 +8,7 @@ module Fog
# * zone_id<~Integer> - Id of zone to delete
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * response<~Excon::Response>: - HTTP status code will be result
def delete_zone(zone_id)
request(
:expects => 200,

View File

@ -5,19 +5,18 @@ module Fog
require 'fog/slicehost/parsers/compute/get_record'
# Get all the DNS records across all the DNS zones for this account
# Get an individual DNS record from the specified zone
#
# ==== 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
# * body<~Hash>:
# * 'record_type'<~String> - type of DNS record to create (A, CNAME, etc)
# * 'zone_id'<~Integer> - ID of the zone to update
# * 'name'<~String> - host name this DNS record is for
# * 'data'<~String> - data for the DNS record (ie for an A record, the IP address)
# * 'ttl'<~Integer> - time to live in seconds
# * 'active'<~String> - whether this record is active or not ('Y' or 'N')
# * 'aux'<~String> - extra data required by the record
def get_record( record_id)
request(
:expects => 200,

View File

@ -13,10 +13,10 @@ module Fog
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'origin'<~String> - Name of zone details are being requested of
# * 'origin'<~String> - domain name to host (ie example.com)
# * 'id'<~Integer> - Id of the zone
# * 'ttl'<~Integer> - TimeToLive (ttl) for the zone
# * 'active'<~String> - 'Y' or 'N' - if the zone is active or disabled
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
def get_zone(zone_id)
request(
:expects => 200,

View File

@ -5,19 +5,15 @@ module Fog
require 'fog/slicehost/parsers/compute/get_zones'
# Get list of DNS zones
# Get list of all DNS zones hosted on Slicehost (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
# * 'origin'<~String> - domain name to host (ie example.com)
# * 'id'<~Integer> - Id of the zone
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
def get_zones
request(
:expects => 200,