[slicehost] remove (now deprecated) slicehost support

This commit is contained in:
geemus 2012-05-28 15:05:40 -05:00
parent cca977fa2d
commit 4c453a84b1
61 changed files with 1 additions and 2285 deletions

View File

@ -75,7 +75,6 @@ require 'fog/bin/ninefold'
require 'fog/bin/rackspace'
require 'fog/bin/openstack'
require 'fog/bin/ovirt'
require 'fog/bin/slicehost'
require 'fog/bin/stormondemand'
require 'fog/bin/terremark'
require 'fog/bin/vcloud'

View File

@ -1,36 +0,0 @@
class Slicehost < Fog::Bin
class << self
def class_for(key)
case key
when :compute
Fog::Compute::Slicehost
when :dns
Fog::DNS::Slicehost
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Logger.warning("Slicehost[:compute] is not recommended, use Compute[:slicehost] for portability")
Fog::Compute.new(:provider => 'Slicehost')
when :dns
Fog::Logger.warning("Slicehost[:dns] is deprecated, use Storage[:slicehost] instead")
Fog::DNS.new(:provider => 'Slicehost')
else
raise ArgumentError, "Unrecognized service: #{key.inspect}"
end
end
@@connections[service]
end
def services
Fog::Slicehost.services
end
end
end

View File

@ -66,10 +66,6 @@ module Fog
when :rackspace
require 'fog/rackspace/compute'
Fog::Compute::Rackspace.new(attributes)
when :slicehost
warn "[DEPRECATION] `slicehost` is deprecated. Please use `rackspace` instead."
require 'fog/slicehost/compute'
Fog::Compute::Slicehost.new(attributes)
when :stormondemand
require 'fog/storm_on_demand/compute'
Fog::Compute::StormOnDemand.new(attributes)

View File

@ -65,7 +65,6 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
:rackspace_username:
:rackspace_servicenet:
:rackspace_cdn_ssl:
:slicehost_password:
:stormondemand_username:
:stormondemand_password:
:terremark_username:

View File

@ -26,10 +26,6 @@ module Fog
when :linode
require 'fog/linode/dns'
Fog::DNS::Linode.new(attributes)
when :slicehost
warn "[DEPRECATION] `slicehost` is deprecated. Please use `racksace` instead."
require 'fog/slicehost/dns'
Fog::DNS::Slicehost.new(attributes)
when :zerigo
require 'fog/zerigo/dns'
Fog::DNS::Zerigo.new(attributes)

View File

@ -21,7 +21,6 @@ require 'fog/ninefold'
require 'fog/rackspace'
require 'fog/openstack'
require 'fog/ovirt'
require 'fog/slicehost'
require 'fog/storm_on_demand'
require 'fog/vcloud'
require 'fog/virtual_box'

View File

@ -1,12 +0,0 @@
require 'fog/core'
module Fog
module Slicehost
extend Fog::Provider
service(:compute, 'slicehost/compute', 'Compute')
service(:dns, 'slicehost/dns', 'DNS')
end
end

View File

@ -1,104 +0,0 @@
require 'fog/slicehost'
require 'fog/compute'
module Fog
module Compute
class Slicehost < Fog::Service
requires :slicehost_password
recognizes :host, :port, :scheme, :persistent
model_path 'fog/slicehost/models/compute'
model :flavor
collection :flavors
model :image
collection :images
model :server
collection :servers
request_path 'fog/slicehost/requests/compute'
request :create_slice
request :delete_slice
request :get_backups
request :get_flavor
request :get_flavors
request :get_image
request :get_images
request :get_slice
request :get_slices
request :reboot_slice
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {}
end
end
def self.reset
@data = nil
end
def initialize(options={})
@slicehost_password = options[:slicehost_password]
end
def data
self.class.data[@slicehost_password]
end
def reset_data
self.class.data.delete(@slicehost_password)
end
end
class Real
def initialize(options={})
require 'fog/core/parser'
@slicehost_password = options[:slicehost_password]
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.slicehost.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload
@connection.reset
end
def request(params)
params[:headers] ||= {}
params[:headers].merge!({
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}"
})
case params[:method]
when 'DELETE', 'GET', 'HEAD'
params[:headers]['Accept'] = 'application/xml'
when 'POST', 'PUT'
params[:headers]['Content-Type'] = 'application/xml'
end
begin
response = @connection.request(params.merge!({:host => @host}))
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Compute::Slicehost::NotFound.slurp(error)
else
error
end
end
response
end
end
end
end
end

View File

@ -1,101 +0,0 @@
require 'fog/slicehost'
require 'fog/dns'
module Fog
module DNS
class Slicehost < Fog::Service
requires :slicehost_password
recognizes :host, :port, :scheme, :persistent
model_path 'fog/slicehost/models/dns'
model :record
collection :records
model :zone
collection :zones
request_path 'fog/slicehost/requests/dns'
request :create_record
request :create_zone
request :delete_record
request :delete_zone
request :get_record
request :get_records
request :get_zone
request :get_zones
request :update_record
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {}
end
end
def self.reset
@data = nil
end
def initialize(options={})
@slicehost_password = options[:slicehost_password]
end
def data
self.class.data[@slicehost_password]
end
def reset_data
self.class.data.delete(@slicehost_password)
end
end
class Real
def initialize(options={})
require 'fog/core/parser'
@slicehost_password = options[:slicehost_password]
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.slicehost.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload
@connection.reset
end
def request(params)
params[:headers] ||= {}
params[:headers].merge!({
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}"
})
case params[:method]
when 'DELETE', 'GET', 'HEAD'
params[:headers]['Accept'] = 'application/xml'
when 'POST', 'PUT'
params[:headers]['Content-Type'] = 'application/xml'
end
begin
response = @connection.request(params.merge!({:host => @host}))
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::DNS::Slicehost::NotFound.slurp(error)
else
error
end
end
response
end
end
end
end
end

View File

@ -1,45 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class Slicehost
class Flavor < Fog::Model
identity :id
attribute :name
attribute :price
attribute :ram
def bits
# 64
raise StandardError.new("Figure me out!?!")
end
def cores
# # 2 quad-cores >= 2Ghz = 8 cores
# 8 * case ram
# when 256
# 1/64.0
# when 512
# 1/32.0
# when 1024
# 1/16.0
# when 2048
# 1/8.0
# when 4096
# 1/4.0
# when 8192
# 1/2.0
# when 15872
# 1
# end
raise StandardError.new("Figure me out!?!")
end
end
end
end
end

View File

@ -1,28 +0,0 @@
require 'fog/core/collection'
require 'fog/slicehost/models/compute/flavor'
module Fog
module Compute
class Slicehost
class Flavors < Fog::Collection
model Fog::Compute::Slicehost::Flavor
def all
data = connection.get_flavors.body['flavors']
load(data)
end
def get(flavor_id)
data = connection.get_flavor(flavor_id).body
new(data)
rescue Excon::Errors::Forbidden
nil
end
end
end
end
end

View File

@ -1,17 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class Slicehost
class Image < Fog::Model
identity :id
attribute :name
end
end
end
end

View File

@ -1,27 +0,0 @@
require 'fog/core/collection'
require 'fog/slicehost/models/compute/image'
module Fog
module Compute
class Slicehost
class Images < Fog::Collection
model Fog::Compute::Slicehost::Image
def all
data = connection.get_images.body['images']
load(data)
end
def get(image_id)
connection.get_image(image_id)
rescue Excon::Errors::Forbidden
nil
end
end
end
end
end

View File

@ -1,113 +0,0 @@
require 'fog/compute/models/server'
module Fog
module Compute
class Slicehost
class Server < Fog::Compute::Server
identity :id
attribute :addresses
attribute :backup_id, :aliases => 'backup-id'
attribute :bandwidth_in, :aliases => 'bw-in'
attribute :bandwidth_out, :aliases => 'bw-out'
attribute :flavor_id, :aliases => 'flavor-id'
attribute :image_id, :aliases => 'image-id'
attribute :name
attribute :progress
attribute :state, :aliases => 'status'
attr_accessor :password
alias_method :'root-password=', :password=
attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
def initialize(attributes={})
self.flavor_id ||= 1 # 256 server
self.image_id ||= 49 # Ubuntu 10.04 LTS 64bit
super
end
def destroy
requires :id
connection.delete_slice(id)
true
end
def flavor
requires :flavor_id
connection.flavors.get(flavor_id)
end
def image
requires :image_id
connection.images.get(image_id)
end
def private_ip_address
nil
end
def private_key_path
@private_key_path ||= Fog.credentials[:private_key_path]
@private_key_path &&= File.expand_path(@private_key_path)
end
def private_key
@private_key ||= private_key_path && File.read(private_key_path)
end
def public_ip_address
addresses.first
end
def public_key_path
@public_key_path ||= Fog.credentials[:public_key_path]
@public_key_path &&= File.expand_path(@public_key_path)
end
def public_key
@public_key ||= public_key_path && File.read(public_key_path)
end
def ready?
self.state == 'active'
end
def reboot(type = 'SOFT')
requires :id
connection.reboot_slice(id, type)
true
end
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
requires :flavor_id, :image_id, :name
data = connection.create_slice(flavor_id, image_id, name)
merge_attributes(data.body)
true
end
def setup(credentials = {})
requires :addresses, :identity, :public_key, :username
Fog::SSH.new(addresses.first, username, credentials).run([
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l #{username}},
%{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}
])
rescue Errno::ECONNREFUSED
sleep(1)
retry
end
def username
@username ||= 'root'
end
end
end
end
end

View File

@ -1,38 +0,0 @@
require 'fog/core/collection'
require 'fog/slicehost/models/compute/server'
module Fog
module Compute
class Slicehost
class Servers < Fog::Collection
model Fog::Compute::Slicehost::Server
def all
data = connection.get_slices.body['slices']
load(data)
end
def bootstrap(new_attributes = {})
server = create(new_attributes)
server.wait_for { ready? }
server.setup(:password => server.password)
server
end
def get(server_id)
if server_id && server = connection.get_slice(server_id).body
new(server)
elsif !server_id
nil
end
rescue Excon::Errors::Forbidden
nil
end
end
end
end
end

View File

@ -1,73 +0,0 @@
require 'fog/core/model'
module Fog
module DNS
class Slicehost
class Record < Fog::Model
extend Fog::Deprecation
deprecate :ip, :value
deprecate :ip=, :value=
identity :id
attribute :active
attribute :value, :aliases => ['ip', 'data']
attribute :name
attribute :description, :aliases => 'aux'
attribute :ttl
attribute :type, :aliases => 'record_type'
attribute :zone_id
def initialize(attributes={})
self.active ||= true
self.ttl ||= 3600
super
end
def active=(new_active)
attributes[:active] = case new_active
when false, 'N'
false
when true, 'Y'
true
end
end
def destroy
requires :identity
connection.delete_record(identity)
true
end
def zone
@zone
end
def save
requires :name, :type, :value, :zone
options = {}
options[:active] = active ? 'Y' : 'N'
options[:aux] = description if description
options[:ttl] = ttl if ttl
if identity
data = connection.update_record(identity, type, zone.id, name, value, options)
else
data = connection.create_record(type, zone.id, name, value, options)
end
merge_attributes(data.body)
true
end
private
def zone=(new_zone)
@zone = new_zone
end
end
end
end
end

View File

@ -1,36 +0,0 @@
require 'fog/core/collection'
require 'fog/slicehost/models/dns/record'
module Fog
module DNS
class Slicehost
class Records < Fog::Collection
attribute :zone
model Fog::DNS::Slicehost::Record
def all
requires :zone
data = connection.get_records.body['records']
load(data).reject {|record| record.zone_id != zone.id}
end
def get(record_id)
data = connection.get_record(record_id).body
new(data)
rescue Excon::Errors::Forbidden
nil
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
end
end
end
end
end

View File

@ -1,69 +0,0 @@
require 'fog/core/model'
require 'fog/slicehost/models/dns/records'
module Fog
module DNS
class Slicehost
class Zone < Fog::Model
identity :id
attribute :active
attribute :domain, :aliases => 'origin'
attribute :ttl
def initialize(attributes={})
self.active ||= true
self.ttl ||= 3600
super
end
def active=(new_active)
attributes[:active] = case new_active
when false, 'N'
false
when true, 'Y'
true
end
end
def destroy
requires :identity
connection.delete_zone(identity)
true
end
def records
@records ||= begin
Fog::DNS::Slicehost::Records.new(
:zone => self,
:connection => connection
).all
end
end
def nameservers
[
'ns1.slicehost.net',
'ns2.slicehost.net',
'ns3.slicehost.net'
]
end
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
requires :active, :domain, :ttl
options = {}
options[:active] = active ? 'Y' : 'N'
options[:ttl] = ttl
data = connection.create_zone(domain, options)
merge_attributes(data.body)
true
end
end
end
end
end

View File

@ -1,28 +0,0 @@
require 'fog/core/collection'
require 'fog/slicehost/models/dns/zone'
module Fog
module DNS
class Slicehost
class Zones < Fog::Collection
model Fog::DNS::Slicehost::Zone
def all
data = connection.get_zones.body['zones']
load(data)
end
def get(zone_id)
data = connection.get_zone(zone_id).body
new(data)
rescue Excon::Errors::Forbidden
nil
end
end
end
end
end

View File

@ -1,31 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class CreateSlice < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'address'
@response['addresses'] ||= []
@response['addresses'] << value
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
@response[name] = value.to_i
when 'bw-in', 'bw-out'
@response[name] = value.to_f
when 'name', 'root-password', 'status'
@response[name] = value
end
end
end
end
end
end
end

View File

@ -1,32 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetBackups < Fog::Parsers::Base
def reset
@backup = {}
@response = { 'backups' => [] }
end
def end_element(name)
case name
when 'backup'
@response['backups'] << @backup
@backup = {}
when 'date'
@backup[name] = Time.parse(value)
when 'id', 'slice-id'
@backup[name] = value.to_i
when 'name'
@backup[name] = value
end
end
end
end
end
end
end

View File

@ -1,26 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetFlavor < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'id', 'price', 'ram'
@response[name] = value.to_i
when 'name'
@response[name] = value
end
end
end
end
end
end
end

View File

@ -1,30 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetFlavors < Fog::Parsers::Base
def reset
@flavor = {}
@response = { 'flavors' => [] }
end
def end_element(name)
case name
when 'flavor'
@response['flavors'] << @flavor
@flavor = {}
when 'id', 'price', 'ram'
@flavor[name] = value.to_i
when 'name'
@flavor[name] = value
end
end
end
end
end
end
end

View File

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

View File

@ -1,30 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetImages < Fog::Parsers::Base
def reset
@image = {}
@response = { 'images' => [] }
end
def end_element(name)
case name
when 'id'
@image[name] = value.to_i
when 'image'
@response['images'] << @image
@image = {}
when 'name'
@image[name] = value
end
end
end
end
end
end
end

View File

@ -1,31 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetSlice < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'address'
@response['addresses'] ||= []
@response['addresses'] << value
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
@response[name] = value.to_i
when 'bw-in', 'bw-out'
@response[name] = value.to_f
when 'name', 'status'
@response[name] = value
end
end
end
end
end
end
end

View File

@ -1,35 +0,0 @@
module Fog
module Parsers
module Compute
module Slicehost
class GetSlices < Fog::Parsers::Base
def reset
@slice = {}
@response = { 'slices' => [] }
end
def end_element(name)
case name
when 'address'
@slice['addresses'] ||= []
@slice['addresses'] << value
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
@slice[name] = value.to_i
when 'bw-in', 'bw-out'
@slice[name] = value.to_f
when 'name', 'status'
@slice[name] = value
when 'slice'
@response['slices'] << @slice
@slice = {}
end
end
end
end
end
end
end

View File

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

View File

@ -1,26 +0,0 @@
module Fog
module Parsers
module DNS
module Slicehost
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

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

View File

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

View File

@ -1,26 +0,0 @@
module Fog
module Parsers
module DNS
module Slicehost
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

@ -1,30 +0,0 @@
module Fog
module Parsers
module DNS
module Slicehost
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

View File

@ -1,41 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/create_slice'
# 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
# * name<~String> - Name of slice
#
# ==== Returns
# * response<~Excon::Response>:
# * 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
# * '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 create_slice(flavor_id, image_id, name)
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><slice><flavor-id type="integer">#{flavor_id}</flavor-id><image-id type="integer">#{image_id}</image-id><name>#{name}</name></slice>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Compute::Slicehost::CreateSlice.new,
:path => 'slices.xml'
)
end
end
end
end
end

View File

@ -1,23 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
# Delete a given slice
# ==== Parameters
# * slice_id<~Integer> - Id of slice to delete
#
# ==== Returns
# * response<~Excon::Response>: - HTTP status code is the return value
def delete_slice(slice_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "slices/#{slice_id}.xml"
)
end
end
end
end
end

View File

@ -1,29 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_backups'
# Get list of backups
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'date'<~Time> - Timestamp of backup creation
# * 'id'<~Integer> - Id of the backup
# * 'name'<~String> - Name of the backup
# * 'slice-id'<~Integer> - Id of slice the backup was made from
def get_backups
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetBackups.new,
:path => 'backups.xml'
)
end
end
end
end
end

View File

@ -1,32 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_flavor'
# Get details of a flavor
#
# ==== Parameters
# * flavor_id<~Integer> - Id of flavor to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'id'<~Integer> - Id of the flavor
# * 'name'<~String> - Name of the flavor
# * 'price'<~Integer> - Price in cents
# * 'ram'<~Integer> - Amount of ram for the flavor
def get_flavor(flavor_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetFlavor.new,
:path => "flavors/#{flavor_id}.xml"
)
end
end
end
end
end

View File

@ -1,29 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_flavors'
# Get list of flavors
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'id'<~Integer> - Id of the flavor
# * 'name'<~String> - Name of the flavor
# * 'price'<~Integer> - Price in cents
# * 'ram'<~Integer> - Amount of ram for the flavor
def get_flavors
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetFlavors.new,
:path => 'flavors.xml'
)
end
end
end
end
end

View File

@ -1,30 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_image'
# Get details of an image
#
# ==== Parameters
# * image_id<~Integer> - Id of image to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'id'<~Integer> - Id of the image
# * 'name'<~String> - Name of the image
def get_image(image_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetImage.new,
:path => "images/#{image_id}.xml"
)
end
end
end
end
end

View File

@ -1,27 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_images'
# Get list of images
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'id'<~Integer> - Id of the image
# * 'name'<~String> - Name of the image
def get_images
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetImages.new,
:path => 'images.xml'
)
end
end
end
end
end

View File

@ -1,38 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_slice'
# Get details of a slice
#
# ==== Parameters
# * slice_id<~Integer> - Id of slice to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * '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_slice(slice_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetSlice.new,
:path => "/slices/#{slice_id}.xml"
)
end
end
end
end
end

View File

@ -1,35 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
require 'fog/slicehost/parsers/compute/get_slices'
# Get list of slices
#
# ==== 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_slices
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Compute::Slicehost::GetSlices.new,
:path => 'slices.xml'
)
end
end
end
end
end

View File

@ -1,36 +0,0 @@
module Fog
module Compute
class Slicehost
class Real
# Reboot slice
# ==== Parameters
# * slice_id<~Integer> - Id of server to reboot
# * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * '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 reboot_slice(slice_id, type = 'SOFT')
request(
:expects => 200,
:method => 'PUT',
:parser => Fog::Parsers::Compute::Slicehost::GetSlice.new,
:path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml"
)
end
end
end
end
end

View File

@ -1,52 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/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+= "<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>#{optional_tags}</record>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::DNS::Slicehost::CreateRecord.new,
:path => 'records.xml'
)
end
end
end
end
end

View File

@ -1,46 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/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+= "<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>#{optional_tags}</zone>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::DNS::Slicehost::CreateZone.new,
:path => 'zones.xml'
)
end
end
end
end
end

View File

@ -1,23 +0,0 @@
module Fog
module DNS
class Slicehost
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
end
end
end

View File

@ -1,23 +0,0 @@
module Fog
module DNS
class Slicehost
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
end
end
end

View File

@ -1,32 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/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::DNS::Slicehost::GetRecord.new,
:path => "records/#{record_id}.xml"
)
end
end
end
end
end

View File

@ -1,32 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/get_records'
# Get all the DNS records across all the DNS zones for this account
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'name'<~String> - Record NAME field (e.g. "example.org." or "www")
# * 'data'<~String> - Data contained by the record (e.g. an IP address, for A records)
# * 'record_type'<~String> - Type of record (A, CNAME, TXT, etc)
# * 'aux'<~String> - Aux data for the record, for those types which have it (e.g. TXT)
# * 'zone_id'<~Integer> - zone ID to which this record belongs
# * 'active'<~String> - whether this record is active in the Slicehost DNS (Y for yes, N for no)
# * 'ttl'<~Integer> - TTL in seconds
def get_records
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::DNS::Slicehost::GetRecords.new,
:path => "records.xml"
)
end
end
end
end
end

View File

@ -1,32 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/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::DNS::Slicehost::GetZone.new,
:path => "/zones/#{zone_id}.xml"
)
end
end
end
end
end

View File

@ -1,30 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
require 'fog/slicehost/parsers/dns/get_zones'
# Get list of all DNS zones hosted on Slicehost (for this account)
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'zones'<~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::DNS::Slicehost::GetZones.new,
:path => 'zones.xml'
)
end
end
end
end
end

View File

@ -1,43 +0,0 @@
module Fog
module DNS
class Slicehost
class Real
#require 'fog/slicehost/parsers/dns/update_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 update_record(record_id, 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>#{optional_tags}</record>},
:expects => 200,
:method => 'PUT',
:path => "records/#{record_id}.xml"
)
end
end
end
end
end

View File

@ -64,13 +64,6 @@ def compute_providers
},
:mocked => true
},
:slicehost => {
:server_attributes => {
:image_id => 49, # image 49 = Ubuntu 10.04 LTS (lucid)
:name => "fog_#{Time.now.to_i}"
},
:mocked => false
},
:voxel => {
:server_attributes => {
:name => "fog.#{Time.now.to_i}",

View File

@ -27,9 +27,6 @@ def dns_providers
:email => 'fog@example.com'
}
},
:slicehost => {
:mocked => false
},
:zerigo => {
:mocked => false
},

View File

@ -12,7 +12,7 @@ def array_differences(array_a, array_b)
end
# check to see which credentials are available and add others to the skipped tags list
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'hp', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'zerigo']
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'hp', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'rackspace', 'stormondemand', 'voxel', 'zerigo']
available_providers = Fog.available_providers.map {|provider| provider.downcase}
for provider in (all_providers - available_providers)
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")

View File

@ -58,7 +58,6 @@ if Fog.mock?
:libvirt_uri => 'qemu://libvirt/system',
:rackspace_api_key => 'rackspace_api_key',
:rackspace_username => 'rackspace_username',
:slicehost_password => 'slicehost_password',
:storm_on_demand_username => 'storm_on_demand_username',
:storm_on_demand_password => 'storm_on_demand_password',
:vcloud_host => 'vcloud_host',

View File

@ -1,18 +0,0 @@
Shindo.tests('Fog::Compute[:slicehost] | backup requests', ['slicehost']) do
@backup_format = {
'date' => String,
'id' => Integer,
'name' => String,
'slice-id' => Integer
}
tests('success') do
tests('#get_backups').formats({ 'backups' => [@backup_format] }) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_backups.body
end
end
end

View File

@ -1,33 +0,0 @@
Shindo.tests('Fog::Compute[:slicehost] | flavor requests', ['slicehost']) do
@flavor_format = {
'id' => Integer,
'name' => String,
'price' => Integer,
'ram' => Integer
}
tests('success') do
tests('#get_flavor(1)').formats(@flavor_format) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_flavor(1).body
end
tests('#get_flavors').formats({ 'flavors' => [@flavor_format] }) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_flavors.body
end
end
tests('failure') do
tests('#get_flavor(0)').raises(Excon::Errors::Forbidden) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_flavor(0)
end
end
end

View File

@ -1,31 +0,0 @@
Shindo.tests('Fog::Compute[:slicehost] | image requests', ['slicehost']) do
@image_format = {
'id' => Integer,
'name' => String
}
tests('success') do
tests('#get_image(19)').formats(@image_format) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_image(19).body
end
tests('#get_images').formats({ 'images' => [@image_format] }) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_images.body
end
end
tests('failure') do
tests('#get_image(0)').raises(Excon::Errors::Forbidden) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_image(0)
end
end
end

View File

@ -1,75 +0,0 @@
Shindo.tests('Fog::Compute[:slicehost] | slice requests', ['slicehost']) do
@slice_format = {
'addresses' => [String],
'bw-in' => Float,
'bw-out' => Float,
'flavor-id' => Integer,
'id' => Integer,
'image-id' => Integer,
'name' => String,
'progress' => Integer,
'status' => String
}
tests('success') do
@slice_id = nil
tests("#create_slice(1, 305, 'fogcreateslice')").formats(@slice_format.merge('root-password' => String)) do
pending if Fog.mocking?
data = Fog::Compute[:slicehost].create_slice(1, 305, 'fogcreateslice').body
@slice_id = data['id']
data
end
unless Fog.mocking?
Fog::Compute[:slicehost].servers.get(@slice_id).wait_for { ready? }
end
tests("#get_slice(#{@slice_id})").formats(@slice_format) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_slice(@slice_id).body
end
tests("#get_slices").formats({'slices' => [@slice_format]}) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_slices.body
end
tests("#reboot_slice(#{@slice_id})").formats(@slice_format) do
pending if Fog.mocking?
Fog::Compute[:slicehost].reboot_slice(@slice_id).body
end
unless Fog.mocking?
Fog::Compute[:slicehost].servers.get(@slice_id).wait_for { ready? }
end
tests("#delete_slice(#{@slice_id})").succeeds do
pending if Fog.mocking?
Fog::Compute[:slicehost].delete_slice(@slice_id)
end
end
tests('failure') do
tests('#get_slice(0)').raises(Excon::Errors::Forbidden) do
pending if Fog.mocking?
Fog::Compute[:slicehost].get_slice(0)
end
tests('#reboot_slice(0)').raises(Excon::Errors::Forbidden) do
pending if Fog.mocking?
Fog::Compute[:slicehost].reboot_slice(0)
end
tests('#delete_slice(0)').raises(Fog::Compute::Slicehost::NotFound) do
pending if Fog.mocking?
Fog::Compute[:slicehost].delete_slice(0)
end
end
end

View File

@ -1,314 +0,0 @@
Shindo.tests('Fog::DNS[:slicehost] | DNS requests', ['slicehost', 'dns']) do
@domain = ''
@new_zones = []
@new_records =[]
tests( 'success') do
test('get current zone count') do
pending if Fog.mocking?
@org_zone_count= 0
response = Fog::DNS[:slicehost].get_zones()
if response.status == 200
zones = response.body['zones']
@org_zone_count = zones.count
end
response.status == 200
end
test('create zone - simple') do
pending if Fog.mocking?
domain = generate_unique_domain( true)
response = Fog::DNS[:slicehost].create_zone(domain)
if response.status == 201
zone_id = response.body['id']
@new_zones << zone_id
end
response.status == 201
end
test('create zone - set all parameters') do
pending if Fog.mocking?
options = { :ttl => 1800, :active => 'N' }
@domain= generate_unique_domain( true)
response = Fog::DNS[:slicehost].create_zone( @domain, options)
if response.status == 201
@zone_id = response.body['id']
@new_zones << @zone_id
end
response.status == 201
end
test("get zone #{@zone_id} - check all parameters for #{@domain}") do
pending if Fog.mocking?
result= false
response = Fog::DNS[:slicehost].get_zone( @zone_id)
if response.status == 200
zone = response.body
if (zone['origin'] == @domain) and (zone['ttl'] == 1800) and
(zone['active'] == 'N')
result= true;
end
end
result
end
test('get zones - make sure total count is correct') do
pending if Fog.mocking?
result= false
response = Fog::DNS[:slicehost].get_zones()
if response.status == 200
zones = response.body['zones']
if (@org_zone_count+2) == zones.count
result= true;
end
end
result
end
test('get zones - check all parameters for a zone') do
pending if Fog.mocking?
result= false
response = Fog::DNS[:slicehost].get_zones()
if response.status == 200
zones = response.body['zones']
zones.each { |zone|
if zone['id'] == @new_zones[1]
if (zone['origin'] == 'sub.' + @domain) and (zone['ttl'] == 1800) and
(zone['active'] == 'N')
result= true;
end
end
}
if (@org_zone_count+2) == zones.count
result= true;
end
end
result
end
test('create record - simple A record') do
pending if Fog.mocking?
host= 'www.' + @domain
zone_id= @new_zones[1]
response = Fog::DNS[:slicehost].create_record( 'A', zone_id, host, '1.2.3.4')
if response.status == 201
record_id = response.body['id']
@new_records << record_id
end
response.status == 201
end
test('create record - A record - all parameters set') do
pending if Fog.mocking?
host= 'ftp.' + @domain
zone_id= @new_zones[1]
options = { :ttl => 3600, :active => 'N'}
response = Fog::DNS[:slicehost].create_record( 'A', zone_id, host, '1.2.3.4', options)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
end
response.status == 201
end
test('create record - CNAME record') do
pending if Fog.mocking?
zone_id= @new_zones[1]
response = Fog::DNS[:slicehost].create_record( 'CNAME', zone_id, 'mail', @domain)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
end
response.status == 201
end
test('create record - NS record') do
pending if Fog.mocking?
ns_domain = 'ns.' + @domain
zone_id= @new_zones[1]
options = { :ttl => 3600, :active => 'N'}
response = Fog::DNS[:slicehost].create_record( 'NS', zone_id, @domain, ns_domain, options)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
end
response.status == 201
end
test('create record - MX record') do
pending if Fog.mocking?
mail_domain = 'mail.' + @domain
zone_id= @new_zones[1]
options = { :ttl => 3600, :active => 'N', :aux => '10'}
response = Fog::DNS[:slicehost].create_record( 'MX', zone_id, @domain, mail_domain, options)
if response.status == 201
@record_id = response.body['id']
@new_records << @record_id
end
response.status == 201
end
test("get record #{@record_id} - verify all parameters") do
pending if Fog.mocking?
result= false
response = Fog::DNS[:slicehost].get_record(@record_id)
if response.status == 200
mail_domain = 'mail.' + @domain
record = response.body
if (record['record_type'] == 'MX') and (record['name'] == @domain) and
(record['value'] == mail_domain) and (record['ttl'] == 3600) and (record['active'] == 'N') and
(record['aux'] == "10")
result = true
end
end
result
end
test('get records - verify all parameters for one record') do
pending if Fog.mocking?
result = false
response = Fog::DNS[:slicehost].get_records()
if response.status == 200
records = response.body['records']
#find mx record
records.each {|record|
if (record['record_type'] == 'MX') and (record['name'] == @domain)
mail_domain = 'mail.' + @domain
if (record['record_type'] == 'MX') and (record['name'] == @domain) and
(record['value'] == mail_domain) and (record['ttl'] == 3600) and (record['active'] == 'N') and
(record['aux'] == "10")
result = true
end
break
end
}
end
result
end
test('update record - verify all parameters for one record') do
pending if Fog.mocking?
result = false
specific_record = nil
response = Fog::DNS[:slicehost].get_records()
if response.status == 200
records = response.body['records']
#find mx record
records.each {|record|
if (record['record_type'] == 'MX') and (record['name'] == @domain)
specific_record = record
break
end
}
end
if (specific_record) #Try to change the TTL for this MX record if we've successfully created it.
response = Fog::DNS[:slicehost].update_record(specific_record['id'], specific_record['record_type'], specific_record['zone_id'],
specific_record['name'], specific_record['value'], {:ttl => 7200, :active => "N", :aux => "10"})
mail_domain = 'mail.' + @domain
record = Fog::DNS[:slicehost].get_record(specific_record['id']).body
if (record['record_type'] == 'MX') and (record['name'] == @domain) and
(record['value'] == mail_domain) and (record['ttl'] == 7200) and (record['active'] == 'N') and
(record['aux'] == "10")
result = true
end
end
result
end
test("newly created zone returns only records which we added to it, not other records already in account") do
pending if Fog.mocking?
@new_zone = Fog::DNS[:slicehost].zones.get(@zone_id)
records = @new_zone.records
records.length == @new_records.length
end
test("delete #{@new_records.count} records created") do
pending if Fog.mocking?
result= true
@new_records.each { |record_id|
response = Fog::DNS[:slicehost].delete_record( record_id)
if response.status != 200
result= false;
end
}
result
end
test("delete #{@new_zones.count} zones created") do
pending if Fog.mocking?
result= true
@new_zones.each { |zone_id|
response = Fog::DNS[:slicehost].delete_zone( zone_id)
if response.status != 200
result= false;
end
}
result
end
end
tests( 'failure') do
#create a zone with invalid parameters
#get zonfo info with invalid zone id
#delete a zone with an invalid zone id
tests('#create_zone') do
end
end
end