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
This commit is contained in:
parent
f9f6abe564
commit
15edb2f61a
@ -18,6 +18,7 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from openstackclient.common import command
|
from openstackclient.common import command
|
||||||
|
from openstackclient.common import exceptions
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
@ -172,6 +173,9 @@ class IssueToken(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
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()
|
token = self.app.client_manager.auth_ref.service_catalog.get_token()
|
||||||
if 'tenant_id' in token:
|
if 'tenant_id' in token:
|
||||||
token['project_id'] = token.pop('tenant_id')
|
token['project_id'] = token.pop('tenant_id')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user