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:
commit
3d4189416b
8 changed files with 86 additions and 2 deletions
|
@ -25,8 +25,7 @@ module Fog
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:idempotent => true,
|
:idempotent => true,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:parser => Fog::Parsers::Storage::AWS::GetService.new,
|
:parser => Fog::Parsers::Storage::AWS::GetService.new
|
||||||
:url => @host
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ class OpenStack < Fog::Bin
|
||||||
Fog::Network::OpenStack
|
Fog::Network::OpenStack
|
||||||
when :storage
|
when :storage
|
||||||
Fog::Storage::OpenStack
|
Fog::Storage::OpenStack
|
||||||
|
when :volume
|
||||||
|
Fog::Volume::OpenStack
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Unrecognized service: #{key}"
|
raise ArgumentError, "Unrecognized service: #{key}"
|
||||||
end
|
end
|
||||||
|
@ -36,6 +38,9 @@ class OpenStack < Fog::Bin
|
||||||
when :storage
|
when :storage
|
||||||
Fog::Logger.warning("OpenStack[:storage] is not recommended, use Storage[:openstack] for portability")
|
Fog::Logger.warning("OpenStack[:storage] is not recommended, use Storage[:openstack] for portability")
|
||||||
Fog::Storage.new(:provider => 'OpenStack')
|
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
|
else
|
||||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,6 +46,7 @@ module Fog
|
||||||
service(:identity, 'openstack/identity', 'Identity')
|
service(:identity, 'openstack/identity', 'Identity')
|
||||||
service(:network, 'openstack/network', 'Network')
|
service(:network, 'openstack/network', 'Network')
|
||||||
service(:storage, 'openstack/storage', 'Storage')
|
service(:storage, 'openstack/storage', 'Storage')
|
||||||
|
service(:volume, 'openstack/volume', 'Volume')
|
||||||
|
|
||||||
# legacy v1.0 style auth
|
# legacy v1.0 style auth
|
||||||
def self.authenticate_v1(options, connection_options = {})
|
def self.authenticate_v1(options, connection_options = {})
|
||||||
|
|
24
lib/fog/rackspace/models/storage/account.rb
Normal file
24
lib/fog/rackspace/models/storage/account.rb
Normal 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
|
|
@ -15,6 +15,7 @@ module Fog
|
||||||
collection :directories
|
collection :directories
|
||||||
model :file
|
model :file
|
||||||
collection :files
|
collection :files
|
||||||
|
model :account
|
||||||
|
|
||||||
request_path 'fog/rackspace/requests/storage'
|
request_path 'fog/rackspace/requests/storage'
|
||||||
request :copy_object
|
request :copy_object
|
||||||
|
@ -108,6 +109,11 @@ module Fog
|
||||||
@connection = Fog::Connection.new(endpoint_uri, @persistent, @connection_options)
|
@connection = Fog::Connection.new(endpoint_uri, @persistent, @connection_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def account
|
||||||
|
account = Fog::Storage::Rackspace::Account.new(:service => self)
|
||||||
|
account.reload
|
||||||
|
end
|
||||||
|
|
||||||
def ssl?
|
def ssl?
|
||||||
!rackspace_cdn_ssl.nil?
|
!rackspace_cdn_ssl.nil?
|
||||||
end
|
end
|
||||||
|
|
15
tests/openstack/volume_tests.rb
Normal file
15
tests/openstack/volume_tests.rb
Normal 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
|
||||||
|
|
28
tests/rackspace/models/storage/account_tests.rb
Normal file
28
tests/rackspace/models/storage/account_tests.rb
Normal 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
|
|
@ -82,4 +82,10 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests('account').succeeds do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
Fog::Storage[:rackspace].account
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue