Skip to content

Commit 372f7ca

Browse files
emontyDean Troyer
authored andcommitted
Make Profile fallback go bye-bye
It's time to move on with life. (dtroyer) This requires sdk >= 0.10.0 (0.9.19 is in global-requirements.txt) and osc-lib >= 1.8.0 (1.8.0 is already in g-r). Once we have sdk bumped make_client() becomes just a pass-through for the plugin interface and existing code compatibility. Change-Id: Ie3d7c442da4257b11140c109e9df69b629336f42
1 parent 07014e0 commit 372f7ca

1 file changed

Lines changed: 11 additions & 41 deletions

File tree

openstackclient/network/client.py

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313

1414
import logging
1515

16-
from openstack import connection
17-
18-
19-
# NOTE(dtroyer): Attempt an import to detect if the SDK installed is new
20-
# enough to not use Profile. If so, use that.
21-
try:
22-
from openstack.config import loader as config # noqa
23-
profile = None
24-
except ImportError:
25-
from openstack import profile
2616
from osc_lib import utils
2717

2818
from openstackclient.i18n import _
@@ -41,37 +31,17 @@
4131

4232
def make_client(instance):
4333
"""Returns a network proxy"""
44-
if getattr(instance, "sdk_connection", None) is None:
45-
if profile is None:
46-
# If the installed OpenStackSDK is new enough to not require a
47-
# Profile obejct and osc-lib is not new enough to have created
48-
# it for us, make an SDK Connection.
49-
# NOTE(dtroyer): This can be removed when this bit is in the
50-
# released osc-lib in requirements.txt.
51-
conn = connection.Connection(
52-
config=instance._cli_options,
53-
session=instance.session,
54-
)
55-
else:
56-
# Fall back to the original Connection creation
57-
prof = profile.Profile()
58-
prof.set_region(API_NAME, instance.region_name)
59-
prof.set_version(API_NAME, instance._api_version[API_NAME])
60-
prof.set_interface(API_NAME, instance.interface)
61-
conn = connection.Connection(
62-
authenticator=instance.session.auth,
63-
verify=instance.session.verify,
64-
cert=instance.session.cert,
65-
profile=prof,
66-
)
67-
68-
instance.sdk_connection = conn
69-
70-
conn = instance.sdk_connection
71-
LOG.debug('Connection: %s', conn)
72-
LOG.debug('Network client initialized using OpenStack SDK: %s',
73-
conn.network)
74-
return conn.network
34+
# NOTE(dtroyer): As of osc-lib 1.8.0 and OpenStackSDK 0.10.0 the
35+
# old Profile interface and separate client creation
36+
# for each API that uses the SDK is unnecessary. This
37+
# callback remains as a remnant of the original plugin
38+
# interface and to avoid the code churn of changing all
39+
# of the existing references.
40+
LOG.debug(
41+
'Network client initialized using OpenStack SDK: %s',
42+
instance.sdk_connection.network,
43+
)
44+
return instance.sdk_connection.network
7545

7646

7747
def build_option_parser(parser):

0 commit comments

Comments
 (0)