summaryrefslogtreecommitdiff
path: root/openstackclient/image/client.py
diff options
context:
space:
mode:
authorArtem Goncharov <artem.goncharov@gmail.com>2019-09-13 18:03:15 +0200
committerMonty Taylor <mordred@inaugust.com>2020-03-23 14:38:32 -0500
commit60e7c51df4cf061ebbb435a959ad63c7d3a296bf (patch)
tree1c974aae914cd316ac90be5f5bca2cae9531e466 /openstackclient/image/client.py
parentfc12033f1da53fe11f930dd405eae5e2bf814621 (diff)
downloadpython-openstackclient-60e7c51df4cf061ebbb435a959ad63c7d3a296bf.tar.gz
Switch image to use SDK
This is a work to switch OSC from using glanceclient to OpenStackSDK. With this change only v2 is using OpenStackSDK. V1 is still using glanceclient and will be switched in a separate change. Remove the direct depend on keystoneauth- let that flow through openstacksdk. Depends-on: https://review.opendev.org/#/c/698972 Change-Id: I36f292fb70c98f6e558f58be55d533d979c47ca7
Diffstat (limited to 'openstackclient/image/client.py')
-rw-r--r--openstackclient/image/client.py76
1 files changed, 42 insertions, 34 deletions
diff --git a/openstackclient/image/client.py b/openstackclient/image/client.py
index b67c291f..15bea17e 100644
--- a/openstackclient/image/client.py
+++ b/openstackclient/image/client.py
@@ -27,7 +27,7 @@ API_VERSION_OPTION = 'os_image_api_version'
API_NAME = "image"
API_VERSIONS = {
"1": "glanceclient.v1.client.Client",
- "2": "glanceclient.v2.client.Client",
+ "2": "openstack.connection.Connection",
}
IMAGE_API_TYPE = 'image'
@@ -38,44 +38,52 @@ IMAGE_API_VERSIONS = {
def make_client(instance):
- """Returns an image service client"""
- image_client = utils.get_client_class(
- API_NAME,
- instance._api_version[API_NAME],
- API_VERSIONS)
- LOG.debug('Instantiating image client: %s', image_client)
-
- endpoint = instance.get_endpoint_for_service_type(
- API_NAME,
- region_name=instance.region_name,
- interface=instance.interface,
- )
-
- client = image_client(
- endpoint,
- token=instance.auth.get_token(instance.session),
- cacert=instance.cacert,
- insecure=not instance.verify,
- )
- # Create the low-level API
-
- image_api = utils.get_client_class(
- API_NAME,
- instance._api_version[API_NAME],
- IMAGE_API_VERSIONS)
- LOG.debug('Instantiating image api: %s', image_api)
-
- client.api = image_api(
- session=instance.session,
- endpoint=instance.get_endpoint_for_service_type(
- IMAGE_API_TYPE,
+ if instance._api_version[API_NAME] != '1':
+ LOG.debug(
+ 'Image client initialized using OpenStack SDK: %s',
+ instance.sdk_connection.image,
+ )
+ return instance.sdk_connection.image
+ else:
+ """Returns an image service client"""
+ image_client = utils.get_client_class(
+ API_NAME,
+ instance._api_version[API_NAME],
+ API_VERSIONS)
+ LOG.debug('Instantiating image client: %s', image_client)
+
+ endpoint = instance.get_endpoint_for_service_type(
+ API_NAME,
region_name=instance.region_name,
interface=instance.interface,
)
- )
- return client
+ client = image_client(
+ endpoint,
+ token=instance.auth.get_token(instance.session),
+ cacert=instance.cacert,
+ insecure=not instance.verify,
+ )
+
+ # Create the low-level API
+
+ image_api = utils.get_client_class(
+ API_NAME,
+ instance._api_version[API_NAME],
+ IMAGE_API_VERSIONS)
+ LOG.debug('Instantiating image api: %s', image_api)
+
+ client.api = image_api(
+ session=instance.session,
+ endpoint=instance.get_endpoint_for_service_type(
+ IMAGE_API_TYPE,
+ region_name=instance.region_name,
+ interface=instance.interface,
+ )
+ )
+
+ return client
def build_option_parser(parser):