From a8d828f330119502fc18107c264f2944548a7fb9 Mon Sep 17 00:00:00 2001 From: Qiu Yu Date: Wed, 29 Jan 2014 15:57:18 +0800 Subject: Add token create subcommand for identity v3 api Implements token create subcommand which is an equivalent of keystone token-get command. Original "wrap" parameter for keystone token-get is not implemented yet due to cliff Bug #1269299 This is a part of: blueprint add-identity-token-support Change-Id: I2255021c9d1f10f757686583b1ebe40b5f3a9ecb --- openstackclient/identity/v3/token.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'openstackclient/identity') diff --git a/openstackclient/identity/v3/token.py b/openstackclient/identity/v3/token.py index ba667be3..68f9ffef 100644 --- a/openstackclient/identity/v3/token.py +++ b/openstackclient/identity/v3/token.py @@ -185,6 +185,24 @@ class CreateRequestToken(show.ShowOne): return zip(*sorted(six.iteritems(request_token))) +class CreateToken(show.ShowOne): + """Create token command""" + + log = logging.getLogger(__name__ + '.CreateToken') + + def get_parser(self, prog_name): + parser = super(CreateToken, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)' % parsed_args) + identity_client = self.app.client_manager.identity + token = identity_client.service_catalog.get_token() + if 'tenant_id' in token: + token['project_id'] = token.pop('tenant_id') + return zip(*sorted(six.iteritems(token))) + + class DeleteAccessToken(command.Command): """Delete access token command""" -- cgit v1.2.1