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

Commit 074ac03

Browse files
committed
Return representive state data for module migrate_osds
Signed-off-by: Tobias Wolf <[email protected]>
1 parent ae5399c commit 074ac03

File tree

1 file changed

+30
-1
lines changed
  • src/rookify/modules/migrate_osds

1 file changed

+30
-1
lines changed

src/rookify/modules/migrate_osds/main.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
from collections import OrderedDict
34
from time import sleep
45
from typing import Any, Dict, List
56
from ..exception import ModuleException
@@ -84,14 +85,42 @@ def preflight(self) -> None:
8485

8586
def execute(self) -> None:
8687
osd_host_devices = self.machine.get_preflight_state_data(
87-
"MigrateOSDsHandler", "osd_host_devices", default_value=[]
88+
"MigrateOSDsHandler", "osd_host_devices", default_value={}
8889
)
8990

9091
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data
9192

9293
for host in osd_host_devices.keys():
9394
self.migrate_osds(host, state_data["node"]["ls"]["osd"][host])
9495

96+
def get_readable_key_value_state(self) -> Dict[str, str]:
97+
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data
98+
99+
osd_host_devices = self.machine.get_preflight_state_data(
100+
"MigrateOSDsHandler", "osd_host_devices", default_value={}
101+
)
102+
103+
kv_state_data = OrderedDict()
104+
105+
for host in state_data["node"]["ls"]["osd"].keys():
106+
if host in osd_host_devices:
107+
osd_device_list = []
108+
109+
for osd_id, device_path in osd_host_devices[host].items():
110+
osd_device_list.append(
111+
{"OSD ID": osd_id, "Device path": device_path}
112+
)
113+
114+
kv_state_data["ceph OSD node {0} devices".format(host)] = (
115+
self._get_readable_json_dump(osd_device_list)
116+
)
117+
else:
118+
kv_state_data["ceph OSD node {0} devices".format(host)] = (
119+
"Not analyzed yet"
120+
)
121+
122+
return kv_state_data
123+
95124
def migrate_osds(self, host: str, osd_ids: List[int]) -> None:
96125
migrated_osd_ids = self.machine.get_execution_state_data(
97126
"MigrateOSDsHandler", "migrated_osd_ids", default_value=[]

0 commit comments

Comments
 (0)