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

completed adding all the Slicehost DNS zone functions

can now add/edit/delete zones in the Slicehost DNS service. Includes the methods create_zone, delete_zone, get_zones, get_zone.  Note, there are no mocks or test cases.
This commit is contained in:
Athir Nuaimi 2010-12-09 14:14:48 -05:00
parent 5b50f8b2a8
commit b1ddc8bf7a
7 changed files with 227 additions and 0 deletions

View file

@ -24,7 +24,14 @@ module Fog
request :get_slice
request :get_slices
request :reboot_slice
request :create_zone
request :delete_zone
request :get_zones
request :get_zone
# 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 CreateZone < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'ttl', 'id'
@response[name] = @value.to_i
when 'origin', 'active'
@response[name] = @value
end
end
end
end
end
end
end

View file

@ -0,0 +1,26 @@
module Fog
module Parsers
module Slicehost
module Compute
class GetZone < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'ttl', 'id'
@response[name] = @value.to_i
when 'origin', 'active'
@response[name] = @value
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_zone'
# 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'
#
# ==== 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)
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin><ttl type="integer">#{ttl}</ttl><active>#{active}</active></zone>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Slicehost::Compute::CreateZone.new,
:path => 'zones.xml'
)
end
end
class Mock
def create_zone(origin, ttl, active)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,43 @@
module Fog
module Slicehost
class Compute
class Real
# Delete a zone from Slicehost's DNS
# ==== Parameters
# * zone_id<~Integer> - Id of zone 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
def delete_zone(zone_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "zones/#{zone_id}.xml"
)
end
end
class Mock
def delete_zone(zone_id)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,43 @@
module Fog
module Slicehost
class Compute
class Real
require 'fog/slicehost/parsers/compute/get_records'
# Get list of DNS zones
#
# ==== 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
# * 'name'<~String> - Name of the slice
# * 'progress'<~Integer> - Progress of current action, in percentage
# * 'status'<~String> - Current status of the slice
def get_records
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Slicehost::Compute::GetRecords.new,
:path => 'records.xml'
)
end
end
class Mock
def get_records
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,40 @@
module Fog
module Slicehost
class Compute
class Real
require 'fog/slicehost/parsers/compute/get_zone'
# Get details of a DNS zone
#
# ==== Parameters
# * zone_id<~Integer> - Id of zone to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'origin'<~String> - Name of zone details are being requested of
# * '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
def get_zone(zone_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Slicehost::Compute::GetZone.new,
:path => "/zones/#{zone_id}.xml"
)
end
end
class Mock
def get_zone(zone_id)
Fog::Mock.not_implemented
end
end
end
end
end