]> git.apps.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>
Fri, 9 Sep 2022 17:30:24 +0000 (19:30 +0200)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
(cherry picked from commit 23615b3e1b0d479595929d6483856afce67502d2)
(cherry picked from commit c685773a691afe25666166af28fc250b285b6e1b)

Resolves: rhbz#2125432

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

index ac49d077c7ae4864a985948e5346b285f59bccee..58a7ab7710dd8e8996ed4497b4e594b26c0bf237 100644 (file)
@@ -79,7 +79,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:
@@ -109,7 +111,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 7d8ea04d1e46cce5bda27f77a0dd9f2e45736609..2384d42e9bc2545aa13492dbaadfef241cfc97d0 100644 (file)
@@ -13,7 +13,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
 
@@ -409,7 +409,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:
@@ -430,14 +430,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 = []