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

Updated to match other tests

Conflicts:
	tests/brightbox/helper.rb
This commit is contained in:
Paul Thornthwaite 2010-12-09 16:00:10 +00:00
commit 734fbfaf43
64 changed files with 969 additions and 286 deletions

View file

@ -1,12 +1,13 @@
PATH
remote: .
specs:
fog (0.3.26)
fog (0.3.30)
builder
excon (>= 0.2.8)
formatador (>= 0.0.16)
json
mime-types
named-parameters (>= 0.0.17)
net-ssh (>= 2.0.23)
nokogiri (>= 1.4.4)
ruby-hmac
@ -21,6 +22,7 @@ GEM
formatador (>= 0.0.12)
json (1.4.6)
mime-types (1.16)
named-parameters (0.0.17)
net-ssh (2.0.23)
nokogiri (1.4.4)
rake (0.8.7)
@ -40,6 +42,7 @@ DEPENDENCIES
formatador (>= 0.0.16)
json
mime-types
named-parameters (>= 0.0.17)
net-ssh (>= 2.0.23)
nokogiri (>= 1.4.4)
rake

View file

@ -7,8 +7,8 @@ Gem::Specification.new do |s|
## If your rubyforge_project name is different, then edit it and comment out
## the sub! line in the Rakefile
s.name = 'fog'
s.version = '0.3.26'
s.date = '2010-12-01'
s.version = '0.3.30'
s.date = '2010-12-08'
s.rubyforge_project = 'fog'
## Make sure your summary is short. The description may be as long
@ -47,6 +47,7 @@ Gem::Specification.new do |s|
s.add_dependency('formatador', '>=0.0.16')
s.add_dependency('json')
s.add_dependency('mime-types')
s.add_dependency('named-parameters', '>=0.0.17')
s.add_dependency('net-ssh', '>=2.0.23')
s.add_dependency('nokogiri', '>=1.4.4')
s.add_dependency('ruby-hmac')

View file

@ -4,6 +4,7 @@ require 'cgi'
require 'excon'
require 'formatador'
require 'time'
require 'named-parameters'
__DIR__ = File.dirname(__FILE__)
@ -18,7 +19,7 @@ module Fog
@mocking = false
unless const_defined?(:VERSION)
VERSION = '0.3.26'
VERSION = '0.3.30'
end
module Mock

View file

@ -1,35 +1,45 @@
class AWS < Fog::Bin
class << self
def class_for(key)
case key
when :cdn
Fog::AWS::CDN
when :compute, :ec2
Fog::AWS::Compute
when :elb
Fog::AWS::ELB
when :iam
Fog::AWS::IAM
when :sdb
Fog::AWS::SimpleDB
when :eu_storage, :s3, :storage
Fog::AWS::Storage
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :cdn
Fog::AWS::CDN.new
when :compute
Fog::AWS::Compute.new
klazz = class_for(key)
hash[key] = case key
when :ec2
location = caller.first
warning = "[yellow][WARN] AWS[:ec2] is deprecated, use AWS[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::AWS::Compute.new
when :elb
Fog::AWS::ELB.new
klazz.new
when :eu_storage
Fog::AWS::Storage.new(:region => 'eu-west-1')
when :iam
Fog::AWS::IAM.new
when :sdb
Fog::AWS::SimpleDB.new
klazz.new(:region => 'eu-west-1')
when :s3
location = caller.first
warning = "[yellow][WARN] AWS[:s3] is deprecated, use AWS[:storage] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::AWS::Storage.new
when :storage
Fog::AWS::Storage.new
klazz.new
else
klazz.new
end
end
@@connections[service]

View file

@ -2,7 +2,8 @@ module Fog
module AWS
class CDN < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :host, :path, :port, :scheme, :version, :persistent, &inject_parameter_specs
model_path 'fog/aws/models/cdn'

View file

@ -2,8 +2,8 @@ module Fog
module AWS
class Compute < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/aws/models/compute'
model :address

View file

@ -2,7 +2,8 @@ module Fog
module AWS
class ELB < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :region, :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
request_path 'fog/aws/requests/elb'
request :create_load_balancer

View file

@ -2,7 +2,8 @@ module Fog
module AWS
class IAM < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
request_path 'fog/aws/requests/iam'
request :add_user_to_group

View file

@ -10,6 +10,7 @@ module Fog
attribute :architecture
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
attribute :description
attribute :location, :aliases => 'imageLocation'
attribute :owner_id, :aliases => 'imageOwnerId'
attribute :state, :aliases => 'imageState'
@ -27,7 +28,7 @@ module Fog
connection.deregister_image(id)
if(delete_snapshot && root_device_type == "ebs")
block_device = block_device_mapping.select {|block_device| block_device['deviceName'] == root_device_name}
block_device = block_device_mapping.detect {|block_device| block_device['deviceName'] == root_device_name}
@connection.snapshots.new(:id => block_device['snapshotId']).destroy
else
true

View file

@ -43,8 +43,8 @@ module Fog
self.filters ||= {}
super
end
def all(filters = @filters)
def all(filters = filters)
self.filters = filters
data = connection.describe_images(filters).body
load(data['imagesSet'])

View file

@ -84,7 +84,7 @@ module Fog
end
def key_pair=(new_keypair)
key_name = new_keypair && new_keypair.name
self.key_name = new_keypair && new_keypair.name
end
def private_key_path
@ -151,7 +151,8 @@ module Fog
def setup(credentials = {})
requires :identity, :ip_address, :username
sleep(10) # takes a bit before EC2 instances will play nice
require 'json'
commands = [
%{mkdir .ssh},
%{passwd -l root},
@ -160,7 +161,16 @@ module Fog
if public_key
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
end
Fog::SSH.new(ip_address, username, credentials).run(commands)
# allow some retries over the first 120 seconds because aws is weird
Timeout::timeout(120) do
begin
Timeout::timeout(4) do
Fog::SSH.new(ip_address, username, credentials).run(commands)
end
rescue Timeout::Error
retry
end
end
rescue Errno::ECONNREFUSED => e
sleep(1)
retry

View file

@ -98,7 +98,19 @@ module Fog
end
server.save
server.wait_for { ready? }
# eventual consistency sometimes means a delay before it appears
retries = 3
begin
server.wait_for { ready? }
rescue Fog::Errors::Error => error
sleep(1)
retries -= 1
if retries > 0
retry
else
raise error
end
end
server.setup(:key_data => [server.private_key])
server
end

View file

@ -26,7 +26,7 @@ module Fog
def end_element(name)
case name
when 'architecture', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
when 'architecture', 'description', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
@image[name] = @value
when 'blockDeviceMapping'
@in_block_device_mapping = false

View file

@ -25,7 +25,7 @@ module Fog
@snapshot['tagSet'][@tag['key']] = @tag['value']
@tag = {}
when 'key', 'value'
@tag[key] = value
@tag[name] = @value
when 'tagSet'
@in_tag_set = false
end

View file

@ -22,6 +22,7 @@ module Fog
# * 'imagesSet'<~Array>:
# * 'architecture'<~String> - Architecture of the image
# * 'blockDeviceMapping'<~Array> - An array of mapped block devices
# * 'description'<~String> - Description of image
# * 'imageId'<~String> - Id of the image
# * 'imageLocation'<~String> - Location of the image
# * 'imageOwnerId'<~String> - Id of the owner of the image

View file

@ -86,12 +86,13 @@ module Fog
response.status = 200
response.body = {
'Contents' => truncated_contents,
'IsTruncated' => truncated_contents.size != contents.size,
'Marker' => options['marker'],
'MaxKeys' => max_keys,
'Name' => bucket['Name'],
'Prefix' => options['prefix']
'CommonPrefixes' => [],
'Contents' => truncated_contents,
'IsTruncated' => truncated_contents.size != contents.size,
'Marker' => options['marker'],
'MaxKeys' => max_keys,
'Name' => bucket['Name'],
'Prefix' => options['prefix']
}
if options['max-keys'] && options['max-keys'] < response.body['Contents'].length
response.body['IsTruncated'] = true

View file

@ -2,8 +2,9 @@ module Fog
module AWS
class SimpleDB < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :host, :nil_string, :path, :port, :scheme, :persistent, &inject_parameter_specs
request_path 'fog/aws/requests/simpledb'
request :batch_put_attributes
request :create_domain

View file

@ -2,8 +2,9 @@ module Fog
module AWS
class Storage < Fog::Service
requires :aws_access_key_id, :aws_secret_access_key
requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/aws/models/storage'
collection :directories
model :directory
@ -175,6 +176,7 @@ module Fog
end
end
class Real
include Utils
extend Fog::Deprecation

View file

@ -1,25 +1,31 @@
class Bluebox < Fog::Bin
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :blocks
location = caller.first
warning = "[yellow][WARN] Bluebox[:blocks] is deprecated, use Bluebox[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Bluebox::Compute.new
when :compute
Fog::Bluebox::Compute.new
end
end
@@connections[service]
def class_for(key)
case key
when :blocks, :compute
Fog::Bluebox::Compute
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def services
[:compute]
def [](service)
@@connections ||= Hash.new do |hash, key|
if key == :blocks
location = caller.first
warning = "[yellow][WARN] Bluebox[:blocks] is deprecated, use Bluebox[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
hash[key] = class_for(key).new
end
@@connections[service]
end
def services
[:compute]
end
end
end

View file

@ -2,7 +2,8 @@ module Fog
module Bluebox
class Compute < Fog::Service
requires :bluebox_api_key, :bluebox_customer_id
requires :bluebox_api_key, :bluebox_customer_id, &inject_parameter_specs
recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent, &inject_parameter_specs
model_path 'fog/bluebox/models/compute'
model :flavor

View file

@ -1,12 +1,18 @@
class Brightbox < Fog::Bin
class << self
def class_for(key)
case key
when :compute
Fog::Brightbox::Compute
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Brightbox::Compute.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -4,7 +4,8 @@ module Fog
API_URL = "https://api.gb1.brightbox.com/"
requires :brightbox_client_id, :brightbox_secret
requires :brightbox_client_id, :brightbox_secret, &inject_parameter_specs
recognizes :brightbox_auth_url, :brightbox_api_url, &inject_parameter_specs
model_path 'fog/brightbox/models/compute'
model :account # Singular resource, no collection

View file

@ -26,6 +26,10 @@ module Fog
connection.map_cloud_ip(identity, :interface => interface_to_map)
end
def mapped?
status == "mapped"
end
def unmap
requires :identity
connection.unmap_cloud_ip(identity)

View file

@ -26,6 +26,10 @@ module Fog
attribute :disk_size
attribute :created_at
def ready?
status == "available"
end
def save
requires :source, :arch
options = {

View file

@ -148,6 +148,7 @@ module Fog
!identity
end
# check that the attributes specified in args exist and is not nil
def requires(*args)
missing = []
for arg in [:connection] | args

View file

@ -34,16 +34,20 @@ module Fog
availability = true
for service in services
begin
service = eval(self[service].class.to_s.split('::')[0...-1].join('::'))
availability &&= service.requirements.all? {|requirement| Fog.credentials.include?(requirement)}
rescue
service = self.class_for(service)
availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
rescue ArgumentError => e
warning = "[yellow][WARN] #{e.message}[/]"
Formatador.display_line(warning)
availability = false
rescue => e
availability = false
end
end
if availability
for service in services
for collection in self[service].collections
for collection in self.class_for(service).collections
unless self.respond_to?(collection)
self.class_eval <<-EOS, __FILE__, __LINE__
def self.#{collection}

View file

@ -28,7 +28,6 @@ module Fog
unless credentials && credentials[credential]
print("\n To run as '#{credential}', add the following to #{config_path}\n")
yml = <<-YML
:#{credential}:
:aws_access_key_id: INTENTIONALLY_LEFT_BLANK
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
@ -51,7 +50,7 @@ module Fog
:terremark_username: INTENTIONALLY_LEFT_BLANK
:terremark_password: INTENTIONALLY_LEFT_BLANK
YML
print(yml)
print("\n#{yml}\n")
raise(ArgumentError.new("Missing Credentials"))
end
credentials[credential]

View file

@ -18,6 +18,26 @@ module Fog
class << self
# this is to accomodate Real implementations of Service subclasses
# NOTE: it might be good to enforce parameter specs to Mock classes as well.
def inject_parameter_specs
lambda do |spec|
implementation = "Real"
self.const_set(implementation, Class.new) unless self.const_defined? implementation
realclass = self.const_get implementation
if realclass.declared_parameters_for(:'self.new', :required).empty?
required = declared_parameters_for(:'self.new', :required)
realclass.send(:requires, *required)
end
if realclass.declared_parameters_for(:'self.new', :optional).empty?
optional = declared_parameters_for(:'self.new', :optional)
realclass.send(:recognizes, *optional)
end
end
end
def inherited(child)
child.class_eval <<-EOS, __FILE__, __LINE__
module Collections
@ -34,13 +54,16 @@ module Fog
EOS
end
def requirements
declared_parameters_for :'self.new', :required
end
def new(options={})
if Fog.bin
default_credentials = Fog.credentials.reject {|key, value| !requirements.include?(key)}
default_credentials = filter_parameters(Fog.credentials)
options = default_credentials.merge(options)
end
validate_arguments(options)
setup_requirements
if Fog.mocking?
@ -110,41 +133,10 @@ module Fog
@requests ||= []
end
def requires(*args)
requirements.concat(args)
end
def requirements
@requirements ||= []
end
def recognizes(*args)
recognized.concat(args)
end
def recognized
@recognized ||= []
end
def reset_data(keys=Mock.data.keys)
Mock.reset_data(keys)
end
def validate_arguments(options)
missing = requirements - options.keys
unless missing.empty?
raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
end
# FIXME: avoid failing for the services that don't have recognizes yet
unless recognizes.empty?
unrecognized = options.keys - requirements - recognized
unless unrecognized.empty?
raise ArgumentError, "Unrecognized arguments: #{unrecognized.join(', ')}"
end
end
end
end
end

View file

@ -42,8 +42,7 @@ module Fog
require 'net/ssh'
@address = address
@username = username
@options = options.merge(:paranoid => false)
@options.merge(:verbose => true)
@options = { :paranoid => false }.merge(options)
end
def run(commands)

View file

@ -1,18 +1,24 @@
class GoGrid < Fog::Bin
class << self
def class_for(key)
case key
when :compute, :servers
Fog::GoGrid::Compute
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::GoGrid::Compute.new
when :servers
if key == :servers
location = caller.first
warning = "[yellow][WARN] GoGrid[:servers] is deprecated, use GoGrid[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::GoGrid::Compute.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -2,8 +2,8 @@ module Fog
module GoGrid
class Compute < Fog::Service
requires :go_grid_api_key
requires :go_grid_shared_secret
requires :go_grid_api_key, :go_grid_shared_secret, &inject_parameter_specs
recognizes :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/go_grid/models/compute'
model :image

View file

@ -1,12 +1,18 @@
class Google < Fog::Bin
class << self
def class_for(key)
case key
when :storage
Fog::Google::Storage
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :storage
Fog::Google::Storage.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end
@ -16,5 +22,4 @@ class Google < Fog::Bin
end
end
end

View file

@ -17,7 +17,7 @@ module Fog
when 'Entries'
@in_entries = true
when 'Scope'
key, value = attrs
key, value = attrs.first
@entry['Scope'][key] = value
end
end

View file

@ -2,7 +2,8 @@ module Fog
module Google
class Storage < Fog::Service
requires :google_storage_access_key_id, :google_storage_secret_access_key
requires :google_storage_access_key_id, :google_storage_secret_access_key, &inject_parameter_specs
recognizes :host, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/google/models/storage'
collection :directories
@ -135,6 +136,7 @@ module Fog
end
end
class Real
include Utils
extend Fog::Deprecation

View file

@ -1,18 +1,24 @@
class Linode < Fog::Bin
class << self
def class_for(key)
case key
when :compute, :linode
Fog::Linode::Compute
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Linode::Compute.new
when :linode
if key == :linode
location = caller.first
warning = "[yellow][WARN] Linode[:linode] is deprecated, use Linode[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Linode::Compute.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -2,7 +2,8 @@ module Fog
module Linode
class Compute < Fog::Service
requires :linode_api_key
requires :linode_api_key, &inject_parameter_specs
recognizes :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/linode/models/compute'

View file

@ -1,18 +1,24 @@
class Local < Fog::Bin
class << self
def class_for(key)
case key
when :files, :storage
Fog::Local::Storage
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :files
if key == :files
location = caller.first
warning = "[yellow][WARN] Local[:files] is deprecated, use Local[:storage] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Local::Storage.new
when :storage
Fog::Local::Storage.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -2,7 +2,7 @@ module Fog
module Local
class Storage < Fog::Service
requires :local_root
requires :local_root, &inject_parameter_specs
model_path 'fog/local/models/storage'
collection :directories

View file

@ -1,18 +1,24 @@
class NewServers < Fog::Bin
class << self
def class_for(key)
case key
when :compute, :new_servers
Fog::NewServers::Compute
else
raise ArgumentError, "Unsupported #{self} service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::NewServers::Compute.new
when :new_servers
if key == :new_servers
location = caller.first
warning = "[yellow][WARN] NewServers[:servers] is deprecated, use NewServers[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::NewServers::Compute.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -4,8 +4,8 @@ module Fog
module NewServers
class Compute < Fog::Service
requires :new_servers_password
requires :new_servers_username
requires :new_servers_password, :new_servers_username, &inject_parameter_specs
recognizes :host, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/new_servers/models/compute'

View file

@ -1,6 +1,6 @@
module Fog
module Rackspace
extend Fog::Provider
service_path 'fog/rackspace'

View file

@ -1,27 +1,37 @@
class Rackspace < Fog::Bin
class << self
def class_for(key)
case key
when :cdn
Fog::Rackspace::CDN
when :compute, :servers
Fog::Rackspace::Compute
when :files, :storage
Fog::Rackspace::Storage
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
klazz = class_for(key)
hash[key] = case key
when :cdn
Fog::Rackspace::CDN.new
when :compute
Fog::Rackspace::Compute.new
when :files
location = caller.first
warning = "[yellow][WARN] Rackspace[:files] is deprecated, use Rackspace[:storage] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Rackspace::Storage.new
klazz.new
when :servers
location = caller.first
warning = "[yellow][WARN] Rackspace[:servers] is deprecated, use Rackspace[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Rackspace::Compute.new
when :storage
Fog::Rackspace::Storage.new
klazz.new
else
klazz.new
end
end
@@connections[service]

View file

@ -2,7 +2,8 @@ module Fog
module Rackspace
class CDN < Fog::Service
requires :rackspace_api_key, :rackspace_username
requires :rackspace_api_key, :rackspace_username, &inject_parameter_specs
recognizes :rackspace_auth_url, :persistent, &inject_parameter_specs
model_path 'fog/rackspace/models/cdn'

View file

@ -2,7 +2,8 @@ module Fog
module Rackspace
class Compute < Fog::Service
requires :rackspace_api_key, :rackspace_username
requires :rackspace_api_key, :rackspace_username, &inject_parameter_specs
recognizes :rackspace_auth_url, :persistent, &inject_parameter_specs
model_path 'fog/rackspace/models/compute'
model :flavor

View file

@ -2,7 +2,8 @@ module Fog
module Rackspace
class Storage < Fog::Service
requires :rackspace_api_key, :rackspace_username
requires :rackspace_api_key, :rackspace_username, &inject_parameter_specs
recognizes :rackspace_auth_url, :persistent, &inject_parameter_specs
model_path 'fog/rackspace/models/storage'
model :directory

View file

@ -1,18 +1,24 @@
class Slicehost < Fog::Bin
class << self
def class_for(key)
case key
when :compute, :slices
Fog::Slicehost::Compute
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Slicehost::Compute.new
when :slices
if key == :slices
location = caller.first
warning = "[yellow][WARN] Slicehost[:blocks] is deprecated, use Bluebox[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::Slicehost::Compute.new
end
hash[key] = class_for(key).new
end
@@connections[service]
end

View file

@ -2,7 +2,8 @@ module Fog
module Slicehost
class Compute < Fog::Service
requires :slicehost_password
requires :slicehost_password, &inject_parameter_specs
recognizes :host, :port, :scheme, :persistent, &inject_parameter_specs
model_path 'fog/slicehost/models/compute'
model :flavor

View file

@ -32,7 +32,11 @@ module Fog
end
class Real
# NOTE: When this vbecomes a service, take care to pass the &inject_parameter_specs
# block on call to requires and recognizes
requires :terremark_ecloud_password, :terremark_ecloud_username
recognizes :host, :path, :port, :scheme, :persistent
include Fog::Terremark::Shared::Real
include Fog::Terremark::Shared::Parser

View file

@ -15,8 +15,13 @@ module Fog
when 'Link'
link = {}
until attributes.empty?
link[attributes.shift] = attributes.shift
end
if attributes.first.is_a?(Array)
attribute = attributes.shift
link[attribute.first] = attribute.last
else
link[attributes.shift] = attributes.shift
end
end
@response['Links'] << link
when 'Org'
org = {}

View file

@ -14,7 +14,12 @@ module Fog
if name == 'Org'
organization = {}
until attributes.empty?
organization[attributes.shift] = attributes.shift
if attributes.first.is_a?(Array)
attribute = attributes.shift
organization[attribute.first] = attribute.last
else
organization[attributes.shift] = attributes.shift
end
end
@response['OrgList'] << organization
end

View file

@ -37,7 +37,12 @@ module Fog
when 'Link'
link = {}
until attributes.empty?
link[attributes.shift] = attributes.shift
if attributes.first.is_a?(Array)
attribute = attributes.shift
link[attribute.first] = attribute.last
else
link[attributes.shift] = attributes.shift
end
end
@response['links'] << link
when 'Memory'
@ -45,13 +50,23 @@ module Fog
when 'Network'
network = {}
until attributes.empty?
network[attributes.shift] = attributes.shift
if attributes.first.is_a?(Array)
attribute = attributes.shift
network[attribute.first] = attribute.last
else
network[attributes.shift] = attributes.shift
end
end
@response['AvailableNetworks'] << network
when 'ResourceEntity'
resource_entity = {}
until attributes.empty?
resource_entity[attributes.shift] = attributes.shift
if attributes.first.is_a?(Array)
attribute = attributes.shift
resource_entity[attribute.first] = attribute.last
else
resource_entity[attributes.shift] = attributes.shift
end
end
@response['ResourceEntities'] << resource_entity
when 'StorageCapacity'

View file

@ -19,7 +19,8 @@ end
module Fog
class Vcloud < Fog::Service
requires :username, :password, :versions_uri
requires :username, :password, :module, :versions_uri, &inject_parameter_specs
recognizes :version, :persistent, &inject_parameter_specs
model_path 'fog/vcloud/models'
model :vdc

View file

@ -1,3 +1,34 @@
module Fog
module Brightbox
module Nullable
module String; end
module Account; end
module Image; end
module Interface; end
module Server; end
module Zone; end
end
end
end
String.send :include, Fog::Brightbox::Nullable::String
NilClass.send :include, Fog::Brightbox::Nullable::String
Hash.send :include, Fog::Brightbox::Nullable::Account
NilClass.send :include, Fog::Brightbox::Nullable::Account
Hash.send :include, Fog::Brightbox::Nullable::Image
NilClass.send :include, Fog::Brightbox::Nullable::Image
Hash.send :include, Fog::Brightbox::Nullable::Interface
NilClass.send :include, Fog::Brightbox::Nullable::Interface
Hash.send :include, Fog::Brightbox::Nullable::Server
NilClass.send :include, Fog::Brightbox::Nullable::Server
Hash.send :include, Fog::Brightbox::Nullable::Zone
NilClass.send :include, Fog::Brightbox::Nullable::Zone
class Brightbox
module Compute
module TestSupport
@ -7,43 +38,22 @@ class Brightbox
module Formats
module Struct
LB_LISTENER = {
'in' => Integer,
'out' => Integer,
'protocol' => String
"in" => Integer,
"out" => Integer,
"protocol" => String
}
LB_HEALTHCHECK = {
'type' => String,
'request' => String,
'port' => Integer,
'interval' => Integer,
'timeout' => Integer,
'threshold_up' => Integer,
'threshold_down' => Integer
"type" => String,
"request" => String,
"port" => Integer,
"interval" => Integer,
"timeout" => Integer,
"threshold_up" => Integer,
"threshold_down" => Integer
}
end
module Nested
SERVER_TYPE = {
"name" => String,
"cores" => Integer,
"created_at" => String,
"resource_type" => String,
"updated_at" => String,
"disk_size" => Integer,
"default" => Fog::Boolean,
"url" => String,
"id" => String,
"ram" => Integer,
"status" => String
}
ZONE = {
"handle" => String,
"resource_type" => String,
"url" => String,
"id" => String
}
ACCOUNT = {
"name" => String,
"ram_used" => Integer,
@ -55,12 +65,21 @@ class Brightbox
"limits_cloudips" => Integer
}
INTERFACE = {
API_CLIENT = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"description" => String
}
CLOUD_IP = {
"id" => String,
"ipv4_address" => String,
"mac_address" => String
"resource_type" => String,
"url" => String,
"public_ip" => String,
"status" => String,
"reverse_dns" => String
}
IMAGE = {
@ -75,81 +94,319 @@ class Brightbox
"status" => String,
"owner" => String
}
end
module Full
INTERFACE = {
"resource_type" => String,
"url" => String,
"id" => String,
"ipv4_address" => String,
"mac_address" => String
}
SERVER = {
'id' => String,
'resource_type' => String,
'url' => String,
'name' => String,
'status' => String,
'hostname' => String,
'created_at' => String,
'started_at' => NilClass,
'deleted_at' => NilClass,
'user_data' => NilClass,
'account' => Brightbox::Compute::Formats::Nested::ACCOUNT,
'server_type' => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
'cloud_ips' => [],
'image' => Brightbox::Compute::Formats::Nested::IMAGE,
'snapshots' => [],
'interfaces' => [Brightbox::Compute::Formats::Nested::INTERFACE],
'zone' => Brightbox::Compute::Formats::Nested::ZONE
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"hostname" => String,
"created_at" => String,
"started_at" => Fog::Brightbox::Nullable::String,
"deleted_at" => Fog::Brightbox::Nullable::String
}
LOAD_BALANCER = {
'id' => String,
'resource_type' => String,
'url' => String,
'name' => String,
'status' => String,
'listeners' => [Brightbox::Compute::Formats::Struct::LB_LISTENER],
'policy' => String,
'healthcheck' => Hash,
'created_at' => String,
'deleted_at' => NilClass,
'account' => Hash,
'nodes' => [Hash]
SERVER_TYPE = {
"name" => String,
"cores" => Integer,
"created_at" => String,
"resource_type" => String,
"updated_at" => String,
"disk_size" => Integer,
"default" => Fog::Boolean,
"url" => String,
"id" => String,
"ram" => Integer,
"status" => String
}
USER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"email_address" => String
}
ZONE = {
"id" => String,
"resource_type" => String,
"url" => String,
"handle" => Fog::Brightbox::Nullable::String
}
end
module Collected
SERVER = {
'id' => String,
'resource_type' => String,
'url' => String,
'name' => String,
'status' => String,
'hostname' => String,
'created_at' => String,
'started_at' => NilClass,
'deleted_at' => NilClass, # String (if deleted) OR NilClass
'account' => Brightbox::Compute::Formats::Nested::ACCOUNT,
'server_type' => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
'cloud_ips' => [],
'image' => Brightbox::Compute::Formats::Nested::IMAGE,
'snapshots' => [],
'interfaces' => [Brightbox::Compute::Formats::Nested::INTERFACE],
'zone' => Brightbox::Compute::Formats::Nested::ZONE
API_CLIENT = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"description" => String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT
}
CLOUD_IP = {
"id" => String,
"resource_type" => String,
"url" => String,
"public_ip" => String,
"status" => String,
"reverse_dns" => String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
"interface" => Fog::Brightbox::Nullable::Interface,
"server" => Fog::Brightbox::Nullable::String
}
IMAGE = {
"name" => String,
"created_at" => String,
"resource_type" => String,
"arch" => String,
"url" => String,
"id" => String,
"description" => String,
"source" => String,
"source_type" => String,
"status" => String,
"owner" => String,
"public" => Fog::Boolean,
"official" => Fog::Boolean,
"compatibility_mode" => Fog::Boolean,
"virtual_size" => Integer,
"disk_size" => Integer,
"ancestor" => Fog::Brightbox::Nullable::Image
}
LOAD_BALANCER = {
'id' => String,
'resource_type' => String,
'url' => String,
'name' => String,
'status' => String,
'created_at' => String,
'deleted_at' => NilClass
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"created_at" => String,
"deleted_at" => Fog::Brightbox::Nullable::String
}
SERVER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"hostname" => String,
"created_at" => String,
"started_at" => Fog::Brightbox::Nullable::String,
"deleted_at" => Fog::Brightbox::Nullable::String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
"server_type" => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
"cloud_ips" => [Brightbox::Compute::Formats::Nested::CLOUD_IP],
"image" => Brightbox::Compute::Formats::Nested::IMAGE,
"snapshots" => [Brightbox::Compute::Formats::Nested::IMAGE],
"interfaces" => [Brightbox::Compute::Formats::Nested::INTERFACE],
"zone" => Fog::Brightbox::Nullable::Zone
}
SERVER_TYPE = {
"id" => String,
"resource_type" => String,
"url" => String,
"handle" => Fog::Brightbox::Nullable::String,
"name" => String,
"status" => String,
"cores" => Integer,
"ram" => Integer,
"disk_size" => Integer
}
USER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"email_address" => String,
"email_verified" => Fog::Boolean,
"accounts" => [Brightbox::Compute::Formats::Nested::ACCOUNT],
"default_account" => NilClass
}
ZONE = {
"id" => String,
"resource_type" => String,
"url" => String,
"handle" => Fog::Brightbox::Nullable::String
}
end
module Full
ACCOUNT = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"address_1" => String,
"address_2" => String,
"city" => String,
"county" => String,
"postcode" => String,
"country_code" => String,
"country_name" => String,
"vat_registration_number" => Fog::Brightbox::Nullable::String,
"telephone_number" => String,
"telephone_verified" => Fog::Boolean,
"created_at" => String,
"ram_limit" => Integer,
"ram_used" => Integer,
"limits_cloudips" => Integer,
"library_ftp_host" => String,
"library_ftp_user" => String,
"library_ftp_password" => Fog::Brightbox::Nullable::String,
"owner" => Brightbox::Compute::Formats::Nested::USER,
"users" => [Brightbox::Compute::Formats::Nested::USER],
"clients" => [Brightbox::Compute::Formats::Nested::API_CLIENT],
"servers" => [Brightbox::Compute::Formats::Nested::SERVER],
"images" => [Brightbox::Compute::Formats::Nested::IMAGE],
"zones" => [Brightbox::Compute::Formats::Nested::ZONE]
}
API_CLIENT = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"description" => String,
"secret" => Fog::Brightbox::Nullable::String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT
}
CLOUD_IP = {
"id" => String,
"resource_type" => String,
"url" => String,
"public_ip" => String,
"status" => String,
"reverse_dns" => String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
"interface" => Fog::Brightbox::Nullable::Interface,
"server" => Fog::Brightbox::Nullable::Server
}
IMAGE = {
"name" => String,
"created_at" => String,
"resource_type" => String,
"arch" => String,
"url" => String,
"id" => String,
"description" => String,
"source" => String,
"source_type" => String,
"status" => String,
"owner" => String, # Account ID not object
"public" => Fog::Boolean,
"official" => Fog::Boolean,
"compatibility_mode" => Fog::Boolean,
"virtual_size" => Integer,
"disk_size" => Integer,
"ancestor" => Fog::Brightbox::Nullable::Image
}
INTERFACE = {
"resource_type" => String,
"url" => String,
"id" => String,
"ipv4_address" => String,
"mac_address" => String,
"server" => Brightbox::Compute::Formats::Nested::SERVER
}
LOAD_BALANCER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"listeners" => [Brightbox::Compute::Formats::Struct::LB_LISTENER],
"policy" => String,
"healthcheck" => Brightbox::Compute::Formats::Struct::LB_HEALTHCHECK,
"created_at" => String,
"deleted_at" => Fog::Brightbox::Nullable::String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
"nodes" => [Brightbox::Compute::Formats::Nested::SERVER]
}
SERVER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"status" => String,
"hostname" => String,
"created_at" => String,
"started_at" => Fog::Brightbox::Nullable::String,
"deleted_at" => Fog::Brightbox::Nullable::String,
"user_data" => Fog::Brightbox::Nullable::String,
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
"server_type" => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
"cloud_ips" => [Brightbox::Compute::Formats::Nested::CLOUD_IP],
"image" => Brightbox::Compute::Formats::Nested::IMAGE,
"snapshots" => [Brightbox::Compute::Formats::Nested::IMAGE],
"interfaces" => [Brightbox::Compute::Formats::Nested::INTERFACE],
"zone" => Brightbox::Compute::Formats::Nested::ZONE
}
SERVER_TYPE = {
"id" => String,
"resource_type" => String,
"url" => String,
"handle" => Fog::Brightbox::Nullable::String,
"name" => String,
"status" => String,
"cores" => Integer,
"ram" => Integer,
"disk_size" => Integer
}
USER = {
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"email_address" => String,
"email_verified" => Fog::Boolean,
"accounts" => [Brightbox::Compute::Formats::Nested::ACCOUNT],
"default_account" => Fog::Brightbox::Nullable::Account,
"ssh_key" => Fog::Brightbox::Nullable::String
}
ZONE = {
"id" => String,
"resource_type" => String,
"url" => String,
"handle" => Fog::Brightbox::Nullable::String
}
end
module Collection
SERVERS = [Brightbox::Compute::Formats::Collected::SERVER]
API_CLIENTS = [Brightbox::Compute::Formats::Collected::API_CLIENT]
CLOUD_IPS = [Brightbox::Compute::Formats::Collected::CLOUD_IP]
IMAGES = [Brightbox::Compute::Formats::Collected::IMAGE]
LOAD_BALANCERS = [Brightbox::Compute::Formats::Collected::LOAD_BALANCER]
SERVERS = [Brightbox::Compute::Formats::Collected::SERVER]
SERVER_TYPES = [Brightbox::Compute::Formats::Collected::SERVER_TYPE]
USERS = [Brightbox::Compute::Formats::Collected::USER]
ZONES = [Brightbox::Compute::Formats::Collected::ZONE]
end
end

View file

@ -0,0 +1,29 @@
Shindo.tests('Brightbox::Compute | account requests', ['brightbox']) do
tests('success') do
tests("#get_account()").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
Brightbox[:compute].get_account()
end
original_name = Brightbox[:compute].get_account["name"]
update_args = {:name => "New name from Fog test"}
tests("#update_account(#{update_args.inspect})").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
Brightbox[:compute].update_account(update_args)
end
Brightbox[:compute].update_account(:name => original_name)
tests("#reset_ftp_password_account()").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
Brightbox[:compute].reset_ftp_password_account()
end
end
tests('failure') do
tests("#update_account()").returns(nil) do
Brightbox[:compute].update_account()
end
end
end

View file

@ -0,0 +1,41 @@
Shindo.tests('Brightbox::Compute | api client requests', ['brightbox']) do
tests('success') do
create_options = {:name => "Name from Fog test (#{Time.now.to_i})", :description => "Description from Fog test"}
tests("#create_api_client(#{create_options.inspect})").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
data = Brightbox[:compute].create_api_client(create_options)
@api_client_id = data["id"]
data
end
tests("#list_api_clients()").formats(Brightbox::Compute::Formats::Collection::API_CLIENTS) do
Brightbox[:compute].list_api_clients()
end
tests("#get_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
Brightbox[:compute].get_api_client(@api_client_id)
end
tests("#update_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
Brightbox[:compute].update_api_client(@api_client_id, :name => "New name from Fog test")
end
tests("#destroy_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
Brightbox[:compute].destroy_api_client(@api_client_id)
end
end
tests('failure') do
tests("#get_api_client('cli-00000')").raises(Excon::Errors::NotFound) do
Brightbox[:compute].get_api_client('cli-00000')
end
tests("#get_api_client()").raises(ArgumentError) do
Brightbox[:compute].get_api_client()
end
end
end

View file

@ -0,0 +1,49 @@
Shindo.tests('Brightbox::Compute | cloud ip requests', ['brightbox']) do
tests('success') do
tests("#create_cloud_ip()").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
data = Brightbox[:compute].create_cloud_ip()
@cloud_ip_id = data["id"]
data
end
tests("#list_cloud_ips()").formats(Brightbox::Compute::Formats::Collection::CLOUD_IPS) do
Brightbox[:compute].list_cloud_ips()
end
tests("#get_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
Brightbox[:compute].get_cloud_ip(@cloud_ip_id)
end
server = Brightbox[:compute].servers.first
interface_id = server.interfaces.first["id"]
map_options = {:interface => interface_id}
tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
Brightbox[:compute].map_cloud_ip(@cloud_ip_id, map_options)
end
Brightbox[:compute].cloud_ips.get(@cloud_ip_id).wait_for { mapped? }
tests("#unmap_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
Brightbox[:compute].unmap_cloud_ip(@cloud_ip_id)
end
tests("#destroy_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
Brightbox[:compute].destroy_cloud_ip(@cloud_ip_id)
end
end
tests('failure') do
tests("#get_cloud_ip('cip-00000')").raises(Excon::Errors::NotFound) do
Brightbox[:compute].get_cloud_ip('cip-00000')
end
tests("#get_cloud_ip()").raises(ArgumentError) do
Brightbox[:compute].get_cloud_ip()
end
end
end

View file

@ -0,0 +1,52 @@
Shindo.tests('Brightbox::Compute | image requests', ['brightbox']) do
tests('success') do
## Difficult to test without having uploaded an Image to your account to register
# creation_options = {
# "arch" => "i686",
# "source" => "fnord"
# }
# tests("#create_image(#{creation_options.inspect})").formats(Brightbox::Compute::Formats::Full::IMAGE) do
# data = Brightbox[:compute].create_image(creation_options)
# @image_id = data["id"]
# data
# end
# Brightbox[:compute].images.get(@image_id).wait_for { ready? }
tests("#list_images()").formats(Brightbox::Compute::Formats::Collection::IMAGES) do
data = Brightbox[:compute].list_images()
@image_id = data.first["id"]
data
end
tests("#get_image('#{@image_id}')").formats(Brightbox::Compute::Formats::Full::IMAGE) do
Brightbox[:compute].get_image(@image_id)
end
## Until Image creation can be automated, we shouldn't be updating Images randomly
# update_options = {}
# tests("#update_image('#{@image_id}', #{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::IMAGE) do
# Brightbox[:compute].update_image(@image_id, :name => "New name from Fog test")
# end
## Same as other tests - can't be deleting them unless part of the test run
# tests("#destroy_server('#{@image_id}')").formats(Brightbox::Compute::Formats::Full::IMAGE) do
# Brightbox[:compute].destroy_image(@image_id)
# end
end
tests('failure') do
tests("#get_image('img-00000')").raises(Excon::Errors::NotFound) do
Brightbox[:compute].get_image('img-00000')
end
tests("#get_image()").raises(ArgumentError) do
Brightbox[:compute].get_image()
end
end
end

View file

@ -0,0 +1,24 @@
Shindo.tests('Brightbox::Compute | interface requests', ['brightbox']) do
tests('success') do
server = Brightbox[:compute].servers.first
@interface_id = server.interfaces.first["id"]
tests("#get_interface('#{@interface_id}')").formats(Brightbox::Compute::Formats::Full::INTERFACE) do
Brightbox[:compute].get_interface(@interface_id)
end
end
tests('failure') do
tests("#get_interface('int-00000')").raises(Excon::Errors::Forbidden) do
Brightbox[:compute].get_interface('int-00000')
end
tests("#get_interface()").raises(ArgumentError) do
Brightbox[:compute].get_interface()
end
end
end

View file

@ -13,10 +13,9 @@ Shindo.tests('Brightbox::Compute | server requests', ['brightbox']) do
Brightbox[:compute].servers.get(server_id).wait_for { ready? }
# Collection of Servers fails to match since deleted_at can be a String OR a NilClass
# tests("#list_servers()").formats(Brightbox::Compute::Formats::Collection::SERVERS) do
# Brightbox[:compute].list_servers()
# end
tests("#list_servers()").formats(Brightbox::Compute::Formats::Collection::SERVERS) do
Brightbox[:compute].list_servers()
end
tests("#get_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
Brightbox[:compute].get_server(server_id)

View file

@ -0,0 +1,28 @@
Shindo.tests('Brightbox::Compute | server type requests', ['brightbox']) do
tests('success') do
tests("#list_server_types()").formats(Brightbox::Compute::Formats::Collection::SERVER_TYPES) do
data = Brightbox[:compute].list_server_types()
@server_type_id = data.first["id"]
data
end
tests("#get_server_type('#{@server_type_id}')").formats(Brightbox::Compute::Formats::Full::SERVER_TYPE) do
Brightbox[:compute].get_server_type(@server_type_id)
end
end
tests('failure') do
tests("#get_server_type('typ-00000')").raises(Excon::Errors::NotFound) do
Brightbox[:compute].get_server_type('typ-00000')
end
tests("#get_server()").raises(ArgumentError) do
Brightbox[:compute].get_server_type()
end
end
end

View file

@ -0,0 +1,33 @@
Shindo.tests('Brightbox::Compute | user requests', ['brightbox']) do
tests('success') do
tests("#list_users()").formats(Brightbox::Compute::Formats::Collection::USERS) do
data = Brightbox[:compute].list_users()
@user_id = data.first["id"]
data
end
tests("#get_user('#{@user_id}')").formats(Brightbox::Compute::Formats::Full::USER) do
data = Brightbox[:compute].get_user(@user_id)
@original_name = data["name"]
data
end
update_options = { :name => "New name from Fog" }
tests("#update_user('#{@user_id}', #{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::USER) do
Brightbox[:compute].update_user(@user_id, update_options)
end
Brightbox[:compute].update_user(@user_id, :name => @original_name)
end
tests('failure') do
tests("#update_user()").raises(ArgumentError) do
Brightbox[:compute].update_user()
end
end
end

View file

@ -0,0 +1,28 @@
Shindo.tests('Brightbox::Compute | zone requests', ['brightbox']) do
tests('success') do
tests("#list_zones()").formats(Brightbox::Compute::Formats::Collection::ZONES) do
data = Brightbox[:compute].list_zones()
@zone_id = data.first["id"]
data
end
tests("#get_zone('#{@zone_id}')").formats(Brightbox::Compute::Formats::Full::ZONE) do
Brightbox[:compute].get_zone(@zone_id)
end
end
tests('failure') do
tests("#get_zone('zon-00000')").raises(Excon::Errors::NotFound) do
Brightbox[:compute].get_zone('zon-00000')
end
tests("#get_zone()").raises(ArgumentError) do
Brightbox[:compute].get_zone()
end
end
end

View file

@ -3,11 +3,12 @@ Shindo.tests('Google::Storage | bucket requests', ['google']) do
tests('success') do
@bucket_format = {
'IsTruncated' => Fog::Boolean,
'Marker' => NilClass,
'Name' => String,
'Prefix' => NilClass,
'Contents' => [{
'CommonPrefixes' => [],
'IsTruncated' => Fog::Boolean,
'Marker' => NilClass,
'Name' => String,
'Prefix' => NilClass,
'Contents' => [{
'ETag' => String,
'Key' => String,
'LastModified' => Time,
@ -16,7 +17,7 @@ Shindo.tests('Google::Storage | bucket requests', ['google']) do
'ID' => String
},
'Size' => Integer,
'StorageClass' => String
'StorageClass' => String
}]
}

View file

@ -1,28 +1,25 @@
__DIR__ = File.dirname(__FILE__)
__LIB_DIR__ = File.join(__DIR__, '../lib')
[ __DIR__, __LIB_DIR__ ].each do |directory|
$LOAD_PATH.unshift directory unless
$LOAD_PATH.include?(directory) ||
$LOAD_PATH.include?(File.expand_path(directory))
end
require 'fog'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require 'fog/core/bin'
Fog.bin = true
require 'tests/helpers/collection_tests'
require 'tests/helpers/model_tests'
__DIR__ = File.dirname(__FILE__)
require 'tests/helpers/compute/flavors_tests'
require 'tests/helpers/compute/server_tests'
require 'tests/helpers/compute/servers_tests'
$LOAD_PATH.unshift __DIR__ unless
$LOAD_PATH.include?(__DIR__) ||
$LOAD_PATH.include?(File.expand_path(__DIR__))
require 'tests/helpers/storage/directory_tests'
require 'tests/helpers/storage/directories_tests'
require 'tests/helpers/storage/file_tests'
require 'tests/helpers/storage/files_tests'
require 'helpers/collection_tests'
require 'helpers/model_tests'
require 'helpers/compute/flavors_tests'
require 'helpers/compute/server_tests'
require 'helpers/compute/servers_tests'
require 'helpers/storage/directory_tests'
require 'helpers/storage/directories_tests'
require 'helpers/storage/file_tests'
require 'helpers/storage/files_tests'
# Use so you can run in mock mode from the command line:
#