From 2928e89b2652ccb1a8665e8b7000f37fc7c98418 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 1 Jul 2025 01:23:49 +0900 Subject: [PATCH] Replace os-client-config It was deprecated[1] after the code was merged into openstacksdk[2]. [1] https://review.opendev.org/c/openstack/os-client-config/+/549307 [2] https://review.opendev.org/c/openstack/openstacksdk/+/518128 Change-Id: I0cc581153c73a9dacc8a160fd63f9cb95660ef3a Signed-off-by: Takashi Kajinami --- keystoneclient/tests/functional/base.py | 19 +++++++++++-------- test-requirements.txt | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/keystoneclient/tests/functional/base.py b/keystoneclient/tests/functional/base.py index a8a12e01e..76355099f 100644 --- a/keystoneclient/tests/functional/base.py +++ b/keystoneclient/tests/functional/base.py @@ -10,10 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. +from openstack import config as occ +import openstack.exceptions import testtools from keystoneclient import client -import os_client_config IDENTITY_CLIENT = 'identity' OPENSTACK_CLOUDS = ('functional_admin', 'devstack-admin', 'envvars') @@ -22,8 +23,8 @@ OPENSTACK_CLOUDS = ('functional_admin', 'devstack-admin', 'envvars') def get_client(version): """Create a keystoneclient instance to run functional tests. - The client is instantiated via os-client-config either based on a - clouds.yaml config file or from the environment variables. + The client is instantiated either based on a clouds.yaml config file or + from the environment variables. First, look for a 'functional_admin' cloud, as this is a cloud that the user may have defined for functional testing with admin credentials. If @@ -33,12 +34,14 @@ def get_client(version): """ for cloud in OPENSTACK_CLOUDS: try: - cloud_config = os_client_config.get_config( + cloud_config = occ.OpenStackConfig().get_one( cloud=cloud, identity_api_version=version) - return cloud_config.get_legacy_client(service_key=IDENTITY_CLIENT, - constructor=client.Client) - - except os_client_config.exceptions.OpenStackConfigException: + endpoint = cloud_config.get_session_endpoint(IDENTITY_CLIENT) + return client.Client( + version=version, + session=cloud_config.get_session(), + endpoint=endpoint) + except openstack.exceptions.ConfigException: pass raise Exception("Could not find any cloud definition for clouds named" diff --git a/test-requirements.txt b/test-requirements.txt index a88f20ac4..e163c528f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,7 @@ fixtures>=3.0.0 # Apache-2.0/BSD keyring>=5.5.1 # MIT/PSF lxml>=4.5.0 # BSD oauthlib>=0.6.2 # BSD -os-client-config>=1.28.0 # Apache-2.0 +openstacksdk>=0.10.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0 tempest>=17.1.0 # Apache-2.0