|
23 | 23 | # SOFTWARE. |
24 | 24 | # |
25 | 25 | ############################################################################### |
| 26 | +from pydantic import ValidationError |
26 | 27 |
|
27 | 28 | from nodescraper.base import InBandDataCollector |
28 | 29 | from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily |
@@ -61,34 +62,46 @@ def collect_data( |
61 | 62 | "nvme smart-log /dev/nvme0", |
62 | 63 | "nvme error-log /dev/nvme0 --log-entries=256", |
63 | 64 | "nvme id-ctrl /dev/nvme0", |
64 | | - "nvme id-ns /dev/nvme0", |
| 65 | + "nvme id-ns /dev/nvme0n1", |
65 | 66 | "nvme fw-log /dev/nvme0", |
66 | 67 | "nvme self-test-log /dev/nvme0", |
67 | | - "nvme telemetry-log /dev/nvme0", |
| 68 | + "nvme get-log /dev/nvme0 --log-id=6 --log-len=512", |
68 | 69 | ] |
69 | 70 |
|
70 | 71 | for cmd in commands: |
71 | | - res = self._run_sut_cmd(cmd) |
| 72 | + res = self._run_sut_cmd(cmd, sudo=True) |
72 | 73 | if res.exit_code == 0: |
73 | 74 | data[cmd] = res.stdout |
74 | 75 | else: |
75 | 76 | self._log_event( |
76 | 77 | category=EventCategory.SW_DRIVER, |
77 | | - description="Failed to execute NVMe command", |
| 78 | + description=f"Failed to execute NVMe command: '{cmd}'", |
78 | 79 | data={"command": cmd, "exit_code": res.exit_code}, |
79 | 80 | priority=EventPriority.ERROR, |
80 | 81 | console_log=True, |
81 | 82 | ) |
82 | 83 |
|
| 84 | + nvme_data = None |
83 | 85 | if data: |
84 | | - nvme_data = NvmeDataModel(nvme_data=data) |
85 | | - self._log_event( |
86 | | - category=EventCategory.SW_DRIVER, |
87 | | - description="Collected NVMe data", |
88 | | - data=nvme_data.model_dump(), |
89 | | - priority=EventPriority.INFO, |
90 | | - ) |
91 | | - self.result.message = "NVMe data successfully collected" |
| 86 | + try: |
| 87 | + nvme_data = NvmeDataModel(nvme_data=data) |
| 88 | + except ValidationError as e: |
| 89 | + self._log_event( |
| 90 | + category=EventCategory.SW_DRIVER, |
| 91 | + description="Validation error while building NvmeDataModel", |
| 92 | + data={"error": str(e)}, |
| 93 | + priority=EventPriority.CRITICAL, |
| 94 | + ) |
| 95 | + self.result.message = "NVMe data invalid format" |
| 96 | + self.result.status = ExecutionStatus.ERROR |
| 97 | + # nvme_data = NvmeDataModel(nvme_data=data) |
| 98 | + # self._log_event( |
| 99 | + # category=EventCategory.SW_DRIVER, |
| 100 | + # description="Collected NVMe data", |
| 101 | + # data=nvme_data.model_dump(), |
| 102 | + # priority=EventPriority.INFO, |
| 103 | + # ) |
| 104 | + # self.result.message = "NVMe data successfully collected" |
92 | 105 | else: |
93 | 106 | nvme_data = None |
94 | 107 | self._log_event( |
|
0 commit comments