X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/67b16f2fd5de0a5cb8078f73abb844d4b04974d6..549f4a1deddb41f6abbc493a660d9fb0976da91a:/sdk/cli/bin/arv diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv index b922e5b85f..d4aef2c088 100755 --- a/sdk/cli/bin/arv +++ b/sdk/cli/bin/arv @@ -36,19 +36,22 @@ case ARGV[0] when 'keep' ARGV.shift @sub = ARGV.shift - if ['get', 'put'].index @sub then + if ['get', 'put', 'ls', 'normalize'].index @sub then # Native Arvados exec `which arv-#{@sub}`.strip, *ARGV - elsif ['ls', 'less', 'check'].index @sub then + elsif ['less', 'check'].index @sub then # wh* shims exec `which wh#{@sub}`.strip, *ARGV + elsif @sub == 'docker' + exec `which arv-keepdocker`.strip, *ARGV else puts "Usage: \n" + "#{$0} keep ls\n" + "#{$0} keep get\n" + "#{$0} keep put\n" + "#{$0} keep less\n" + - "#{$0} keep check\n" + "#{$0} keep check\n" + + "#{$0} keep docker\n" end abort when 'pipeline' @@ -65,6 +68,9 @@ when 'pipeline' when 'tag' ARGV.shift exec `which arv-tag`.strip, *ARGV +when 'ws' + ARGV.shift + exec `which arv-ws`.strip, *ARGV end ENV['ARVADOS_API_VERSION'] ||= 'v1' @@ -89,7 +95,7 @@ begin rescue LoadError abort <<-EOS -Please install all required gems: +Please install all required gems: gem install activesupport andand curb google-api-client json oj trollop @@ -148,8 +154,13 @@ class ArvadosClient < Google::APIClient end end -client = ArvadosClient.new(:host => ENV['ARVADOS_API_HOST'], :application_name => 'arvados-cli', :application_version => '1.0') -arvados = client.discovered_api('arvados', ENV['ARVADOS_API_VERSION']) +begin + client = ArvadosClient.new(:host => ENV['ARVADOS_API_HOST'], :application_name => 'arvados-cli', :application_version => '1.0') + arvados = client.discovered_api('arvados', ENV['ARVADOS_API_VERSION']) +rescue Exception => e + puts "Failed to connect to Arvados API server: #{e}" + exit 1 +end def to_boolean(s) !!(s =~ /^(true|t|yes|y|1)$/i) @@ -170,8 +181,8 @@ def help_methods(discovery_document, resource, method=nil) end banner += "\n" STDERR.puts banner - - if not method.nil? and method != '--help' then + + if not method.nil? and method != '--help' then Trollop::die ("Unknown method #{method.inspect} " + "for resource #{resource.inspect}") end @@ -194,7 +205,7 @@ def help_resources(discovery_document, resource) banner += "\n" STDERR.puts banner - if not resource.nil? and resource != '--help' then + if not resource.nil? and resource != '--help' then Trollop::die "Unknown resource type #{resource.inspect}" end exit 255 @@ -296,20 +307,18 @@ if global_opts[:dry_run] exit end -request_parameters = {}.merge(method_opts) +request_parameters = {_profile:true}.merge(method_opts) resource_body = request_parameters.delete(resource_schema.to_sym) if resource_body request_body = { resource_schema => resource_body } else - request_body = {} + request_body = nil end case api_method when - 'arvados.users.event_stream', - 'arvados.jobs.log_stream', 'arvados.jobs.log_tail_follow' # Special case for methods that respond with data streams rather @@ -320,7 +329,7 @@ when curl.headers['Accept'] = 'text/plain' curl.headers['Authorization'] = "OAuth2 #{ENV['ARVADOS_API_TOKEN']}" if ENV['ARVADOS_API_HOST_INSECURE'] - curl.ssl_verify_peer = false + curl.ssl_verify_peer = false curl.ssl_verify_host = false end if global_opts[:verbose] @@ -330,12 +339,13 @@ when end exit 0 else - request_body[:api_token] = ENV['ARVADOS_API_TOKEN'] - request_body[:_profile] = true result = client.execute(:api_method => eval(api_method), :parameters => request_parameters, :body => request_body, - :authenticated => false) + :authenticated => false, + :headers => { + authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN'] + }) end begin @@ -364,5 +374,3 @@ else puts results['uuid'] end end - -