Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit d89d12c

Browse files
committed
Return representive state data for module analyze_ceph
This reverts commit b33cd08. Signed-off-by: Tobias Wolf <[email protected]>
1 parent 3a7f91d commit d89d12c

File tree

1 file changed

+24
-15
lines changed
  • src/rookify/modules/analyze_ceph

1 file changed

+24
-15
lines changed

src/rookify/modules/analyze_ceph/main.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
from typing import Any, Optional
3+
from collections import OrderedDict
4+
from typing import Any, Dict, Optional
45
from ..machine import Machine
56
from ..module import ModuleHandler
67

@@ -39,26 +40,34 @@ def preflight(self) -> Any:
3940

4041
self.logger.info("AnalyzeCephHandler ran successfully.")
4142

42-
def status(self) -> Any:
43-
commands = ["mon dump", "osd dump", "device ls", "fs ls", "node ls"]
43+
def get_readable_key_value_state(self) -> Dict[str, str]:
4444
state = self.machine.get_preflight_state("AnalyzeCephHandler")
4545

46-
# Check if all expected commands have been run
47-
all_commands_found = True
48-
for command in commands:
49-
if not self._process_command(state.data, command):
50-
all_commands_found = False
51-
break
46+
kv_state_data = OrderedDict()
47+
48+
if "mon" not in state.data or "dump" not in state.data["mon"]:
49+
kv_state_data["ceph mon dump"] = "Not analyzed yet"
50+
else:
51+
kv_state_data["ceph mon dump"] = self._get_readable_json_dump(
52+
state.data["mon"]["dump"]
53+
)
5254

53-
# Log the status
54-
if all_commands_found:
55-
self.logger.info("AnalyzeCephHandler has already been run.")
56-
self.logger.info("Current state data: %s", state.data)
55+
if "osd" not in state.data or "dump" not in state.data["osd"]:
56+
kv_state_data["ceph osd dump"] = "Not analyzed yet"
5757
else:
58-
self.logger.info(
59-
"AnalyzeCephHandler Progress: Not all commands have been run yet."
58+
kv_state_data["ceph osd dump"] = self._get_readable_json_dump(
59+
state.data["osd"]["dump"]
6060
)
6161

62+
if "device" not in state.data or "ls" not in state.data["device"]:
63+
kv_state_data["OSD devices"] = "Not analyzed yet"
64+
else:
65+
kv_state_data["OSD devices"] = self._get_readable_json_dump(
66+
state.data["device"]["ls"]
67+
)
68+
69+
return kv_state_data
70+
6271
@staticmethod
6372
def register_preflight_state(
6473
machine: Machine, state_name: str, handler: ModuleHandler, **kwargs: Any

0 commit comments

Comments
 (0)