From: Guillaume Abrioux Date: Thu, 20 May 2021 14:06:05 +0000 (+0200) Subject: cephadm: add daemon_name in daemon description X-Git-Tag: v16.2.7~67^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8255b1462b3e52d34a3357390d62341dd8fd5715;p=ceph.git cephadm: add daemon_name in daemon description This adds the daemon_name in json output when asking for daemon description. Signed-off-by: Guillaume Abrioux (cherry picked from commit 19ee16a46b90d92f1a49ace5ba1a3c47eb8c1403) --- diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index dfa3cb4b6ef..649c09013fb 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -115,6 +115,7 @@ class TestCephadm(object): out = dd.to_json() del out['daemon_id'] del out['events'] + del out['daemon_name'] return out assert [remove_id_events(dd) for dd in wait(cephadm_module, c)] == [ diff --git a/src/pybind/mgr/cephadm/tests/test_spec.py b/src/pybind/mgr/cephadm/tests/test_spec.py index d46cbfe7f17..23fcf9c2367 100644 --- a/src/pybind/mgr/cephadm/tests/test_spec.py +++ b/src/pybind/mgr/cephadm/tests/test_spec.py @@ -284,6 +284,7 @@ def test_dd_octopus(dd_json): 'last_configured']: if k in j: j[k] = j[k].rstrip('Z') + del j['daemon_name'] return j assert dd_json == convert_to_old_style_json( diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 34beb5e2a3f..a88ab9c71c7 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -829,6 +829,7 @@ class DaemonDescription(object): # This is the in mds., the ID that will appear # in the FSMap/ServiceMap. self.daemon_id: Optional[str] = daemon_id + self.daemon_name = self.name() # Some daemon types have a numeric rank assigned self.rank: Optional[int] = rank @@ -962,6 +963,7 @@ class DaemonDescription(object): out['daemon_type'] = self.daemon_type out['daemon_id'] = self.daemon_id out['service_name'] = self._service_name + out['daemon_name'] = self.name() out['hostname'] = self.hostname out['container_id'] = self.container_id out['container_image_id'] = self.container_image_id @@ -998,6 +1000,7 @@ class DaemonDescription(object): out: Dict[str, Any] = OrderedDict() out['daemon_type'] = self.daemon_type out['daemon_id'] = self.daemon_id + out['daemon_name'] = self.name() out['hostname'] = self.hostname out['container_id'] = self.container_id out['container_image_id'] = self.container_image_id @@ -1039,6 +1042,8 @@ class DaemonDescription(object): c[k] = str_to_datetime(c[k]) events = [OrchestratorEvent.from_json(e) for e in event_strs] status_int = c.pop('status', None) + if 'daemon_name' in c: + del c['daemon_name'] status = DaemonDescriptionStatus(status_int) if status_int is not None else None return cls(events=events, status=status, **c) diff --git a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py index 35f4b64b878..7ccd0614666 100644 --- a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py @@ -84,6 +84,7 @@ def test_apply(): def test_yaml(): y = """daemon_type: crash daemon_id: ubuntu +daemon_name: crash.ubuntu hostname: ubuntu status: 1 status_desc: starting