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

Merge commit 'v0.3.30' into gh-master

This commit is contained in:
Paul Thornthwaite 2010-12-09 09:39:54 +00:00
commit 2c484a64dc
52 changed files with 326 additions and 191 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

@ -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

@ -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:
#