Skip to content

Commit 80da4d6

Browse files
committed
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
1 parent c161a76 commit 80da4d6

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

openstackclient/network/client.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import logging
1515

1616
from openstack import connection
17-
from openstack import profile
17+
try:
18+
from openstack import profile
19+
except ImportError:
20+
profile = None
1821
from osc_lib import utils
1922

2023
from openstackclient.i18n import _
@@ -33,14 +36,20 @@
3336

3437
def make_client(instance):
3538
"""Returns a network proxy"""
36-
prof = profile.Profile()
37-
prof.set_region(API_NAME, instance.region_name)
38-
prof.set_version(API_NAME, instance._api_version[API_NAME])
39-
prof.set_interface(API_NAME, instance.interface)
40-
conn = connection.Connection(authenticator=instance.session.auth,
41-
verify=instance.session.verify,
42-
cert=instance.session.cert,
43-
profile=prof)
39+
if profile is None:
40+
# New SDK
41+
conn = connection.Connection(
42+
cloud_config=instance._cli_options,
43+
session=instance.session)
44+
else:
45+
prof = profile.Profile()
46+
prof.set_region(API_NAME, instance.region_name)
47+
prof.set_version(API_NAME, instance._api_version[API_NAME])
48+
prof.set_interface(API_NAME, instance.interface)
49+
conn = connection.Connection(authenticator=instance.session.auth,
50+
verify=instance.session.verify,
51+
cert=instance.session.cert,
52+
profile=prof)
4453
LOG.debug('Connection: %s', conn)
4554
LOG.debug('Network client initialized using OpenStack SDK: %s',
4655
conn.network)

0 commit comments

Comments
 (0)