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
This commit is contained in:
parent
07014e09c9
commit
372f7caa08
@ -13,16 +13,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openstack import connection
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE(dtroyer): Attempt an import to detect if the SDK installed is new
|
|
||||||
# enough to not use Profile. If so, use that.
|
|
||||||
try:
|
|
||||||
from openstack.config import loader as config # noqa
|
|
||||||
profile = None
|
|
||||||
except ImportError:
|
|
||||||
from openstack import profile
|
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
@ -41,37 +31,17 @@ API_VERSIONS = {
|
|||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
"""Returns a network proxy"""
|
"""Returns a network proxy"""
|
||||||
if getattr(instance, "sdk_connection", None) is None:
|
# NOTE(dtroyer): As of osc-lib 1.8.0 and OpenStackSDK 0.10.0 the
|
||||||
if profile is None:
|
# old Profile interface and separate client creation
|
||||||
# If the installed OpenStackSDK is new enough to not require a
|
# for each API that uses the SDK is unnecessary. This
|
||||||
# Profile obejct and osc-lib is not new enough to have created
|
# callback remains as a remnant of the original plugin
|
||||||
# it for us, make an SDK Connection.
|
# interface and to avoid the code churn of changing all
|
||||||
# NOTE(dtroyer): This can be removed when this bit is in the
|
# of the existing references.
|
||||||
# released osc-lib in requirements.txt.
|
LOG.debug(
|
||||||
conn = connection.Connection(
|
'Network client initialized using OpenStack SDK: %s',
|
||||||
config=instance._cli_options,
|
instance.sdk_connection.network,
|
||||||
session=instance.session,
|
|
||||||
)
|
)
|
||||||
else:
|
return instance.sdk_connection.network
|
||||||
# Fall back to the original Connection creation
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
|
|
||||||
instance.sdk_connection = conn
|
|
||||||
|
|
||||||
conn = instance.sdk_connection
|
|
||||||
LOG.debug('Connection: %s', conn)
|
|
||||||
LOG.debug('Network client initialized using OpenStack SDK: %s',
|
|
||||||
conn.network)
|
|
||||||
return conn.network
|
|
||||||
|
|
||||||
|
|
||||||
def build_option_parser(parser):
|
def build_option_parser(parser):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user