mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add services accessors and clarify vocab by not reusing service
This commit is contained in:
parent
fd755e042b
commit
dce5893555
10 changed files with 53 additions and 55 deletions
16
bin/fog
16
bin/fog
|
@ -24,17 +24,17 @@ else
|
|||
@irb.context.prompt_mode = :FOG
|
||||
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
||||
|
||||
services = Fog.services.map{|service| service.to_s}
|
||||
available_services = if services.length > 1
|
||||
services[0...-1].join(', ') << ' and ' << services[-1]
|
||||
modules = Fog.modules.map{|_module_| _module_.to_s}
|
||||
modules = if modules.length > 1
|
||||
modules[0...-1].join(', ') << ' and ' << modules[-1]
|
||||
else
|
||||
services.first
|
||||
modules.first
|
||||
end
|
||||
print "Welcome to fog interactive!\n"
|
||||
print "Your '#{Fog.credential.to_s}' configuration provides access to #{available_services}.\n"
|
||||
Fog.services.each do |service|
|
||||
if service.respond_to?(:startup_notice)
|
||||
service.send(:startup_notice)
|
||||
print "Your '#{Fog.credential.to_s}' configuration provides access to #{modules}.\n"
|
||||
Fog.modules.each do |_module_|
|
||||
if _module_.respond_to?(:startup_notice)
|
||||
_module_.send(:startup_notice)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ module AWS
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:ec2, :elb, :simpledb, :s3]
|
||||
end
|
||||
|
||||
for collection in Fog::AWS::EC2.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
|
|
|
@ -14,54 +14,20 @@ require 'fog/bluebox/bin'
|
|||
module Fog
|
||||
class << self
|
||||
|
||||
def services
|
||||
services = []
|
||||
[::AWS, ::GoGrid, ::Linode, ::Local, ::NewServers, ::Rackspace, ::Slicehost, ::Terremark, ::Vcloud, ::Bluebox].each do |service|
|
||||
if service.initialized?
|
||||
services << service
|
||||
end
|
||||
end
|
||||
services
|
||||
end
|
||||
def modules
|
||||
[
|
||||
::AWS,
|
||||
::GoGrid,
|
||||
::Linode,
|
||||
::Local,
|
||||
::NewServers,
|
||||
::Rackspace,
|
||||
::Slicehost,
|
||||
::Terremark,
|
||||
::Vcloud,
|
||||
::Bluebox
|
||||
].select {|_module_| _module_.initialized?}
|
||||
|
||||
def directories
|
||||
directories = {}
|
||||
services.each do |service|
|
||||
if service.respond_to?(:directories)
|
||||
directories[service] = service.directories
|
||||
end
|
||||
end
|
||||
directories
|
||||
end
|
||||
|
||||
def flavors
|
||||
flavors = {}
|
||||
services.each do |service|
|
||||
if service.respond_to?(:flavors)
|
||||
flavors[service] = service.flavors
|
||||
end
|
||||
end
|
||||
flavors
|
||||
end
|
||||
|
||||
def images
|
||||
images = {}
|
||||
services.each do |service|
|
||||
if service.respond_to?(:images)
|
||||
images[service] = service.images
|
||||
end
|
||||
end
|
||||
images
|
||||
end
|
||||
|
||||
def servers
|
||||
servers = {}
|
||||
services.each do |service|
|
||||
if service.respond_to?(:servers)
|
||||
servers[service] = service.servers
|
||||
end
|
||||
end
|
||||
servers
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,6 +17,10 @@ module Bluebox
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:blocks]
|
||||
end
|
||||
|
||||
for collection in Fog::Bluebox.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
|
|
|
@ -16,6 +16,10 @@ module GoGrid
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:go_grid]
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
def initialized?
|
||||
|
|
|
@ -16,6 +16,10 @@ module Linode
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:linode]
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
def initialized?
|
||||
|
|
|
@ -16,6 +16,10 @@ module Local
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:files]
|
||||
end
|
||||
|
||||
for collection in Fog::Local.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
|
|
|
@ -16,6 +16,10 @@ module NewServers
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:new_servers]
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
def initialized?
|
||||
|
|
|
@ -18,6 +18,10 @@ module Rackspace
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:files, :servers]
|
||||
end
|
||||
|
||||
for collection in Fog::Rackspace::Files.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
|
|
|
@ -16,6 +16,10 @@ module Slicehost
|
|||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:slices]
|
||||
end
|
||||
|
||||
for collection in Fog::Slicehost.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
|
|
Loading…
Reference in a new issue