diff options
| author | Monty Taylor <mordred@inaugust.com> | 2017-11-16 08:09:11 -0600 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2017-11-16 08:09:11 -0600 |
| commit | 80da4d6cf8140a150c18c55c1e2b5da49dd59e9d (patch) | |
| tree | 3c62abaa56cda78040c687fb60ac32639af63a10 | |
| parent | c161a76a5f08585388e1a49d2882204ca719428c (diff) | |
| download | python-openstackclient-80da4d6cf8140a150c18c55c1e2b5da49dd59e9d.tar.gz | |
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
| -rw-r--r-- | openstackclient/network/client.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py index 9525b947..3566bfe5 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) |
