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

deprecate old initializers

This commit is contained in:
geemus 2011-01-07 18:14:39 -08:00
parent 0a85cd8a9a
commit bc25028c2f
22 changed files with 274 additions and 5 deletions

View file

@ -3,7 +3,7 @@ module Fog
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider)
case provider = attributes[:provider] # attributes.delete(:provider)
when 'AWS'
require 'fog/cdn/aws'
Fog::AWS::CDN.new(attributes)

View file

@ -4,6 +4,7 @@ module Fog
requires :aws_access_key_id, :aws_secret_access_key
recognizes :host, :path, :port, :scheme, :version, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/cdn/models/aws'
@ -34,6 +35,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::CDN.new is deprecated, use Fog::CDN.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@aws_access_key_id = options[:aws_access_key_id]
@data = self.class.data[options[:region]][@aws_access_key_id]
@ -64,6 +72,13 @@ module Fog
# ==== Returns
# * cdn object with connection to aws.
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::CDN.new is deprecated, use Fog::CDN.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)

View file

@ -4,6 +4,7 @@ module Fog
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/cdn/models/rackspace'
@ -27,6 +28,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::CDN.new is deprecated, use Fog::CDN.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@rackspace_username = options[:rackspace_username]
@data = self.class.data[@rackspace_username]
end
@ -36,6 +44,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::CDN.new is deprecated, use Fog::CDN.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'json'
credentials = Fog::Rackspace.authenticate(options)
@auth_token = credentials['X-Auth-Token']

View file

@ -3,7 +3,7 @@ module Fog
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider)
case provider = attributes[:provider] # attributes.delete(:provider)
when 'AWS'
require 'fog/compute/aws'
Fog::AWS::Compute.new(attributes)

View file

@ -20,6 +20,7 @@ module Fog
requires :aws_access_key_id, :aws_secret_access_key
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/aws'
model :address
@ -145,6 +146,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::Compute.new is deprecated, use Fog::Compute.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@aws_access_key_id = options[:aws_access_key_id]
@region = options[:region] || 'us-east-1'
@data = self.class.data[@region][@aws_access_key_id]
@ -174,6 +182,13 @@ module Fog
# ==== Returns
# * EC2 object with connection to aws.
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::Compute.new is deprecated, use Fog::Compute.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)

View file

@ -4,6 +4,7 @@ module Fog
requires :bluebox_api_key, :bluebox_customer_id
recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/bluebox'
model :flavor
@ -39,6 +40,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Bluebox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Bluebox') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@bluebox_api_key = options[:bluebox_api_key]
@data = self.class.data[@bluebox_api_key]
end
@ -48,6 +56,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Bluebox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Bluebox') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'json'
@bluebox_api_key = options[:bluebox_api_key]
@bluebox_customer_id = options[:bluebox_customer_id]

View file

@ -6,6 +6,7 @@ module Fog
requires :brightbox_client_id, :brightbox_secret
recognizes :brightbox_auth_url, :brightbox_api_url
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/brightbox'
model :account # Singular resource, no collection
@ -73,6 +74,13 @@ module Fog
class Mock
def initialize(options)
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Brightbox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Brightbox') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
end
@ -85,6 +93,13 @@ module Fog
class Real
def initialize(options)
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Brightbox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Brightbox') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require "json"
# Currently authentication and api endpoints are the same but may change
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL

View file

@ -4,6 +4,7 @@ module Fog
requires :go_grid_api_key, :go_grid_shared_secret
recognizes :host, :path, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/go_grid'
model :image
@ -38,6 +39,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::GoGrid::Compute.new is deprecated, use Fog::Compute.new(:provider => 'GoGrid') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@go_grid_api_key = options[:go_grid_api_key]
@go_grid_shared_secret = options[:go_grid_shared_secret]
@data = self.class.data[@go_grid_api_key]
@ -48,6 +56,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::GoGrid::Compute.new is deprecated, use Fog::Compute.new(:provider => 'GoGrid') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'digest/md5'
require 'json'
@go_grid_api_key = options[:go_grid_api_key]

View file

@ -4,6 +4,7 @@ module Fog
requires :linode_api_key
recognizes :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/linode'
@ -37,6 +38,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Linode::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Linode') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@linode_api_key = options[:linode_api_key]
@data = self.class.data[@linode_api_key]
end
@ -46,6 +54,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Linode::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Linode') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'json'
@linode_api_key = options[:linode_api_key]
@host = options[:host] || "api.linode.com"

View file

@ -6,6 +6,7 @@ module Fog
requires :new_servers_password, :new_servers_username
recognizes :host, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/new_servers'
@ -33,6 +34,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::NewServers::Compute.new is deprecated, use Fog::Compute.new(:provider => 'NewServers') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@new_server_username = options[:new_servers_username]
@data = self.class.data[@new_server_username]
end
@ -42,6 +50,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::NewServers::Compute.new is deprecated, use Fog::Compute.new(:provider => 'NewServers') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@new_servers_password = options[:new_servers_password]
@new_servers_username = options[:new_servers_username]
@host = options[:host] || "noc.newservers.com"

View file

@ -20,6 +20,7 @@ module Fog
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/rackspace'
model :flavor
@ -75,6 +76,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@rackspace_username = options[:rackspace_username]
@data = self.class.data[@rackspace_username]
end
@ -84,6 +92,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'json'
credentials = Fog::Rackspace.authenticate(options)
@auth_token = credentials['X-Auth-Token']

View file

@ -4,6 +4,7 @@ module Fog
requires :slicehost_password
recognizes :host, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/compute/models/slicehost'
model :flavor
@ -40,6 +41,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Slicehost::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Slicehost') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@slicehost_password = options[:slicehost_password]
@data = self.class.data[@slicehost_password]
end
@ -49,6 +57,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Slicehost::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Slicehost') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@slicehost_password = options[:slicehost_password]
@host = options[:host] || "api.slicehost.com"
@port = options[:port] || 443

View file

@ -3,7 +3,7 @@ module Fog
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider)
case provider = attributes[:provider] # attributes.delete(:provider)
when 'AWS'
require 'fog/dns/aws'
Fog::AWS::DNS.new(attributes)

View file

@ -4,6 +4,7 @@ module Fog
requires :aws_access_key_id, :aws_secret_access_key
recognizes :host, :path, :port, :scheme, :version, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/dns/models/aws'
model :record
@ -39,6 +40,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::DNS.new is deprecated, use Fog::DNS.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@aws_access_key_id = options[:aws_access_key_id]
@data = self.class.data[options[:region]][@aws_access_key_id]
@ -69,6 +77,13 @@ module Fog
# ==== Returns
# * dns object with connection to aws.
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::DNS.new is deprecated, use Fog::Storage.new(:provider => 'DNS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)

View file

@ -4,6 +4,7 @@ module Fog
requires :linode_api_key
recognizes :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/dns/models/linode'
model :record
@ -36,6 +37,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Linode::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Linode') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@linode_api_key = options[:linode_api_key]
@data = self.class.data[@linode_api_key]
end
@ -45,6 +53,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Linode::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Linode') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'json'
@linode_api_key = options[:linode_api_key]
@host = options[:host] || "api.linode.com"

View file

@ -4,6 +4,7 @@ module Fog
requires :slicehost_password
recognizes :host, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/dns/models/slicehost'
model :record
@ -36,6 +37,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Slicehost::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Slicehost') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@slicehost_password = options[:slicehost_password]
@data = self.class.data[@slicehost_password]
end
@ -45,6 +53,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Slicehost::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Slicehost') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@slicehost_password = options[:slicehost_password]
@host = options[:host] || "api.slicehost.com"
@port = options[:port] || 443

View file

@ -4,6 +4,7 @@ module Fog
requires :zerigo_email, :zerigo_token
recognizes :timeout, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/dns/models/zerigo'
model :record
@ -42,6 +43,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Zerigo::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Zerigo') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@zerigo_email = options[:zerigo_email]
@zerigo_token = options[:zerigo_token]
@data = self.class.data[@zerigo_email]
@ -53,7 +61,14 @@ module Fog
class Real
def initialize(options={})
@zerigo_email = options[:zerigo_email]
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Zerigo::DNS.new is deprecated, use Fog::DNS.new(:provider => 'Zerigo') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@zerigo_email = options[:zerigo_email]
@zerigo_token = options[:zerigo_token]
@host = options[:host] || "ns.zerigo.com"
@port = options[:port] || 80

View file

@ -3,7 +3,7 @@ module Fog
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider)
case provider = attributes[:provider] # attributes.delete(:provider)
when 'AWS'
require 'fog/storage/aws'
Fog::AWS::Storage.new(attributes)

View file

@ -20,6 +20,7 @@ module Fog
requires :aws_access_key_id, :aws_secret_access_key
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/storage/models/aws'
collection :directories
@ -170,6 +171,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::Storage.new is deprecated, use Fog::Storage.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@ -218,6 +226,12 @@ module Fog
# ==== Returns
# * S3 object with connection to aws.
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::AWS::Storage.new is deprecated, use Fog::Storage.new(:provider => 'AWS') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]

View file

@ -4,6 +4,7 @@ module Fog
requires :google_storage_access_key_id, :google_storage_secret_access_key
recognizes :host, :port, :scheme, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/storage/models/google'
collection :directories
@ -127,6 +128,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Google::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Google') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@google_storage_access_key_id = options[:google_storage_access_key_id]
@data = self.class.data[@google_storage_access_key_id]
@ -161,6 +169,13 @@ module Fog
# ==== Returns
# * Storage object with connection to google.
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Google::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Google') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@google_storage_access_key_id = options[:google_storage_access_key_id]
@google_storage_secret_access_key = options[:google_storage_secret_access_key]

View file

@ -3,6 +3,7 @@ module Fog
class Storage < Fog::Service
requires :local_root
recognizes :provider # remove post deprecation
model_path 'fog/storage/models/local'
collection :directories
@ -25,6 +26,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@local_root = ::File.expand_path(options[:local_root])
@data = self.class.data[@local_root]
end
@ -41,6 +49,13 @@ module Fog
class Real
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
@local_root = ::File.expand_path(options[:local_root])
end

View file

@ -20,6 +20,7 @@ module Fog
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url, :persistent
recognizes :provider # remove post deprecation
model_path 'fog/storage/models/rackspace'
model :directory
@ -87,6 +88,13 @@ module Fog
end
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@ -99,6 +107,13 @@ module Fog
include Utils
def initialize(options={})
unless options.delete(:provider)
location = caller.first
warning = "[yellow][WARN] Fog::Rackspace::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Rackspace') instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
end
require 'mime/types'
require 'json'
@rackspace_api_key = options[:rackspace_api_key]