Fix list operation based on sdk interface

The SDK provides an additional parameter 'paginated' for specifying
whether the result will be paginated at server side. This feature saves
us from hacking the list function.

Also, the latest SDK revision has consolidated all kwargs in to a single
parameter named 'params'. This patch also fixes this problem.

Change-Id: Ib4ce1d03d18fe38cb655c541547faf41f3312a26
This commit is contained in:
tengqm
2015-07-18 01:55:59 -04:00
parent 4d93cffd32
commit d355c0b65a
3 changed files with 3 additions and 31 deletions

View File

@@ -84,28 +84,6 @@ class Resource(base.Resource):
These classes are here because the OpenStack SDK base version is making
some assumptions about operations that cannot be satisfied in Senlin.
'''
@classmethod
def list_short(cls, session, path_args=None, **params):
'''Return a generator that will page through results of GET requests.
This method bypasses the DB session support and retrieves list that
is directly exposed by server.
'''
if not cls.allow_list:
raise exceptions.MethodNotSupported('list')
if path_args:
url = cls.base_path % path_args
else:
url = cls.base_path
resp = session.get(url, service=cls.service, params=params).body
if cls.resources_key:
resp = resp[cls.resources_key]
for data in resp:
value = cls.existing(**data)
yield value
def create(self, session, extra_attrs=False):
"""Create a remote resource from this instance.

View File

@@ -47,13 +47,7 @@ class Client(object):
def list(self, cls, **options):
try:
return cls.list(self.session, **options)
except Exception as ex:
client_exc.parse_exception(ex)
def list_short(self, cls, options=None):
try:
return cls.list_short(self.session, path_args=None, **options)
return cls.list(self.session, params=options)
except Exception as ex:
client_exc.parse_exception(ex)

View File

@@ -37,7 +37,7 @@ def do_build_info(sc, args):
def do_profile_type_list(sc, args):
'''List the available profile types.'''
types = sc.list_short(models.ProfileType, {})
types = sc.list(models.ProfileType, paginated=False)
utils.print_list(types, ['name'], sortby_index=0)
@@ -221,7 +221,7 @@ def do_profile_delete(sc, args):
def do_policy_type_list(sc, args):
'''List the available policy types.'''
types = sc.list_short(models.PolicyType, {})
types = sc.list(models.PolicyType, paginated=False)
utils.print_list(types, ['name'], sortby_index=0)