From f7d34f2dc70a052d3705a582a256703372b16a36 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 12 Jul 2017 18:16:14 +0200 Subject: [PATCH] B #5236: oneuser token-create does not work without ONE_AUTH --- share/onetoken/onetoken.sh | 4 ++-- src/cli/oneuser | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/share/onetoken/onetoken.sh b/share/onetoken/onetoken.sh index 59c61e4a0a..48c9a09655 100644 --- a/share/onetoken/onetoken.sh +++ b/share/onetoken/onetoken.sh @@ -10,7 +10,7 @@ onetokenset(){ shift if [ -z "$USER" -o "${USER:0:1}" = "-" ]; then - echo "Usage: $0 [options]" >&2 + echo "Usage: onetokenset [options]" >&2 echo " Any option understood by 'oneuser token-set' is valid." >&2 return 1 fi @@ -42,7 +42,7 @@ onetokencreate(){ USER=$1 if [ -z "$USER" ]; then - echo "Usage: $0 [options]" >&2 + echo "Usage: onetokencreate [options]" >&2 echo " Any option understood by 'oneuser token-create' is valid." >&2 return 1 fi diff --git a/src/cli/oneuser b/src/cli/oneuser index 3ac3b1bce7..5d207da5b0 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -33,14 +33,28 @@ require 'one_helper/onequota_helper' require 'uri' -cmd=CommandParser::CmdParser.new(ARGV) do +NO_CLIENT_CMDS = [ :key, :"token-create", :login ] + +cmd = CommandParser::CmdParser.new(ARGV) do usage "`oneuser` [] []" version OpenNebulaHelper::ONE_VERSION helper = OneUserHelper.new before_proc do - helper.set_client(options) if ![:key].include?(@comm_name) + if !NO_CLIENT_CMDS.include?(@comm_name) + begin + helper.set_client(options) + rescue Exception => e + STDERR.puts e.message + + if e.message != "ONE_AUTH file not present" + STDERR.puts e.backtrace + end + + exit 1 + end + end end ########################################################################