From e4467b7df16e5162e4a98d3d5089a2569713ffa4 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Wed, 2 Sep 2020 20:25:52 +0800 Subject: [PATCH] mgr/dashboard: refator orchestrator service and daemon APIs - Allow listing services by service_type. - Allow listing daemons by daemon_type. Signed-off-by: Kiefer Chang (cherry picked from commit b88638873bd738af1ce258549abb6c25e0683907) --- src/pybind/mgr/dashboard/controllers/host.py | 2 +- src/pybind/mgr/dashboard/controllers/service.py | 4 ++-- src/pybind/mgr/dashboard/services/orchestrator.py | 11 ++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/host.py b/src/pybind/mgr/dashboard/controllers/host.py index c8a4d9007231e..bb9014bec65c7 100644 --- a/src/pybind/mgr/dashboard/controllers/host.py +++ b/src/pybind/mgr/dashboard/controllers/host.py @@ -166,7 +166,7 @@ class Host(RESTController): @raise_if_no_orchestrator def daemons(self, hostname: str) -> List[dict]: orch = OrchClient.instance() - daemons = orch.services.list_daemons(None, hostname) + daemons = orch.services.list_daemons(hostname=hostname) return [d.to_json() for d in daemons] @handle_orchestrator_error('host') diff --git a/src/pybind/mgr/dashboard/controllers/service.py b/src/pybind/mgr/dashboard/controllers/service.py index 9f1e70bb94dd8..509a2147a685a 100644 --- a/src/pybind/mgr/dashboard/controllers/service.py +++ b/src/pybind/mgr/dashboard/controllers/service.py @@ -13,7 +13,7 @@ class Service(RESTController): @raise_if_no_orchestrator def list(self, service_name: Optional[str] = None) -> List[dict]: orch = OrchClient.instance() - return [service.to_json() for service in orch.services.list(service_name)] + return [service.to_json() for service in orch.services.list(service_name=service_name)] @raise_if_no_orchestrator def get(self, service_name: str) -> List[dict]: @@ -27,5 +27,5 @@ class Service(RESTController): @raise_if_no_orchestrator def daemons(self, service_name: str) -> List[dict]: orch = OrchClient.instance() - daemons = orch.services.list_daemons(service_name) + daemons = orch.services.list_daemons(service_name=service_name) return [d.to_json() for d in daemons] diff --git a/src/pybind/mgr/dashboard/services/orchestrator.py b/src/pybind/mgr/dashboard/services/orchestrator.py index ea33b9a37ee28..a1f22a9a0673a 100644 --- a/src/pybind/mgr/dashboard/services/orchestrator.py +++ b/src/pybind/mgr/dashboard/services/orchestrator.py @@ -84,8 +84,10 @@ class InventoryManager(ResourceManager): class ServiceManager(ResourceManager): @wait_api_result - def list(self, service_name: Optional[str] = None) -> List[ServiceDescription]: - return self.api.describe_service(None, service_name) + def list(self, + service_type: Optional[str] = None, + service_name: Optional[str] = None) -> List[ServiceDescription]: + return self.api.describe_service(service_type, service_name) @wait_api_result def get(self, service_name: str) -> ServiceDescription: @@ -94,8 +96,11 @@ class ServiceManager(ResourceManager): @wait_api_result def list_daemons(self, service_name: Optional[str] = None, + daemon_type: Optional[str] = None, hostname: Optional[str] = None) -> List[DaemonDescription]: - return self.api.list_daemons(service_name, host=hostname) + return self.api.list_daemons(service_name=service_name, + daemon_type=daemon_type, + host=hostname) def reload(self, service_type, service_ids): if not isinstance(service_ids, list): -- 2.39.5