|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
| 3 | +from collections import OrderedDict |
3 | 4 | from time import sleep |
4 | 5 | from typing import Any, Dict, List |
5 | 6 | from ..exception import ModuleException |
@@ -84,14 +85,42 @@ def preflight(self) -> None: |
84 | 85 |
|
85 | 86 | def execute(self) -> None: |
86 | 87 | osd_host_devices = self.machine.get_preflight_state_data( |
87 | | - "MigrateOSDsHandler", "osd_host_devices", default_value=[] |
| 88 | + "MigrateOSDsHandler", "osd_host_devices", default_value={} |
88 | 89 | ) |
89 | 90 |
|
90 | 91 | state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data |
91 | 92 |
|
92 | 93 | for host in osd_host_devices.keys(): |
93 | 94 | self.migrate_osds(host, state_data["node"]["ls"]["osd"][host]) |
94 | 95 |
|
| 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 | + |
95 | 124 | def migrate_osds(self, host: str, osd_ids: List[int]) -> None: |
96 | 125 | migrated_osd_ids = self.machine.get_execution_state_data( |
97 | 126 | "MigrateOSDsHandler", "migrated_osd_ids", default_value=[] |
|
0 commit comments