Skip to content

Commit 9c945be

Browse files
author
Dean Troyer
committed
Cleanup auth client path
1 parent 04730e6 commit 9c945be

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

openstackclient/shell.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ def __init__(self):
6161
command_manager=CommandManager('openstack.cli'),
6262
)
6363

64-
def _authenticate(self, **kwargs):
65-
"""Get an auth token from Keystone
66-
67-
:param username: name of user
68-
:param password: user's password
69-
:param tenant_id: unique identifier of tenant
70-
:param tenant_name: name of tenant
71-
:param auth_url: endpoint to authenticate against
72-
"""
73-
self.ksclient = ksclient.Client(username=kwargs.get('username'),
74-
password=kwargs.get('password'),
75-
tenant_id=kwargs.get('tenant_id'),
76-
tenant_name=kwargs.get('tenant_name'),
77-
auth_url=kwargs.get('auth_url'))
78-
return self.ksclient.auth_token
79-
8064
def build_option_parser(self, description, version):
8165
parser = super(OpenStackShell, self).build_option_parser(
8266
description,
@@ -177,14 +161,23 @@ def prepare_to_run_command(self, cmd):
177161
'tenant_name': self.options.os_tenant_name,
178162
'auth_url': self.options.os_auth_url
179163
}
180-
token = self._authenticate(**kwargs)
181-
endpoint = self.ksclient.service_catalog.url_for(service_type=cmd.api)
164+
self.auth_client = ksclient.Client(
165+
username=kwargs.get('username'),
166+
password=kwargs.get('password'),
167+
tenant_id=kwargs.get('tenant_id'),
168+
tenant_name=kwargs.get('tenant_name'),
169+
auth_url=kwargs.get('auth_url'),
170+
)
171+
token = self.auth_client.auth_token
172+
endpoint = self.auth_client.service_catalog.url_for(service_type=cmd.api)
182173

183174
if self.options.debug:
184175
print "api: %s" % cmd.api
185176
print "token: %s" % token
186177
print "endpoint: %s" % endpoint
187178

179+
# get a client for the desired api here
180+
188181
def clean_up(self, cmd, result, err):
189182
self.log.debug('clean_up %s', cmd.__class__.__name__)
190183
if err:

0 commit comments

Comments
 (0)