Merge "Revise client constructor"
This commit is contained in:
commit
32401586d8
@ -13,7 +13,7 @@
|
|||||||
from senlinclient.common import utils
|
from senlinclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
def Client(api_ver, session, **kwargs):
|
def Client(api_ver, *args, **kwargs):
|
||||||
'''Import versioned client module.
|
'''Import versioned client module.
|
||||||
|
|
||||||
:param api_ver: API version required.
|
:param api_ver: API version required.
|
||||||
@ -21,4 +21,4 @@ def Client(api_ver, session, **kwargs):
|
|||||||
'''
|
'''
|
||||||
module = utils.import_versioned_module(api_ver, 'client')
|
module = utils.import_versioned_module(api_ver, 'client')
|
||||||
cls = getattr(module, 'Client')
|
cls = getattr(module, 'Client')
|
||||||
return cls(session)
|
return cls(*args, **kwargs)
|
||||||
|
@ -29,7 +29,6 @@ from senlinclient import cliargs
|
|||||||
from senlinclient import client as senlin_client
|
from senlinclient import client as senlin_client
|
||||||
from senlinclient.common import exc
|
from senlinclient.common import exc
|
||||||
from senlinclient.common.i18n import _
|
from senlinclient.common.i18n import _
|
||||||
from senlinclient.common import sdk
|
|
||||||
from senlinclient.common import utils
|
from senlinclient.common import utils
|
||||||
|
|
||||||
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
||||||
@ -234,10 +233,8 @@ class SenlinShell(object):
|
|||||||
'token': args.token,
|
'token': args.token,
|
||||||
'trust_id': args.trust_id,
|
'trust_id': args.trust_id,
|
||||||
}
|
}
|
||||||
conn = sdk.create_connection(args.user_preferences,
|
return senlin_client.Client('1', args.user_preferences,
|
||||||
USER_AGENT, **kwargs)
|
USER_AGENT, **kwargs)
|
||||||
|
|
||||||
return senlin_client.Client('1', conn.session)
|
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
# Parse args once to find version
|
# Parse args once to find version
|
||||||
|
@ -16,10 +16,18 @@ from openstack.identity import identity_service
|
|||||||
from openstack import transport as trans
|
from openstack import transport as trans
|
||||||
|
|
||||||
from senlinclient.common import exc as client_exc
|
from senlinclient.common import exc as client_exc
|
||||||
|
from senlinclient.common import sdk
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
def __init__(self, session):
|
|
||||||
|
def __init__(self, preferences, user_agent, **kwargs):
|
||||||
|
if 'session' in kwargs:
|
||||||
|
session = kwargs['session']
|
||||||
|
else:
|
||||||
|
conn = sdk.create_connection(preferences, user_agent, **kwargs)
|
||||||
|
session = conn.session
|
||||||
|
|
||||||
self.session = session
|
self.session = session
|
||||||
self.auth = session.authenticator
|
self.auth = session.authenticator
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user