|
13 | 13 |
|
14 | 14 | import logging |
15 | 15 |
|
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 |
26 | 16 | from osc_lib import utils |
27 | 17 |
|
28 | 18 | from openstackclient.i18n import _ |
|
41 | 31 |
|
42 | 32 | def make_client(instance): |
43 | 33 | """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 |
75 | 45 |
|
76 | 46 |
|
77 | 47 | def build_option_parser(parser): |
|
0 commit comments