From b88638873bd738af1ce258549abb6c25e0683907 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 --- 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 abae3284b35de..8394fc578e3ab 100644 --- a/src/pybind/mgr/dashboard/controllers/host.py +++ b/src/pybind/mgr/dashboard/controllers/host.py @@ -189,7 +189,7 @@ class Host(RESTController): @raise_if_no_orchestrator([OrchFeature.DAEMON_LIST]) 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 b62e7d68a3315..4470f8f831e02 100644 --- a/src/pybind/mgr/dashboard/controllers/service.py +++ b/src/pybind/mgr/dashboard/controllers/service.py @@ -32,7 +32,7 @@ class Service(RESTController): @raise_if_no_orchestrator([OrchFeature.SERVICE_LIST]) 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([OrchFeature.SERVICE_LIST]) def get(self, service_name: str) -> List[dict]: @@ -46,7 +46,7 @@ class Service(RESTController): @raise_if_no_orchestrator([OrchFeature.DAEMON_LIST]) 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] @CreatePermission diff --git a/src/pybind/mgr/dashboard/services/orchestrator.py b/src/pybind/mgr/dashboard/services/orchestrator.py index 37b7b3b141e1d..16c038ada6e78 100644 --- a/src/pybind/mgr/dashboard/services/orchestrator.py +++ b/src/pybind/mgr/dashboard/services/orchestrator.py @@ -85,8 +85,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: @@ -95,8 +97,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