incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962225 - in /incubator/deltacloud/trunk/client: bin/deltacloudc lib/deltacloud.rb
Date Thu, 08 Jul 2010 23:37:53 GMT
Author: lutter
Date: Thu Jul  8 23:37:53 2010
New Revision: 962225

URL: http://svn.apache.org/viewvc?rev=962225&view=rev
Log:
Added verbose option for command line client

Modified:
    incubator/deltacloud/trunk/client/bin/deltacloudc
    incubator/deltacloud/trunk/client/lib/deltacloud.rb

Modified: incubator/deltacloud/trunk/client/bin/deltacloudc
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/bin/deltacloudc?rev=962225&r1=962224&r2=962225&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/bin/deltacloudc (original)
+++ incubator/deltacloud/trunk/client/bin/deltacloudc Thu Jul  8 23:37:53 2010
@@ -21,7 +21,9 @@ require 'optparse'
 require 'uri'
 require 'deltacloud'
 
-options = {}
+options = {
+  :verbose => false
+}
 
 @optparse = OptionParser.new do |opts|
 
@@ -44,6 +46,7 @@ BANNER
   opts.on( '-l', '--list', 'List collections/operations') { |id| options[:list] = true }
   opts.on( '-h', '--help', 'Display this screen' ) { puts opts ; exit }
   opts.on( '-v', '--version', 'Display API version' ) { options[:version]=true }
+  opts.on( '-V', '--verbose', 'Print verbose messages' ) { options[:verbose]=true }
 end
 
 def invalid_usage(error_msg='')
@@ -63,7 +66,7 @@ options[:collection] = ARGV[0]
 options[:operation] = ARGV[1]
 
 # Connect to Deltacloud API and fetch all entry points
-client = DeltaCloud.new(url.user, url.password, api_url)
+client = DeltaCloud.new(url.user, url.password, api_url, { :verbose => options[:verbose]
})
 collections = client.entry_points.keys
 
 # Exclude collection which don't have methods in client library yet

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=962225&r1=962224&r2=962225&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Thu Jul  8 23:37:53 2010
@@ -49,12 +49,13 @@ class DeltaCloud
     end
   end
 
-  def initialize(name, password, api_uri, &block)
+  def initialize(name, password, api_uri, opts={}, &block)
     @logger       = Logger.new( STDERR )
     @name         = name
     @password     = password
     @api_uri      = URI.parse( api_uri )
     @entry_points = {}
+    @verbose      = opts[:verbose]
     discover_entry_points
     connect( &block )
     self
@@ -377,7 +378,7 @@ class DeltaCloud
       :authorization => "Basic "+Base64.encode64("#{@name}:#{@password}"),
       :accept => "application/xml"
     }
-    # logger << "Request [#{method.to_s.upcase}] #{request_path}]\n"
+    logger << "Request [#{method.to_s.upcase}] #{request_path}]\n"  if @verbose
     if method.eql?(:get)
       RestClient.send(method, request_path, headers, &block)
     else



Mime
View raw message