]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: cleanups
authorPere Diaz Bou <pdiazbou@redhat.com>
Tue, 5 Jul 2022 11:22:42 +0000 (13:22 +0200)
committerPere Diaz Bou <pdiazbou@redhat.com>
Thu, 14 Jul 2022 15:28:37 +0000 (17:28 +0200)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
(cherry picked from commit 23615b3e1b0d479595929d6483856afce67502d2)

src/pybind/mgr/dashboard/controllers/rbd.py
src/pybind/mgr/dashboard/services/rbd.py

index 943a0936720526919a2f58fb4cbd230f6e5587b2..2f0e4b3836c277113a73ddb129edc31126043512 100644 (file)
@@ -80,7 +80,9 @@ class Rbd(RESTController):
     ALLOW_DISABLE_FEATURES = {"exclusive-lock", "object-map", "fast-diff", "deep-flatten",
                               "journaling"}
 
-    def _rbd_list(self, pool_name=None, offset=0, limit=5, search='', sort=''):
+    DEFAULT_LIMIT = 5
+
+    def _rbd_list(self, pool_name=None, offset=0, limit=DEFAULT_LIMIT, search='', sort=''):
         if pool_name:
             pools = [pool_name]
         else:
@@ -110,7 +112,7 @@ class Rbd(RESTController):
                  },
                  responses={200: RBD_SCHEMA})
     @RESTController.MethodMap(version=APIVersion(2, 0))  # type: ignore
-    def list(self, pool_name=None, offset: int = 0, limit: int = 5,
+    def list(self, pool_name=None, offset: int = 0, limit: int = DEFAULT_LIMIT,
              search: str = '', sort: str = ''):
         return self._rbd_list(pool_name, offset=offset, limit=limit, search=search, sort=sort)
 
index d35a99e97a3b2425b68a357acb92831bc527d61d..ad471a9fae17c5a405da6890c6fc08c731f6847c 100644 (file)
@@ -15,7 +15,7 @@ from ..plugins.ttl_cache import ttl_cache
 from .ceph_service import CephService
 
 try:
-    from typing import List
+    from typing import List, Optional
 except ImportError:
     pass  # For typing only
 
@@ -424,7 +424,7 @@ class RbdService(object):
                                 errno=errno.ENOENT)
 
     @classmethod
-    def _rbd_pool_image_refs(cls, pool_names: List[str], namespace=None):
+    def _rbd_pool_image_refs(cls, pool_names: List[str], namespace: Optional[str] = None):
         joint_refs = []
         rbd_inst = rbd.RBD()
         for pool in pool_names:
@@ -445,14 +445,14 @@ class RbdService(object):
         return joint_refs
 
     @classmethod
-    def rbd_pool_list(cls, pool_names: List[str], namespace=None, offset=0, limit=0,
-                      search='', sort=''):
+    def rbd_pool_list(cls, pool_names: List[str], namespace: Optional[str] = None, offset: int = 0,
+                      limit: int = 5, search: str = '', sort: str = ''):
         offset = int(offset)
         limit = int(limit)
         # let's use -1 to denotate we want ALL images for now. Iscsi currently gathers
         # all images therefore, we need this.
         if limit < -1:
-            return []
+            raise DashboardException(msg=f'Wrong limit value {limit}', code=400)
 
         refs = cls._rbd_pool_image_refs(pool_names, namespace)
         image_refs = []