Skip to content

Commit

Permalink
Return representive state data for module migrate_osds
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne committed Sep 17, 2024
1 parent ae5399c commit 074ac03
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/rookify/modules/migrate_osds/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from collections import OrderedDict
from time import sleep
from typing import Any, Dict, List
from ..exception import ModuleException
Expand Down Expand Up @@ -84,14 +85,42 @@ def preflight(self) -> None:

def execute(self) -> None:
osd_host_devices = self.machine.get_preflight_state_data(
"MigrateOSDsHandler", "osd_host_devices", default_value=[]
"MigrateOSDsHandler", "osd_host_devices", default_value={}
)

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

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

def get_readable_key_value_state(self) -> Dict[str, str]:
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data

osd_host_devices = self.machine.get_preflight_state_data(
"MigrateOSDsHandler", "osd_host_devices", default_value={}
)

kv_state_data = OrderedDict()

for host in state_data["node"]["ls"]["osd"].keys():
if host in osd_host_devices:
osd_device_list = []

for osd_id, device_path in osd_host_devices[host].items():
osd_device_list.append(
{"OSD ID": osd_id, "Device path": device_path}
)

kv_state_data["ceph OSD node {0} devices".format(host)] = (
self._get_readable_json_dump(osd_device_list)
)
else:
kv_state_data["ceph OSD node {0} devices".format(host)] = (
"Not analyzed yet"
)

return kv_state_data

def migrate_osds(self, host: str, osd_ids: List[int]) -> None:
migrated_osd_ids = self.machine.get_execution_state_data(
"MigrateOSDsHandler", "migrated_osd_ids", default_value=[]
Expand Down

0 comments on commit 074ac03

Please sign in to comment.