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
This commit is contained in:
Monty Taylor 2017-11-16 08:09:11 -06:00
parent c161a76a5f
commit 80da4d6cf8
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -14,7 +14,10 @@
import logging
from openstack import connection
try:
from openstack import profile
except ImportError:
profile = None
from osc_lib import utils
from openstackclient.i18n import _
@ -33,6 +36,12 @@ API_VERSIONS = {
def make_client(instance):
"""Returns a network proxy"""
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])