Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
/.bundle/
/.yardoc
/Gemfile.lock
Expand Down
64 changes: 33 additions & 31 deletions fog-rackspace.gemspec

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions lib/fog/rackspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
require 'fog/json'

module Fog
module CDN
autoload :Rackspace, File.expand_path('../rackspace/cdn', __FILE__)
end

module Compute
autoload :Rackspace, File.expand_path('../rackspace/compute', __FILE__)
autoload :RackspaceV2, File.expand_path('../rackspace/compute_v2', __FILE__)
end

module DNS
autoload :Rackspace, File.expand_path('../rackspace/dns', __FILE__)
end

module Storage
autoload :Rackspace, File.expand_path('../rackspace/storage', __FILE__)
end

module Rackspace
autoload :Errors, File.expand_path('../rackspace/errors', __FILE__)
autoload :MockData, File.expand_path('../rackspace/mock_data', __FILE__)
Expand All @@ -36,7 +19,7 @@ module Rackspace
autoload :CDNV2, File.expand_path('../rackspace/cdn_v2', __FILE__)
autoload :Compute, File.expand_path('../rackspace/compute', __FILE__)
autoload :ComputeV2, File.expand_path('../rackspace/compute_v2', __FILE__)
autoload :Database, File.expand_path('../rackspace/databases', __FILE__)
autoload :Databases, File.expand_path('../rackspace/databases', __FILE__)
autoload :DNS, File.expand_path('../rackspace/dns', __FILE__)
autoload :Identity, File.expand_path('../rackspace/identity', __FILE__)
autoload :LoadBalancers, File.expand_path('../rackspace/load_balancers', __FILE__)
Expand All @@ -50,9 +33,9 @@ module Rackspace
service(:auto_scale, 'AutoScale')
service(:block_storage, 'BlockStorage')
service(:cdn, 'CDN')
service(:cdn_v2, 'CDN v2')
service(:cdn_v2, 'CDNV2')
service(:compute, 'Compute')
service(:compute_v2, 'Compute v2')
service(:compute_v2, 'ComputeV2')
service(:dns, 'DNS')
service(:storage, 'Storage')
service(:load_balancers, 'LoadBalancers')
Expand All @@ -66,7 +49,7 @@ module Rackspace

def self.authenticate(options, connection_options = {})
rackspace_auth_url = options[:rackspace_auth_url]
rackspace_auth_url ||= options[:rackspace_endpoint] == Fog::Compute::RackspaceV2::LON_ENDPOINT ? UK_AUTH_ENDPOINT : US_AUTH_ENDPOINT
rackspace_auth_url ||= options[:rackspace_endpoint] == Fog::Rackspace::ComputeV2::LON_ENDPOINT ? UK_AUTH_ENDPOINT : US_AUTH_ENDPOINT
url = rackspace_auth_url.match(/^https?:/) ? \
rackspace_auth_url : 'https://' + rackspace_auth_url
uri = URI.parse(url)
Expand Down Expand Up @@ -109,4 +92,23 @@ def self.escape(str,extra_exclude_chars = '')
end
end
end

# Backward compatibility aliases for Fog 2.4.0
# These allow existing code using the old Fog::Service::Rackspace pattern to continue working
module CDN
Rackspace = Fog::Rackspace::CDN
end

module Compute
Rackspace = Fog::Rackspace::Compute
RackspaceV2 = Fog::Rackspace::ComputeV2
end

module DNS
Rackspace = Fog::Rackspace::DNS
end

module Storage
Rackspace = Fog::Rackspace::Storage
end
end
36 changes: 18 additions & 18 deletions lib/fog/rackspace/cdn.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


module Fog
module CDN
class Rackspace < Fog::Service
module Rackspace
class CDN < Fog::Service
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url, :persistent, :rackspace_cdn_ssl, :rackspace_region, :rackspace_cdn_url

Expand Down Expand Up @@ -55,13 +55,13 @@ def endpoint_uri(service_endpoint_url=nil)
end

# Publish container to CDN
# @param [Fog::Storage::Rackspace::Directory] container directory to publish
# @param [Fog::Rackspace::Storage::Directory] container directory to publish
# @param [Boolean] publish If true directory is published. If false directory is unpublished.
# @return [Hash] hash containing urls for published container
# @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404
# @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400
# @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500
# @raise [Fog::Storage::Rackspace::ServiceError]
# @raise [Fog::Rackspace::Storage::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Storage::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Storage::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Storage::ServiceError]
def publish_container(container, publish = true)
enabled = publish ? 'True' : 'False'
response = put_container(container.key, 'X-Cdn-Enabled' => enabled)
Expand All @@ -70,11 +70,11 @@ def publish_container(container, publish = true)
end

# Returns hash of urls for container
# @param [Fog::Storage::Rackspace::Directory] container to retrieve urls for
# @param [Fog::Rackspace::Storage::Directory] container to retrieve urls for
# @return [Hash] hash containing urls for published container
# @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400
# @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500
# @raise [Fog::Storage::Rackspace::ServiceError]
# @raise [Fog::Rackspace::Storage::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Storage::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Storage::ServiceError]
# @note If unable to find container or container is not published this method will return an empty hash.
def urls(container)
begin
Expand Down Expand Up @@ -122,7 +122,7 @@ def data
end

def purge(object)
return true if object.is_a? Fog::Storage::Rackspace::File
return true if object.is_a? Fog::Rackspace::Storage::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
end

Expand Down Expand Up @@ -152,10 +152,10 @@ def reload
end

# Purges File
# @param [Fog::Storage::Rackspace::File] file to be purged from the CDN
# @param [Fog::Rackspace::Storage::File] file to be purged from the CDN
# @raise [Fog::Errors::NotImplemented] returned when non file parameters are specified
def purge(file)
unless file.is_a? Fog::Storage::Rackspace::File
unless file.is_a? Fog::Rackspace::Storage::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
end

Expand All @@ -166,13 +166,13 @@ def purge(file)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise Fog::Storage::Rackspace::NotFound.slurp(error, self)
raise Fog::Rackspace::Storage::NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
raise Fog::Storage::Rackspace::BadRequest.slurp(error, self)
raise Fog::Rackspace::Storage::BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise Fog::Storage::Rackspace::InternalServerError.slurp(error, self)
raise Fog::Rackspace::Storage::InternalServerError.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise Fog::Storage::Rackspace::ServiceError.slurp(error, self)
raise Fog::Rackspace::Storage::ServiceError.slurp(error, self)
end

private
Expand Down
7 changes: 5 additions & 2 deletions lib/fog/rackspace/compute.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


module Fog
module Compute
class Rackspace < Fog::Service
module Rackspace
class Compute < Fog::Service
include Fog::Rackspace::Errors

class ServiceError < Fog::Rackspace::Errors::ServiceError; end
Expand Down Expand Up @@ -253,4 +253,7 @@ def authenticate_v1(options)
end
end
end

# fog-core 2.4.0 still users this definition
Compute::Rackspace = Fog::Rackspace::Compute
end
7 changes: 5 additions & 2 deletions lib/fog/rackspace/compute_v2.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


module Fog
module Compute
class RackspaceV2 < Fog::Service
module Rackspace
class ComputeV2 < Fog::Service
include Fog::Rackspace::Errors

class ServiceError < Fog::Rackspace::Errors::ServiceError; end
Expand Down Expand Up @@ -250,4 +250,7 @@ def authenticate_v1(options)
end
end
end

# fog-core 2.4.0 still has this definitaion
Compute::RackspaceV2 = Fog::Rackspace::ComputeV2
end
4 changes: 2 additions & 2 deletions lib/fog/rackspace/dns.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


module Fog
module DNS
class Rackspace < Fog::Service
module Rackspace
class DNS < Fog::Service
include Fog::Rackspace::Errors

class ServiceError < Fog::Rackspace::Errors::ServiceError; end
Expand Down
18 changes: 9 additions & 9 deletions lib/fog/rackspace/docs/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,17 @@ To retrieve a list of directories:

service.directories

This returns a collection of `Fog::Storage::Rackspace::Directory` models:
This returns a collection of `Fog::Rackspace::Storage::Directory` models:

<Fog::Storage::Rackspace::Directories
<Fog::Rackspace::Storage::Directories
[
<Fog::Storage::Rackspace::Directory
<Fog::Rackspace::Storage::Directory
key="blue",
bytes=434266,
count=1,
cdn_cname=nil
>,
<Fog::Storage::Rackspace::Directory
<Fog::Rackspace::Storage::Directory
key="brown",
bytes=761879,
count=1,
Expand All @@ -277,9 +277,9 @@ This call is similar to...

... except the `get` method makes an HTTP call that returns metadata for up to the first 10,000 files. **This can be slow!**

This returns a `Fog::Storage::Rackspace::Directory` instance:
This returns a `Fog::Rackspace::Storage::Directory` instance:

<Fog::Storage::Rackspace::Directory
<Fog::Rackspace::Storage::Directory
key="blue",
bytes=434266,
count=1,
Expand Down Expand Up @@ -471,7 +471,7 @@ To stream video for iOS devices without needing to convert your video use the fo

## Metadata

You can access metadata as an attribute on both `Fog::Storage::Rackspace::Directory` and `Fog::Storage::Rackspace::File`.
You can access metadata as an attribute on both `Fog::Rackspace::Storage::Directory` and `Fog::Rackspace::Storage::File`.

This example demonstrates how to iterate through a directory's metadata:

Expand Down Expand Up @@ -528,9 +528,9 @@ To view Cloud Files usage execute the following:

service.account

This returns a `Fog::Storage::Rackspace::Account` instance:
This returns a `Fog::Rackspace::Storage::Account` instance:

<Fog::Storage::Rackspace::Account
<Fog::Rackspace::Storage::Account
meta_temp_url_key="lkkl23jl2j3",
container_count=13,
bytes_used=2563554,
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/rackspace/models/compute_v2/virtual_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
require 'fog/rackspace/models/compute_v2/virtual_interface'

module Fog
module Compute
class RackspaceV2
module Rackspace
class ComputeV2
class VirtualInterface < Fog::Model
# @!attribute [r] id
# @return [String] The virtual interface id
Expand Down
12 changes: 10 additions & 2 deletions lib/fog/rackspace/models/load_balancers/load_balancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def nodes
end

def nodes=(new_nodes=[])
nodes.load(new_nodes)
# fog-core 2.5.0+ requires hashes for collection.new, not model instances
normalized_nodes = new_nodes.map do |node|
node.is_a?(Fog::Rackspace::LoadBalancers::Node) ? node.attributes : node
end
nodes.load(normalized_nodes)
end

def https_redirect
Expand Down Expand Up @@ -108,7 +112,11 @@ def virtual_ips
end

def virtual_ips=(new_virtual_ips=[])
virtual_ips.load(new_virtual_ips)
# fog-core 2.5.0+ requires hashes for collection.new, not model instances
normalized_ips = new_virtual_ips.map do |vip|
vip.is_a?(Fog::Rackspace::LoadBalancers::VirtualIp) ? vip.attributes : vip
end
virtual_ips.load(normalized_ips)
end

def enable_content_caching
Expand Down
22 changes: 11 additions & 11 deletions lib/fog/rackspace/models/storage/account.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'fog/core/model'

module Fog
module Storage
class Rackspace
module Rackspace
class Storage
class Account < Fog::Model
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View_Account_Info-d1e11995.html

Expand All @@ -25,21 +25,21 @@ class Account < Fog::Model

# Saves account settings (meta_temp_url_key)
# @return [Boolean] returns true if successfully updated
# @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404
# @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400
# @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500
# @raise [Fog::Storage::Rackspace::ServiceError]
# @raise [Fog::Rackspace::Storage::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Storage::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Storage::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Storage::ServiceError]
def save
service.post_set_meta_temp_url_key meta_temp_url_key
true
end

# Reload account with latest data from Cloud Files
# @return [Fog::Storage::Rackspace::Account] returns itself
# @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404
# @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400
# @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500
# @raise [Fog::Storage::Rackspace::ServiceError]
# @return [Fog::Rackspace::Storage::Account] returns itself
# @raise [Fog::Rackspace::Storage::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Storage::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Storage::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Storage::ServiceError]
def reload
response = service.head_containers
merge_attributes response.headers
Expand Down
Loading