mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
providers abstraction, more consolidated bin stuff between providers
This commit is contained in:
parent
71e4f64024
commit
07dbdf6952
12 changed files with 246 additions and 362 deletions
11
bin/fog
11
bin/fog
|
@ -24,14 +24,15 @@ else
|
||||||
@irb.context.prompt_mode = :FOG
|
@irb.context.prompt_mode = :FOG
|
||||||
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
||||||
|
|
||||||
modules = Fog.modules.map{|_module_| _module_.to_s}
|
providers = Fog.providers.map{|provider| provider.to_s}
|
||||||
modules = if modules.length > 1
|
providers = if providers.length > 1
|
||||||
modules[0...-1].join(', ') << ' and ' << modules[-1]
|
providers[0...-1].join(', ') << ' and ' << providers[-1]
|
||||||
else
|
else
|
||||||
modules.first
|
providers.first
|
||||||
end
|
end
|
||||||
Formatador.display_line('Welcome to fog interactive!')
|
Formatador.display_line('Welcome to fog interactive!')
|
||||||
Formatador.display_line(":#{Fog.credential.to_s} credentials provide #{modules}")
|
Formatador.display_line(":#{Fog.credential.to_s} credentials provide #{providers}")
|
||||||
|
providers = Fog.providers
|
||||||
Fog.modules.each do |_module_|
|
Fog.modules.each do |_module_|
|
||||||
if _module_.respond_to?(:startup_notice)
|
if _module_.respond_to?(:startup_notice)
|
||||||
_module_.send(:startup_notice)
|
_module_.send(:startup_notice)
|
||||||
|
|
|
@ -1,67 +1,37 @@
|
||||||
module AWS
|
class AWS < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
if Fog.credentials[:aws_access_key_id] && Fog.credentials[:aws_secret_access_key]
|
def [](service)
|
||||||
|
@@connections ||= Hash.new do |hash, key|
|
||||||
def initialized?
|
hash[key] = case key
|
||||||
true
|
when :compute
|
||||||
end
|
Fog::AWS::Compute.new
|
||||||
|
when :ec2
|
||||||
def [](service)
|
location = caller.first
|
||||||
@@connections ||= Hash.new do |hash, key|
|
warning = "[yellow][WARN] AWS[:ec2] is deprecated, use AWS[:compute] instead[/]"
|
||||||
hash[key] = case key
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :compute
|
Formatador.display_line(warning)
|
||||||
Fog::AWS::Compute.new
|
Fog::AWS::Compute.new
|
||||||
when :ec2
|
when :elb
|
||||||
location = caller.first
|
Fog::AWS::ELB.new
|
||||||
warning = "[yellow][WARN] AWS[:ec2] is deprecated, use AWS[:compute] instead[/]"
|
when :simpledb
|
||||||
warning << " [light_black](" << location << ")[/] "
|
Fog::AWS::SimpleDB.new
|
||||||
Formatador.display_line(warning)
|
when :s3
|
||||||
Fog::AWS::Compute.new
|
location = caller.first
|
||||||
when :elb
|
warning = "[yellow][WARN] AWS[:s3] is deprecated, use AWS[:storage] instead[/]"
|
||||||
Fog::AWS::ELB.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :simpledb
|
Formatador.display_line(warning)
|
||||||
Fog::AWS::SimpleDB.new
|
Fog::AWS::Storage.new
|
||||||
when :s3
|
when :storage
|
||||||
location = caller.first
|
Fog::AWS::Storage.new
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:compute, :elb, :simpledb, :storage]
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::AWS::Compute.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:compute].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::AWS::Storage.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:storage].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute, :elb, :simpledb, :storage]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
require 'fog/credentials'
|
require 'fog/credentials'
|
||||||
|
|
||||||
require 'fog/aws/bin'
|
|
||||||
require 'fog/go_grid/bin'
|
|
||||||
require 'fog/linode/bin'
|
|
||||||
require 'fog/local/bin'
|
|
||||||
require 'fog/new_servers/bin'
|
|
||||||
require 'fog/rackspace/bin'
|
|
||||||
require 'fog/slicehost/bin'
|
|
||||||
require 'fog/terremark/bin'
|
|
||||||
require 'fog/vcloud/bin'
|
|
||||||
require 'fog/bluebox/bin'
|
|
||||||
|
|
||||||
module Fog
|
module Fog
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
def modules
|
def providers
|
||||||
[
|
[
|
||||||
::AWS,
|
::AWS,
|
||||||
::Bluebox,
|
::Bluebox,
|
||||||
|
@ -24,10 +13,63 @@ module Fog
|
||||||
::NewServers,
|
::NewServers,
|
||||||
::Rackspace,
|
::Rackspace,
|
||||||
::Slicehost,
|
::Slicehost,
|
||||||
::Terremark,
|
::Terremark
|
||||||
|
].select {|provider| provider.available?}
|
||||||
|
end
|
||||||
|
|
||||||
|
def modules
|
||||||
|
[
|
||||||
::Vcloud
|
::Vcloud
|
||||||
].select {|_module_| _module_.initialized?}
|
].select {|_module_| _module_.initialized?}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Bin
|
||||||
|
class << self
|
||||||
|
|
||||||
|
def available?
|
||||||
|
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
|
||||||
|
availability = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if availability
|
||||||
|
for service in services
|
||||||
|
for collection in self[service].collections
|
||||||
|
self.class_eval <<-EOS, __FILE__, __LINE__
|
||||||
|
def #{collection}
|
||||||
|
self[:#{service}].#{collection}
|
||||||
|
end
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
availability
|
||||||
|
end
|
||||||
|
|
||||||
|
def collections
|
||||||
|
services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'fog/aws/bin'
|
||||||
|
require 'fog/bluebox/bin'
|
||||||
|
require 'fog/go_grid/bin'
|
||||||
|
require 'fog/linode/bin'
|
||||||
|
require 'fog/local/bin'
|
||||||
|
require 'fog/new_servers/bin'
|
||||||
|
require 'fog/rackspace/bin'
|
||||||
|
require 'fog/slicehost/bin'
|
||||||
|
require 'fog/terremark/bin'
|
||||||
|
require 'fog/vcloud/bin'
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
module Bluebox
|
class Bluebox < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
if Fog.credentials[:bluebox_api_key]
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def [](service)
|
def [](service)
|
||||||
@@connections ||= Hash.new do |hash, key|
|
@@connections ||= Hash.new do |hash, key|
|
||||||
hash[key] = case key
|
hash[key] = case key
|
||||||
|
@ -27,20 +21,5 @@ module Bluebox
|
||||||
[:compute]
|
[:compute]
|
||||||
end
|
end
|
||||||
|
|
||||||
for collection in Fog::Bluebox::Compute.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:compute].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,25 @@
|
||||||
module GoGrid
|
class GoGrid < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:go_grid_api_key] && Fog.credentials[:go_grid_shared_secret]
|
|
||||||
|
|
||||||
def initialized?
|
def [](service)
|
||||||
true
|
@@connections ||= Hash.new do |hash, key|
|
||||||
end
|
hash[key] = case key
|
||||||
|
when :compute
|
||||||
def [](service)
|
Fog::GoGrid::Compute.new
|
||||||
@@connections ||= Hash.new do |hash, key|
|
when :servers
|
||||||
hash[key] = case key
|
location = caller.first
|
||||||
when :compute
|
warning = "[yellow][WARN] GoGrid[:servers] is deprecated, use GoGrid[:compute] instead[/]"
|
||||||
Fog::GoGrid::Compute.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :servers
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::GoGrid::Compute.new
|
||||||
warning = "[yellow][WARN] GoGrid[:servers] is deprecated, use GoGrid[:compute] instead[/]"
|
|
||||||
warning << " [light_black](" << location << ")[/] "
|
|
||||||
Formatador.display_line(warning)
|
|
||||||
Fog::GoGrid::Compute.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:compute]
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,25 @@
|
||||||
module Linode
|
class Linode < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:linode_api_key]
|
|
||||||
|
|
||||||
def initialized?
|
def [](service)
|
||||||
true
|
@@connections ||= Hash.new do |hash, key|
|
||||||
end
|
hash[key] = case key
|
||||||
|
when :compute
|
||||||
def [](service)
|
Fog::Linode::Compute.new
|
||||||
@@connections ||= Hash.new do |hash, key|
|
when :linode
|
||||||
hash[key] = case key
|
location = caller.first
|
||||||
when :compute
|
warning = "[yellow][WARN] Linode[:linode] is deprecated, use Linode[:compute] instead[/]"
|
||||||
Fog::Linode::Compute.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :linode
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::Linode::Compute.new
|
||||||
warning = "[yellow][WARN] Linode[:linode] is deprecated, use Linode[:compute] instead[/]"
|
|
||||||
warning << " [light_black](" << location << ")[/] "
|
|
||||||
Formatador.display_line(warning)
|
|
||||||
Fog::Linode::Compute.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:compute]
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,45 +1,25 @@
|
||||||
module Local
|
class Local < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:local_root]
|
|
||||||
|
|
||||||
def initialized?
|
def [](service)
|
||||||
true
|
@@connections ||= Hash.new do |hash, key|
|
||||||
end
|
hash[key] = case key
|
||||||
|
when :files
|
||||||
def [](service)
|
location = caller.first
|
||||||
@@connections ||= Hash.new do |hash, key|
|
warning = "[yellow][WARN] Local[:files] is deprecated, use Local[:storage] instead[/]"
|
||||||
hash[key] = case key
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :files
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::Local::Storage.new
|
||||||
warning = "[yellow][WARN] Local[:files] is deprecated, use Local[:storage] instead[/]"
|
when :storage
|
||||||
warning << " [light_black](" << location << ")[/] "
|
Fog::Local::Storage.new
|
||||||
Formatador.display_line(warning)
|
|
||||||
Fog::Local::Storage.new
|
|
||||||
when :storage
|
|
||||||
Fog::Local::Storage.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:storage]
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::Local::Storage.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:storage].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:storage]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,25 @@
|
||||||
module NewServers
|
class NewServers < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:new_servers_password] && Fog.credentials[:new_servers_username]
|
|
||||||
|
|
||||||
def initialized?
|
def [](service)
|
||||||
true
|
@@connections ||= Hash.new do |hash, key|
|
||||||
end
|
hash[key] = case key
|
||||||
|
when :compute
|
||||||
def [](service)
|
Fog::NewServers::Compute.new
|
||||||
@@connections ||= Hash.new do |hash, key|
|
when :new_servers
|
||||||
hash[key] = case key
|
location = caller.first
|
||||||
when :compute
|
warning = "[yellow][WARN] NewServers[:servers] is deprecated, use NewServers[:compute] instead[/]"
|
||||||
Fog::NewServers::Compute.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :new_servers
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::NewServers::Compute.new
|
||||||
warning = "[yellow][WARN] NewServers[:servers] is deprecated, use NewServers[:compute] instead[/]"
|
|
||||||
warning << " [light_black](" << location << ")[/] "
|
|
||||||
Formatador.display_line(warning)
|
|
||||||
Fog::NewServers::Compute.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:compute]
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,61 +1,33 @@
|
||||||
module Rackspace
|
class Rackspace < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:rackspace_api_key] && Fog.credentials[:rackspace_username]
|
|
||||||
|
|
||||||
def initialized?
|
def [](service)
|
||||||
true
|
@@connections ||= Hash.new do |hash, key|
|
||||||
end
|
hash[key] = case key
|
||||||
|
when :compute
|
||||||
def [](service)
|
Fog::Rackspace::Compute.new
|
||||||
@@connections ||= Hash.new do |hash, key|
|
when :files
|
||||||
hash[key] = case key
|
location = caller.first
|
||||||
when :compute
|
warning = "[yellow][WARN] Rackspace[:files] is deprecated, use Rackspace[:storage] instead[/]"
|
||||||
Fog::Rackspace::Compute.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :files
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::Rackspace::Storage.new
|
||||||
warning = "[yellow][WARN] Rackspace[:files] is deprecated, use Rackspace[:storage] instead[/]"
|
when :servers
|
||||||
warning << " [light_black](" << location << ")[/] "
|
location = caller.first
|
||||||
Formatador.display_line(warning)
|
warning = "[yellow][WARN] Rackspace[:servers] is deprecated, use Rackspace[:compute] instead[/]"
|
||||||
Fog::Rackspace::Storage.new
|
warning << " [light_black](" << location << ")[/] "
|
||||||
when :servers
|
Formatador.display_line(warning)
|
||||||
location = caller.first
|
Fog::Rackspace::Compute.new
|
||||||
warning = "[yellow][WARN] Rackspace[:servers] is deprecated, use Rackspace[:compute] instead[/]"
|
when :storage
|
||||||
warning << " [light_black](" << location << ")[/] "
|
Fog::Rackspace::Storage.new
|
||||||
Formatador.display_line(warning)
|
|
||||||
Fog::Rackspace::Compute.new
|
|
||||||
when :storage
|
|
||||||
Fog::Rackspace::Storage.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@connections[service]
|
|
||||||
end
|
end
|
||||||
|
@@connections[service]
|
||||||
def services
|
|
||||||
[:compute, :storage]
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::Rackspace::Compute.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:compute].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::Rackspace::Storage.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:storage].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute, :storage]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,45 +1,29 @@
|
||||||
module Slicehost
|
class Slicehost < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if Fog.credentials[:slicehost_password]
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def [](service)
|
|
||||||
@@connections ||= Hash.new do |hash, key|
|
|
||||||
hash[key] = case key
|
|
||||||
when :compute
|
|
||||||
Fog::Slicehost::Compute.new
|
|
||||||
when :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
|
|
||||||
end
|
|
||||||
@@connections[service]
|
|
||||||
end
|
|
||||||
|
|
||||||
def services
|
|
||||||
[:compute]
|
|
||||||
end
|
|
||||||
|
|
||||||
for collection in Fog::Slicehost::Compute.collections
|
|
||||||
module_eval <<-EOS, __FILE__, __LINE__
|
|
||||||
def #{collection}
|
|
||||||
self[:compute].#{collection}
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def initialized?
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def [](service)
|
||||||
|
@@connections ||= Hash.new do |hash, key|
|
||||||
|
hash[key] = case key
|
||||||
|
when :compute
|
||||||
|
Fog::Slicehost::Compute.new
|
||||||
|
when :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
|
||||||
|
end
|
||||||
|
@@connections[service]
|
||||||
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:compute]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,44 +1,36 @@
|
||||||
module Terremark
|
class Terremark < Fog::Bin
|
||||||
class << self
|
class << self
|
||||||
if (Fog::Terremark::ECLOUD_OPTIONS.all? { |option| Fog.credentials.has_key?(option) } ) ||
|
|
||||||
(Fog::Terremark::VCLOUD_OPTIONS.all? { |option| Fog.credentials.has_key?(option) } )
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def terremark_service(service)
|
|
||||||
case service
|
|
||||||
when :ecloud
|
|
||||||
Fog::Terremark::Ecloud
|
|
||||||
when :vcloud
|
|
||||||
Fog::Terremark::Vcloud
|
|
||||||
else
|
|
||||||
raise "Unsupported Terremark Service"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def [](service)
|
|
||||||
@@connections ||= Hash.new do |hash, key|
|
|
||||||
credentials = Fog.credentials.reject do |k,v|
|
|
||||||
case key
|
|
||||||
when :ecloud
|
|
||||||
!Fog::Terremark::ECLOUD_OPTIONS.include?(k)
|
|
||||||
when :vcloud
|
|
||||||
!Fog::Terremark::VCLOUD_OPTIONS.include?(k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
hash[key] = terremark_service(key).new(credentials)
|
|
||||||
end
|
|
||||||
@@connections[service]
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
def initialized?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def available?
|
||||||
|
Fog::Terremark::ECLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)} ||
|
||||||
|
Fog::Terremark::VCLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def terremark_service(service)
|
||||||
|
case service
|
||||||
|
when :ecloud
|
||||||
|
Fog::Terremark::Ecloud
|
||||||
|
when :vcloud
|
||||||
|
Fog::Terremark::Vcloud
|
||||||
|
else
|
||||||
|
raise "Unsupported Terremark Service"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](service)
|
||||||
|
@@connections ||= Hash.new do |hash, key|
|
||||||
|
credentials = Fog.credentials.reject do |k,v|
|
||||||
|
case key
|
||||||
|
when :ecloud
|
||||||
|
!Fog::Terremark::ECLOUD_OPTIONS.include?(k)
|
||||||
|
when :vcloud
|
||||||
|
!Fog::Terremark::VCLOUD_OPTIONS.include?(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hash[key] = terremark_service(key).new(credentials)
|
||||||
|
end
|
||||||
|
@@connections[service]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Vcloud
|
||||||
end
|
end
|
||||||
|
|
||||||
def startup_notice
|
def startup_notice
|
||||||
puts "You have access to the following vCloud services: #{Vcloud.registered_services}."
|
Formatador.display_line("You have access to the following Vcloud services: #{Vcloud.registered_services}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](service)
|
def [](service)
|
||||||
|
|
Loading…
Reference in a new issue