Skip to content

Commit c127bbc

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Revert "Remove all usage of keystoneclient"" into stable/wallaby
2 parents 2972583 + 7ce475c commit c127bbc

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

glance/common/auth.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
3333
"""
3434
import httplib2
35-
from keystoneauth1.access import service_catalog as ks_service_catalog
35+
from keystoneclient import service_catalog as ks_service_catalog
3636
from oslo_serialization import jsonutils
3737
from six.moves import http_client as http
3838
# NOTE(jokke): simplified transition to py3, behaves like py2 xrange
@@ -326,10 +326,11 @@ def get_endpoint(service_catalog, service_type='image', endpoint_region=None,
326326
otherwise we will raise an exception.
327327
"""
328328
endpoints = ks_service_catalog.ServiceCatalogV2(
329-
service_catalog).get_urls(interface=endpoint_type,
330-
service_type=service_type,
331-
region_name=endpoint_region)
332-
if len(endpoints) == 0:
329+
{'serviceCatalog': service_catalog}
330+
).get_urls(service_type=service_type,
331+
region_name=endpoint_region,
332+
endpoint_type=endpoint_type)
333+
if endpoints is None:
333334
raise exception.NoServiceEndpoint()
334335
elif len(endpoints) == 1:
335336
return endpoints[0]

glance/common/trust_auth.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from keystoneauth1 import exceptions as ka_exceptions
1616
from keystoneauth1 import loading as ka_loading
17+
from keystoneclient.v3 import client as ks_client
1718
from oslo_config import cfg
1819
from oslo_log import log as logging
1920

@@ -31,17 +32,17 @@ def __init__(self, user_plugin, user_project, user_roles):
3132
# step 1: create trust to ensure that we can always update token
3233

3334
# trustor = user who made the request
34-
trustor_client = self._load_session(user_plugin)
35-
trustor_id = trustor_client.get_user_id()
35+
trustor_client = self._load_client(user_plugin)
36+
trustor_id = trustor_client.session.get_user_id()
3637

3738
# get trustee user client that impersonates main user
3839
trustee_user_auth = ka_loading.load_auth_from_conf_options(
3940
CONF, 'keystone_authtoken')
4041
# save service user client because we need new service token
4142
# to refresh trust-scoped client later
42-
self.trustee_user_client = self._load_session(trustee_user_auth)
43+
self.trustee_user_client = self._load_client(trustee_user_auth)
4344

44-
trustee_id = self.trustee_user_client.get_user_id()
45+
trustee_id = self.trustee_user_client.session.get_user_id()
4546

4647
self.trust_id = trustor_client.trusts.create(trustor_user=trustor_id,
4748
trustee_user=trustee_id,
@@ -63,12 +64,12 @@ def refresh_token(self):
6364
if self.trustee_client is None:
6465
self.trustee_client = self._refresh_trustee_client()
6566
try:
66-
return self.trustee_client.get_token()
67+
return self.trustee_client.session.get_token()
6768
except ka_exceptions.Unauthorized:
6869
# in case of Unauthorized exceptions try to refresh client because
6970
# service user token may expired
7071
self.trustee_client = self._refresh_trustee_client()
71-
return self.trustee_client.get_token()
72+
return self.trustee_client.session.get_token()
7273

7374
def release_resources(self):
7475
"""Release keystone resources required for refreshing"""
@@ -98,11 +99,11 @@ def _refresh_trustee_client(self):
9899
trustee_auth = ka_loading.load_auth_from_conf_options(
99100
CONF, 'keystone_authtoken', **kwargs)
100101

101-
return self._load_session(trustee_auth)
102+
return self._load_client(trustee_auth)
102103

103104
@staticmethod
104-
def _load_session(plugin):
105-
# load ksa session from auth settings and user plugin
105+
def _load_client(plugin):
106+
# load client from auth settings and user plugin
106107
sess = ka_loading.load_session_from_conf_options(
107108
CONF, 'keystone_authtoken', auth=plugin)
108-
return sess
109+
return ks_client.Client(session=sess)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ PrettyTable>=0.7.1 # BSD
3232
Paste>=2.0.2 # MIT
3333

3434
jsonschema>=3.2.0 # MIT
35+
python-keystoneclient>=3.8.0 # Apache-2.0
3536
pyOpenSSL>=17.1.0 # Apache-2.0
3637
# Required by openstack.common libraries
3738
six>=1.11.0 # MIT

0 commit comments

Comments
 (0)