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, \
ServiceDescription, raise_if_exception
from .. import mgr
+from ._paginate import ListPaginator
logger = logging.getLogger('orchestrator')
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: