diff --git a/fog.gemspec b/fog.gemspec
index c0e731502..303be8bcf 100644
--- a/fog.gemspec
+++ b/fog.gemspec
@@ -514,6 +514,7 @@ Gem::Specification.new do |s|
lib/fog/slicehost/parsers/compute/get_images.rb
lib/fog/slicehost/parsers/compute/get_slice.rb
lib/fog/slicehost/parsers/compute/get_slices.rb
+ lib/fog/slicehost/parsers/compute/get_zones.rb
lib/fog/slicehost/requests/compute/create_slice.rb
lib/fog/slicehost/requests/compute/delete_slice.rb
lib/fog/slicehost/requests/compute/get_backups.rb
@@ -523,6 +524,7 @@ Gem::Specification.new do |s|
lib/fog/slicehost/requests/compute/get_images.rb
lib/fog/slicehost/requests/compute/get_slice.rb
lib/fog/slicehost/requests/compute/get_slices.rb
+ lib/fog/slicehost/requests/compute/get_zones.rb
lib/fog/slicehost/requests/compute/reboot_slice.rb
lib/fog/terremark.rb
lib/fog/terremark/bin.rb
diff --git a/lib/fog/slicehost/compute.rb b/lib/fog/slicehost/compute.rb
index 5a467e6bd..88e62fa71 100644
--- a/lib/fog/slicehost/compute.rb
+++ b/lib/fog/slicehost/compute.rb
@@ -24,6 +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
diff --git a/lib/fog/slicehost/parsers/compute/create_record.rb b/lib/fog/slicehost/parsers/compute/create_record.rb
new file mode 100644
index 000000000..5b487e777
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/create_record.rb
@@ -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
diff --git a/lib/fog/slicehost/parsers/compute/create_zone.rb b/lib/fog/slicehost/parsers/compute/create_zone.rb
new file mode 100644
index 000000000..c8c638a2e
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/create_zone.rb
@@ -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
diff --git a/lib/fog/slicehost/parsers/compute/get_record.rb b/lib/fog/slicehost/parsers/compute/get_record.rb
new file mode 100644
index 000000000..32d2e300f
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/get_record.rb
@@ -0,0 +1,26 @@
+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
+end
diff --git a/lib/fog/slicehost/parsers/compute/get_records.rb b/lib/fog/slicehost/parsers/compute/get_records.rb
new file mode 100644
index 000000000..b7822bcdc
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/get_records.rb
@@ -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
diff --git a/lib/fog/slicehost/parsers/compute/get_zone.rb b/lib/fog/slicehost/parsers/compute/get_zone.rb
new file mode 100644
index 000000000..697949680
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/get_zone.rb
@@ -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
diff --git a/lib/fog/slicehost/parsers/compute/get_zones.rb b/lib/fog/slicehost/parsers/compute/get_zones.rb
new file mode 100644
index 000000000..643b67381
--- /dev/null
+++ b/lib/fog/slicehost/parsers/compute/get_zones.rb
@@ -0,0 +1,30 @@
+module Fog
+ module Parsers
+ module Slicehost
+ module Compute
+
+ class GetZones < Fog::Parsers::Base
+
+ def reset
+ @zone = {}
+ @response = { 'zones' => [] }
+ end
+
+ def end_element(name)
+ case name
+ when 'ttl', 'id'
+ @zone[name] = @value.to_i
+ when 'active', 'origin'
+ @zone[name] = @value
+ when 'zone'
+ @response['zones'] << @zone
+ @zone = {}
+ end
+ end
+
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/fog/slicehost/requests/compute/create_record.rb b/lib/fog/slicehost/requests/compute/create_record.rb
new file mode 100644
index 000000000..2580dae21
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/create_record.rb
@@ -0,0 +1,61 @@
+module Fog
+ module Slicehost
+ class Compute
+ class Real
+
+ require 'fog/slicehost/parsers/compute/create_record'
+
+ # 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 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>:
+ # * 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+= "#{value}"
+ when :active
+ optional_tags+= "#{value}"
+ when :aux
+ optional_tags+= "#{value}"
+ end
+ }
+
+ request(
+ :body => %Q{#{record_type}#{zone_id}#{name}#{data}#{optional_tags}},
+ :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
diff --git a/lib/fog/slicehost/requests/compute/create_slice.rb b/lib/fog/slicehost/requests/compute/create_slice.rb
index eb009bef6..d9e33d9a7 100644
--- a/lib/fog/slicehost/requests/compute/create_slice.rb
+++ b/lib/fog/slicehost/requests/compute/create_slice.rb
@@ -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
diff --git a/lib/fog/slicehost/requests/compute/create_zone.rb b/lib/fog/slicehost/requests/compute/create_zone.rb
new file mode 100644
index 000000000..57c392ed3
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/create_zone.rb
@@ -0,0 +1,54 @@
+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)
+ # * 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<~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+= "#{value}"
+ when :active
+ optional_tags+= "#{value}"
+ end
+ }
+
+ request(
+ :body => %Q{#{origin}#{optional_tags}},
+ :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
diff --git a/lib/fog/slicehost/requests/compute/delete_record.rb b/lib/fog/slicehost/requests/compute/delete_record.rb
new file mode 100644
index 000000000..98f8bfb78
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/delete_record.rb
@@ -0,0 +1,31 @@
+module Fog
+ module Slicehost
+ class Compute
+ class Real
+
+ # Delete a record from the specified DNS zone
+ # ==== Parameters
+ # * record_id<~Integer> - Id of DNS record to delete
+ #
+ # ==== Returns
+ # * response<~Excon::Response>: - HTTP status code will be result
+ 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
diff --git a/lib/fog/slicehost/requests/compute/delete_slice.rb b/lib/fog/slicehost/requests/compute/delete_slice.rb
index 548ee3602..55eba0981 100644
--- a/lib/fog/slicehost/requests/compute/delete_slice.rb
+++ b/lib/fog/slicehost/requests/compute/delete_slice.rb
@@ -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,
diff --git a/lib/fog/slicehost/requests/compute/delete_zone.rb b/lib/fog/slicehost/requests/compute/delete_zone.rb
new file mode 100644
index 000000000..5657a2d78
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/delete_zone.rb
@@ -0,0 +1,31 @@
+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>: - HTTP status code will be result
+ 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
diff --git a/lib/fog/slicehost/requests/compute/get_record.rb b/lib/fog/slicehost/requests/compute/get_record.rb
new file mode 100644
index 000000000..7e02f2a27
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/get_record.rb
@@ -0,0 +1,40 @@
+module Fog
+ module Slicehost
+ class Compute
+ class Real
+
+ require 'fog/slicehost/parsers/compute/get_record'
+
+ # Get an individual DNS record from the specified zone
+ #
+ # ==== Returns
+ # * response<~Excon::Response>:
+ # * 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,
+ :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
diff --git a/lib/fog/slicehost/requests/compute/get_records.rb b/lib/fog/slicehost/requests/compute/get_records.rb
new file mode 100644
index 000000000..e4842d7fe
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/get_records.rb
@@ -0,0 +1,41 @@
+module Fog
+ module Slicehost
+ class Compute
+ class Real
+
+ require 'fog/slicehost/parsers/compute/get_records'
+
+ # 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_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
diff --git a/lib/fog/slicehost/requests/compute/get_zone.rb b/lib/fog/slicehost/requests/compute/get_zone.rb
new file mode 100644
index 000000000..94a29fc54
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/get_zone.rb
@@ -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> - 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_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
diff --git a/lib/fog/slicehost/requests/compute/get_zones.rb b/lib/fog/slicehost/requests/compute/get_zones.rb
new file mode 100644
index 000000000..979457070
--- /dev/null
+++ b/lib/fog/slicehost/requests/compute/get_zones.rb
@@ -0,0 +1,37 @@
+module Fog
+ module Slicehost
+ class Compute
+ class Real
+
+ require 'fog/slicehost/parsers/compute/get_zones'
+
+ # Get list of all DNS zones hosted on Slicehost (for this account)
+ #
+ # ==== Returns
+ # * response<~Excon::Response>:
+ # * body<~Array>:
+ # * '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,
+ :method => 'GET',
+ :parser => Fog::Parsers::Slicehost::Compute::GetZones.new,
+ :path => 'zones.xml'
+ )
+ end
+
+ end
+
+ class Mock
+
+ def get_zones
+ Fog::Mock.not_implemented
+ end
+
+ end
+ end
+ end
+end