From d355c0b65a946bdc57162337c8f8fbbe3ebd05e1 Mon Sep 17 00:00:00 2001 From: tengqm Date: Sat, 18 Jul 2015 01:55:59 -0400 Subject: [PATCH] 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 --- senlinclient/common/sdk.py | 22 ---------------------- senlinclient/v1/client.py | 8 +------- senlinclient/v1/shell.py | 4 ++-- 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/senlinclient/common/sdk.py b/senlinclient/common/sdk.py index c7461c82..e0ea4334 100644 --- a/senlinclient/common/sdk.py +++ b/senlinclient/common/sdk.py @@ -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. diff --git a/senlinclient/v1/client.py b/senlinclient/v1/client.py index 2940c05c..b2d83cab 100644 --- a/senlinclient/v1/client.py +++ b/senlinclient/v1/client.py @@ -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) diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index abe05d65..885db232 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -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)