Revise client constructor
This patch revises the client.Client constructor so that other software can invoke senlinclient in the same way as they do with other client packages. Change-Id: I060e2bf70d51ec381934cfd487a1a6cb44f0edd2 Closes-Bug: #1498906
This commit is contained in:
parent
4fa928655c
commit
256e6302bd
@ -13,7 +13,7 @@
|
||||
from senlinclient.common import utils
|
||||
|
||||
|
||||
def Client(api_ver, session, **kwargs):
|
||||
def Client(api_ver, *args, **kwargs):
|
||||
'''Import versioned client module.
|
||||
|
||||
:param api_ver: API version required.
|
||||
@ -21,4 +21,4 @@ def Client(api_ver, session, **kwargs):
|
||||
'''
|
||||
module = utils.import_versioned_module(api_ver, '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.common import exc
|
||||
from senlinclient.common.i18n import _
|
||||
from senlinclient.common import sdk
|
||||
from senlinclient.common import utils
|
||||
|
||||
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
||||
@ -234,10 +233,8 @@ class SenlinShell(object):
|
||||
'token': args.token,
|
||||
'trust_id': args.trust_id,
|
||||
}
|
||||
conn = sdk.create_connection(args.user_preferences,
|
||||
USER_AGENT, **kwargs)
|
||||
|
||||
return senlin_client.Client('1', conn.session)
|
||||
return senlin_client.Client('1', args.user_preferences,
|
||||
USER_AGENT, **kwargs)
|
||||
|
||||
def main(self, argv):
|
||||
# Parse args once to find version
|
||||
|
@ -16,10 +16,18 @@ from openstack.identity import identity_service
|
||||
from openstack import transport as trans
|
||||
|
||||
from senlinclient.common import exc as client_exc
|
||||
from senlinclient.common import sdk
|
||||
|
||||
|
||||
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.auth = session.authenticator
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user