--- client/bin/deltacloudc | 7 +++++-- client/lib/deltacloud.rb | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/client/bin/deltacloudc b/client/bin/deltacloudc index 53001e9..f0b6958 100755 --- a/client/bin/deltacloudc +++ b/client/bin/deltacloudc @@ -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 diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb index 7dc2722..32e2a0c 100644 --- a/client/lib/deltacloud.rb +++ b/client/lib/deltacloud.rb @@ -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
deltacloud-devel@lists.fedorahosted.org