From 80da4d6cf8140a150c18c55c1e2b5da49dd59e9d Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 16 Nov 2017 08:09:11 -0600 Subject: [PATCH] Add logic to handle old and new sdk constructor SDK is removing Profile, but currently has compat code to support this invocation in OSC. While the intent is to protect people from upgrade breakage, it's python, and packaging things have a tendency to get strange. By putting in a little belt and suspenders if block here, we can hopefully protect folks who upgrade sdk for some reason without upgrading python-openstackclient. Change-Id: Id678e97a2b99dbbfc772acc8c6ba283db551723d --- openstackclient/network/client.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py index 9525b947d0..3566bfe525 100644 --- a/openstackclient/network/client.py +++ b/openstackclient/network/client.py @@ -14,7 +14,10 @@ import logging from openstack import connection -from openstack import profile +try: + from openstack import profile +except ImportError: + profile = None from osc_lib import utils from openstackclient.i18n import _ @@ -33,14 +36,20 @@ API_VERSIONS = { def make_client(instance): """Returns a network proxy""" - prof = profile.Profile() - prof.set_region(API_NAME, instance.region_name) - prof.set_version(API_NAME, instance._api_version[API_NAME]) - prof.set_interface(API_NAME, instance.interface) - conn = connection.Connection(authenticator=instance.session.auth, - verify=instance.session.verify, - cert=instance.session.cert, - profile=prof) + if profile is None: + # New SDK + conn = connection.Connection( + cloud_config=instance._cli_options, + session=instance.session) + else: + prof = profile.Profile() + prof.set_region(API_NAME, instance.region_name) + prof.set_version(API_NAME, instance._api_version[API_NAME]) + prof.set_interface(API_NAME, instance.interface) + conn = connection.Connection(authenticator=instance.session.auth, + verify=instance.session.verify, + cert=instance.session.cert, + profile=prof) LOG.debug('Connection: %s', conn) LOG.debug('Network client initialized using OpenStack SDK: %s', conn.network)