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

rebasing with master

This commit is contained in:
Kyle Rames 2013-02-28 09:21:37 -06:00
commit 3d4189416b
8 changed files with 86 additions and 2 deletions

View file

@ -25,8 +25,7 @@ module Fog
:host => @host,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::Storage::AWS::GetService.new,
:url => @host
:parser => Fog::Parsers::Storage::AWS::GetService.new
})
end

View file

@ -13,6 +13,8 @@ class OpenStack < Fog::Bin
Fog::Network::OpenStack
when :storage
Fog::Storage::OpenStack
when :volume
Fog::Volume::OpenStack
else
raise ArgumentError, "Unrecognized service: #{key}"
end
@ -36,6 +38,9 @@ class OpenStack < Fog::Bin
when :storage
Fog::Logger.warning("OpenStack[:storage] is not recommended, use Storage[:openstack] for portability")
Fog::Storage.new(:provider => 'OpenStack')
when :volume
Fog::Logger.warning("OpenStack[:volume] is not recommended, use Volume[:openstack] for portability")
Fog::Volume.new(:provider => 'OpenStack')
else
raise ArgumentError, "Unrecognized service: #{key.inspect}"
end

View file

@ -46,6 +46,7 @@ module Fog
service(:identity, 'openstack/identity', 'Identity')
service(:network, 'openstack/network', 'Network')
service(:storage, 'openstack/storage', 'Storage')
service(:volume, 'openstack/volume', 'Volume')
# legacy v1.0 style auth
def self.authenticate_v1(options, connection_options = {})

View file

@ -0,0 +1,24 @@
require 'fog/core/model'
module Fog
module Storage
class Rackspace
class Account < Fog::Model
attribute :meta_temp_url_key, :aliases => 'X-Account-Meta-Temp-Url-Key'
attribute :container_count, :aliases => 'X-Account-Container-Count', :type => :integer
attribute :bytes_used, :aliases => 'X-Account-Bytes-Used', :type => :integer
attribute :object_count, :aliases => 'X-Account-Object-Count', :type => :integer
def save
service.post_set_meta_temp_url_key meta_temp_url_key
true
end
def reload
response = service.head_containers
merge_attributes response.headers
end
end
end
end
end

View file

@ -15,6 +15,7 @@ module Fog
collection :directories
model :file
collection :files
model :account
request_path 'fog/rackspace/requests/storage'
request :copy_object
@ -108,6 +109,11 @@ module Fog
@connection = Fog::Connection.new(endpoint_uri, @persistent, @connection_options)
end
def account
account = Fog::Storage::Rackspace::Account.new(:service => self)
account.reload
end
def ssl?
!rackspace_cdn_ssl.nil?
end

View file

@ -0,0 +1,15 @@
Shindo.tests('Fog::Volume[:openstack]', ['openstack', 'volume']) do
volume = Fog::Volume[:openstack]
tests("Volumes collection") do
%w{ volumes }.each do |collection|
test("it should respond to #{collection}") { volume.respond_to? collection }
test("it should respond to #{collection}.all") { eval("volume.#{collection}").respond_to? 'all' }
# not implemented
#test("it should respond to #{collection}.get") { eval("volume.#{collection}").respond_to? 'get' }
end
end
end

View file

@ -0,0 +1,28 @@
Shindo.tests('Fog::Rackspace::Storage | account', ['rackspace']) do
pending if Fog.mocking?
@account = Fog::Storage[:rackspace].account
tests('load') do
headers = @account.service.head_containers.headers
returns(headers['X-Account-Meta-Temp-Url-Key']) { @account.meta_temp_url_key }
returns(headers['X-Account-Container-Count'].to_i) { @account.container_count }
returns(headers['X-Account-Bytes-Used'].to_i) { @account.bytes_used }
returns(headers['X-Account-Object-Count'].to_i) { @account.object_count }
end
tests('reload') do
@account.reload
end
tests('save') do
key = "testing-update-#{Time.now.to_i}"
@account.meta_temp_url_key = "testing-update-#{Time.now.to_i}"
@account.save
headers = @account.service.head_containers.headers
returns(key) { headers['X-Account-Meta-Temp-Url-Key'] }
end
end

View file

@ -82,4 +82,10 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
end
end
tests('account').succeeds do
pending if Fog.mocking?
Fog::Storage[:rackspace].account
end
end