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:
parent
c161a76a5f
commit
80da4d6cf8
@ -14,7 +14,10 @@
|
||||
import logging
|
||||
|
||||
from openstack import connection
|
||||
from openstack import profile
|
||||
try:
|
||||
from openstack import profile
|
||||
except ImportError:
|
||||
profile = None
|
||||
from osc_lib import utils
|
||||
|
||||
from openstackclient.i18n import _
|
||||
@ -33,14 +36,20 @@ API_VERSIONS = {
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns a network proxy"""
|
||||
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)
|
||||
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])
|
||||
prof.set_interface(API_NAME, instance.interface)
|
||||
conn = connection.Connection(authenticator=instance.session.auth,
|
||||
verify=instance.session.verify,
|
||||
cert=instance.session.cert,
|
||||
profile=prof)
|
||||
LOG.debug('Connection: %s', conn)
|
||||
LOG.debug('Network client initialized using OpenStack SDK: %s',
|
||||
conn.network)
|
||||
|
Loading…
Reference in New Issue
Block a user