소스 검색

Fix paging issue in aws

Nuwan Goonasekera 7 년 전
부모
커밋
856ba0e6d6
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 4
      cloudbridge/cloud/providers/aws/helpers.py
  2. 3 2
      test/test_vm_types_service.py

+ 3 - 4
cloudbridge/cloud/providers/aws/helpers.py

@@ -176,9 +176,8 @@ class BotoGenericService(object):
         if limit:
             PaginationConfig = {'MaxItems': limit, 'PageSize': limit}
 
-        # TODO: Paging with marker
-        # if marker:
-        #     PaginationConfig.update({'StartingToken': marker})
+        if marker:
+            PaginationConfig.update({'StartingToken': marker})
 
         params.update({'PaginationConfig': PaginationConfig})
         args = trim_empty_params(params)
@@ -203,7 +202,6 @@ class BotoGenericService(object):
         else:
             log.debug("Does not support server side pagination. Client will"
                       " limit and page results.")
-            # Do not limit, let the ClientPagedResultList enforce limit
             return (None, collection)
 
     def list(self, limit=None, marker=None, collection=None, **kwargs):
@@ -215,6 +213,7 @@ class BotoGenericService(object):
                            current resource. See http://boto3.readthedocs.io/
                            en/latest/guide/collections.html
         """
+        limit = limit or self.provider.config.default_result_limit
         collection = collection or self.boto_collection.filter(**kwargs)
         resume_token, boto_objs = self._make_query(collection, limit, marker)
 

+ 3 - 2
test/test_vm_types_service.py

@@ -24,13 +24,14 @@ class CloudVMTypeServiceTestCase(ProviderTestBase):
                 vm_type.family is None or isinstance(
                     vm_type.family,
                     six.string_types),
-                "VMType family family be None or a"
+                "VMType family must be None or a"
                 " string but is: {0}".format(vm_type.family))
             self.assertTrue(
                 vm_type.vcpus is None or (
                     isinstance(vm_type.vcpus, six.integer_types) and
                     vm_type.vcpus >= 0),
-                "VMType vcpus family must be None or a positive integer")
+                "VMType vcpus must be None or a positive integer but is: {0}"
+                .format(vm_type.vcpus))
             self.assertTrue(
                 vm_type.ram is None or vm_type.ram >= 0,
                 "VMType ram must be None or a positive number")