summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authortimothy-symanczyk <timothy_symanczyk@symantec.com>2016-03-18 15:44:02 -0700
committertimothy-symanczyk <timothy_symanczyk@symantec.com>2016-03-18 15:44:02 -0700
commit15edb2f61a4d193c069dce903b29c391f04ba0b8 (patch)
tree9dd8f59b6db8e15ee90356cde223b0595b9745a6 /openstackclient
parentf9f6abe56414a56ea28863ad5824a5c176a75b33 (diff)
downloadpython-openstackclient-15edb2f61a4d193c069dce903b29c391f04ba0b8.tar.gz
Improve error for token issue command without auth
Currently when you perform the 'token issue' command with the admin_token, the error is a nonsense python error. This commit changes it to be user-friendly. Change-Id: I5cc92c342e3f83e099354cd04301c7b8d8d2dabc Closes-Bug: #1547721
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/identity/v3/token.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/openstackclient/identity/v3/token.py b/openstackclient/identity/v3/token.py
index bf039d2f..62a4c4a3 100644
--- a/openstackclient/identity/v3/token.py
+++ b/openstackclient/identity/v3/token.py
@@ -18,6 +18,7 @@
import six
from openstackclient.common import command
+from openstackclient.common import exceptions
from openstackclient.common import utils
from openstackclient.identity import common
@@ -172,6 +173,9 @@ class IssueToken(command.ShowOne):
return parser
def take_action(self, parsed_args):
+ if not self.app.client_manager.auth_ref:
+ raise exceptions.AuthorizationFailure(
+ "Only an authorized user may issue a new token.")
token = self.app.client_manager.auth_ref.service_catalog.get_token()
if 'tenant_id' in token:
token['project_id'] = token.pop('tenant_id')