From 7c9efa6bdfbc73806349ff684eff5e87ede086ad Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 16 Feb 2020 19:27:46 -0600 Subject: [PATCH] mgr/test_orchestrator: describe_service -> list_daemons Signed-off-by: Sage Weil --- qa/tasks/mgr/dashboard/test_orchestrator.py | 24 +++++++++---------- .../mgr/dashboard/services/orchestrator.py | 2 +- .../mgr/test_orchestrator/dummy_data.json | 6 ++--- src/pybind/mgr/test_orchestrator/module.py | 24 +++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_orchestrator.py b/qa/tasks/mgr/dashboard/test_orchestrator.py index 4f702066e73..e8fa0fa93d7 100644 --- a/qa/tasks/mgr/dashboard/test_orchestrator.py +++ b/qa/tasks/mgr/dashboard/test_orchestrator.py @@ -26,26 +26,26 @@ test_data = { ] } ], - 'services': [ + 'daemons': [ { 'nodename': 'test-host0', - 'service_type': 'mon', - 'service_instance': 'a' + 'daemon_type': 'mon', + 'daemon_id': 'a' }, { 'nodename': 'test-host0', - 'service_type': 'mgr', - 'service_instance': 'x' + 'daemon_type': 'mgr', + 'daemon_id': 'x' }, { 'nodename': 'test-host0', - 'service_type': 'osd', - 'service_instance': '0' + 'daemon_type': 'osd', + 'daemon_id': '0' }, { 'nodename': 'test-host1', - 'service_type': 'osd', - 'service_instance': '1' + 'daemon_type': 'osd', + 'daemon_id': '1' } ] } @@ -66,8 +66,8 @@ class OrchestratorControllerTest(DashboardTestCase): return test_data['inventory'] @property - def test_data_services(self): - return test_data['services'] + def test_data_daemons(self): + return test_data['daemons'] @classmethod def setUpClass(cls): @@ -100,7 +100,7 @@ class OrchestratorControllerTest(DashboardTestCase): for key, value in data.items(): self.assertEqual(value, resp_data[key]) - def _validate_service(self, data, resp_data): + def _validate_daemon(self, data, resp_data): for key, value in data.items(): self.assertEqual(value, resp_data[key]) diff --git a/src/pybind/mgr/dashboard/services/orchestrator.py b/src/pybind/mgr/dashboard/services/orchestrator.py index c60e32cec69..6973632eb22 100644 --- a/src/pybind/mgr/dashboard/services/orchestrator.py +++ b/src/pybind/mgr/dashboard/services/orchestrator.py @@ -77,7 +77,7 @@ class ServiceManager(ResourceManager): @wait_api_result def list(self, service_type=None, service_id=None, node_name=None): - return self.api.describe_service(service_type, service_id, node_name) + return self.api.list_daemons(service_type, service_id, node_name) def reload(self, service_type, service_ids): if not isinstance(service_ids, list): diff --git a/src/pybind/mgr/test_orchestrator/dummy_data.json b/src/pybind/mgr/test_orchestrator/dummy_data.json index b68898acf59..4d7866ea1a0 100644 --- a/src/pybind/mgr/test_orchestrator/dummy_data.json +++ b/src/pybind/mgr/test_orchestrator/dummy_data.json @@ -145,11 +145,11 @@ ] } ], - "services": [ + "daemons": [ { "nodename": "host0", - "service_type": "osd", - "service_instance": "1" + "daemon_type": "osd", + "daemon_id": "1" } ] } diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 7db7216f068..6af285e7692 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -117,8 +117,8 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): def _init_data(self, data=None): self._inventory = [orchestrator.InventoryNode.from_json(inventory_node) for inventory_node in data.get('inventory', [])] - self._services = [orchestrator.ServiceDescription.from_json(service) - for service in data.get('services', [])] + self._daemons = [orchestrator.DaemonDescription.from_json(service) + for service in data.get('daemons', [])] @deferred_read def get_inventory(self, node_filter=None, refresh=False): @@ -154,32 +154,32 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): raise Exception('c-v failed') @deferred_read - def describe_service(self, service_type=None, service_id=None, node_name=None, refresh=False): + def list_daemons(self, daemon_type=None, daemon_id=None, node_name=None, refresh=False): """ There is no guarantee which daemons are returned by describe_service, except that it returns the mgr we're running in. """ - if service_type: - support_services = ("mds", "osd", "mon", "rgw", "mgr", "iscsi") - assert service_type in support_services, service_type + " unsupported" + if daemon_type: + daemon_types = ("mds", "osd", "mon", "rgw", "mgr", "iscsi") + assert daemon_type in daemon_types, daemon_type + " unsupported" - if self._services: + if self._daemons: if node_name: - return list(filter(lambda svc: svc.nodename == node_name, self._services)) - return self._services + return list(filter(lambda svc: svc.nodename == node_name, self._daemons)) + return self._daemons out = map(str, check_output(['ps', 'aux']).splitlines()) - types = (service_type, ) if service_type else ("mds", "osd", "mon", "rgw", "mgr") + types = (daemon_type, ) if daemon_type else ("mds", "osd", "mon", "rgw", "mgr") assert isinstance(types, tuple) processes = [p for p in out if any([('ceph-' + t in p) for t in types])] result = [] for p in processes: - sd = orchestrator.ServiceDescription() + sd = orchestrator.DaemonDescription() sd.nodename = 'localhost' res = re.search('ceph-[^ ]+', p) assert res - sd.service_instance = res.group() + sd.daemon_id = res.group() result.append(sd) return result -- 2.39.5