Fix client constructor for ease of use

This patch optimizes the client constructor so that caller doesn't have
to provide user_preferences or user_agent arguments. It would be a
convenience for projects such as senlin-dashboard.

Change-Id: I0e98fb055441a941ad7c9da6e36b4a388ae0a75a
This commit is contained in:
tengqm 2015-09-30 04:33:06 -04:00
parent 3c5aa04054
commit 63b8839741
3 changed files with 5 additions and 4 deletions

View File

@ -123,7 +123,7 @@ class Resource(base.Resource):
return self
def create_connection(preferences, user_agent, **kwargs):
def create_connection(preferences=None, user_agent=None, **kwargs):
try:
conn = connection.Connection(profile=preferences,
user_agent=user_agent,

View File

@ -233,8 +233,9 @@ class SenlinShell(object):
'token': args.token,
'trust_id': args.trust_id,
}
return senlin_client.Client('1', args.user_preferences,
USER_AGENT, **kwargs)
return senlin_client.Client('1', args.user_preferences, USER_AGENT,
**kwargs)
def main(self, argv):
# Parse args once to find version

View File

@ -21,7 +21,7 @@ from senlinclient.common import sdk
class Client(object):
def __init__(self, preferences, user_agent, **kwargs):
def __init__(self, preferences=None, user_agent=None, **kwargs):
if 'session' in kwargs:
session = kwargs['session']
else: