incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Added command line switch to list all available drivers for current API instance
Date Tue, 02 Aug 2011 09:37:07 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/bin/deltacloudd |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/server/bin/deltacloudd b/server/bin/deltacloudd
index a0b108f..1142756 100755
--- a/server/bin/deltacloudd
+++ b/server/bin/deltacloudd
@@ -46,6 +46,7 @@ BANNER
   end
   opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env]
= env }
   opts.on( '-s', '--ssl', 'Enable SSL (default: disabled)') { |env| options[:ssl] = true
}
+  opts.on( '-l', '--list', 'List available drivers') { |env| options[:drivers] = true }
   opts.on( '-t', '--timeout TIMEOUT', 'Timeout for single request (default: 60)') do |timeout|
     ENV["API_TIMEOUT"] = timeout
   end
@@ -78,7 +79,7 @@ if options[:help]
  exit(0)
 end
 
-unless ENV["API_DRIVER"]
+unless options[:drivers] or ENV["API_DRIVER"]
   puts "You need to specify a driver to use (-i <driver>)"
   exit(1)
 end
@@ -106,19 +107,21 @@ end
 ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
 ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
 
-msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
-msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
-if options[:ssl]
-  msg << ":: https://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
-else
-  msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
-end
-puts msg
-if ENV['API_USER'] && ENV['API_PASSWORD']
-  puts "Warning: API_USER and API_PASSWORD set in environment"
-  puts "         anybody can access this server with your credentials"
+unless options[:drivers]
+  msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
+  msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
+  if options[:ssl]
+    msg << ":: https://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
+  else
+    msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
+  end
+  puts msg
+  if ENV['API_USER'] && ENV['API_PASSWORD']
+    puts "Warning: API_USER and API_PASSWORD set in environment"
+    puts "         anybody can access this server with your credentials"
+  end
+  puts
 end
-puts
 
 dirname="#{File.dirname(__FILE__)}/.."
 
@@ -168,6 +171,13 @@ else
   end
   argv_opts.flatten!
 
+  if options[:drivers]
+    require 'server.rb'
+    puts "Available drivers:\n"
+    puts driver_config.keys.map{ |d| d.to_s }.join(', ')
+    exit(0)
+  end
+
   if have_rerun && options[:env] == "development"
     argv_opts.unshift "thin"
     command = argv_opts.join(" ")
-- 
1.7.4.1


Mime
View raw message