]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/services/orchestrator.py
import ceph quincy 17.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / orchestrator.py
index 6829108e098d54315d9ba39eba891a6fcf12337c..1818164d6c96cbe3d30379e8783b03212b4548be 100644 (file)
@@ -2,7 +2,7 @@
 
 import logging
 from functools import wraps
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Optional, Tuple
 
 from ceph.deployment.service_spec import ServiceSpec
 from orchestrator import DaemonDescription, DeviceLightLoc, HostSpec, \
@@ -10,6 +10,7 @@ from orchestrator import DaemonDescription, DeviceLightLoc, HostSpec, \
     ServiceDescription, raise_if_exception
 
 from .. import mgr
+from ._paginate import ListPaginator
 
 logger = logging.getLogger('orchestrator')
 
@@ -95,11 +96,21 @@ class InventoryManager(ResourceManager):
 
 
 class ServiceManager(ResourceManager):
-    @wait_api_result
     def list(self,
              service_type: Optional[str] = None,
-             service_name: Optional[str] = None) -> List[ServiceDescription]:
-        return self.api.describe_service(service_type, service_name)
+             service_name: Optional[str] = None,
+             offset: int = 0, limit: int = -1,
+             sort: str = '+service_name', search: str = '') -> Tuple[List[Dict[Any, Any]], int]:
+        services = self.api.describe_service(service_type, service_name)
+        services = [service.to_dict() for service in services.result]
+        paginator = ListPaginator(offset, limit, sort, search,
+                                  input_list=services,
+                                  searchable_params=['service_name', 'status.running',
+                                                     'status.last_refreshed', 'status.size'],
+                                  sortable_params=['service_name', 'status.running',
+                                                   'status.last_refreshed', 'status.size'],
+                                  default_sort='+service_name')
+        return list(paginator.list()), paginator.get_count()
 
     @wait_api_result
     def get(self, service_name: str) -> ServiceDescription: