amd-node-scraper 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. amd_node_scraper-0.0.1.dist-info/LICENSE +21 -0
  2. amd_node_scraper-0.0.1.dist-info/METADATA +424 -0
  3. amd_node_scraper-0.0.1.dist-info/RECORD +197 -0
  4. amd_node_scraper-0.0.1.dist-info/WHEEL +5 -0
  5. amd_node_scraper-0.0.1.dist-info/entry_points.txt +2 -0
  6. amd_node_scraper-0.0.1.dist-info/top_level.txt +1 -0
  7. nodescraper/__init__.py +32 -0
  8. nodescraper/base/__init__.py +34 -0
  9. nodescraper/base/inbandcollectortask.py +118 -0
  10. nodescraper/base/inbanddataplugin.py +39 -0
  11. nodescraper/base/regexanalyzer.py +120 -0
  12. nodescraper/cli/__init__.py +29 -0
  13. nodescraper/cli/cli.py +511 -0
  14. nodescraper/cli/constants.py +27 -0
  15. nodescraper/cli/dynamicparserbuilder.py +171 -0
  16. nodescraper/cli/helper.py +517 -0
  17. nodescraper/cli/inputargtypes.py +129 -0
  18. nodescraper/configbuilder.py +123 -0
  19. nodescraper/configregistry.py +66 -0
  20. nodescraper/configs/node_status.json +19 -0
  21. nodescraper/connection/__init__.py +25 -0
  22. nodescraper/connection/inband/__init__.py +46 -0
  23. nodescraper/connection/inband/inband.py +171 -0
  24. nodescraper/connection/inband/inbandlocal.py +93 -0
  25. nodescraper/connection/inband/inbandmanager.py +151 -0
  26. nodescraper/connection/inband/inbandremote.py +173 -0
  27. nodescraper/connection/inband/sshparams.py +43 -0
  28. nodescraper/constants.py +26 -0
  29. nodescraper/enums/__init__.py +40 -0
  30. nodescraper/enums/eventcategory.py +89 -0
  31. nodescraper/enums/eventpriority.py +42 -0
  32. nodescraper/enums/executionstatus.py +44 -0
  33. nodescraper/enums/osfamily.py +34 -0
  34. nodescraper/enums/systeminteraction.py +41 -0
  35. nodescraper/enums/systemlocation.py +33 -0
  36. nodescraper/generictypes.py +36 -0
  37. nodescraper/interfaces/__init__.py +44 -0
  38. nodescraper/interfaces/connectionmanager.py +143 -0
  39. nodescraper/interfaces/dataanalyzertask.py +138 -0
  40. nodescraper/interfaces/datacollectortask.py +185 -0
  41. nodescraper/interfaces/dataplugin.py +356 -0
  42. nodescraper/interfaces/plugin.py +127 -0
  43. nodescraper/interfaces/resultcollator.py +56 -0
  44. nodescraper/interfaces/task.py +164 -0
  45. nodescraper/interfaces/taskresulthook.py +39 -0
  46. nodescraper/models/__init__.py +48 -0
  47. nodescraper/models/analyzerargs.py +93 -0
  48. nodescraper/models/collectorargs.py +30 -0
  49. nodescraper/models/connectionconfig.py +34 -0
  50. nodescraper/models/datamodel.py +171 -0
  51. nodescraper/models/datapluginresult.py +39 -0
  52. nodescraper/models/event.py +158 -0
  53. nodescraper/models/pluginconfig.py +38 -0
  54. nodescraper/models/pluginresult.py +39 -0
  55. nodescraper/models/systeminfo.py +44 -0
  56. nodescraper/models/taskresult.py +185 -0
  57. nodescraper/models/timerangeargs.py +38 -0
  58. nodescraper/pluginexecutor.py +274 -0
  59. nodescraper/pluginregistry.py +152 -0
  60. nodescraper/plugins/__init__.py +25 -0
  61. nodescraper/plugins/inband/__init__.py +25 -0
  62. nodescraper/plugins/inband/amdsmi/__init__.py +28 -0
  63. nodescraper/plugins/inband/amdsmi/amdsmi_analyzer.py +821 -0
  64. nodescraper/plugins/inband/amdsmi/amdsmi_collector.py +1313 -0
  65. nodescraper/plugins/inband/amdsmi/amdsmi_plugin.py +43 -0
  66. nodescraper/plugins/inband/amdsmi/amdsmidata.py +1002 -0
  67. nodescraper/plugins/inband/amdsmi/analyzer_args.py +50 -0
  68. nodescraper/plugins/inband/amdsmi/cper.py +65 -0
  69. nodescraper/plugins/inband/bios/__init__.py +29 -0
  70. nodescraper/plugins/inband/bios/analyzer_args.py +64 -0
  71. nodescraper/plugins/inband/bios/bios_analyzer.py +93 -0
  72. nodescraper/plugins/inband/bios/bios_collector.py +93 -0
  73. nodescraper/plugins/inband/bios/bios_plugin.py +43 -0
  74. nodescraper/plugins/inband/bios/biosdata.py +30 -0
  75. nodescraper/plugins/inband/cmdline/__init__.py +25 -0
  76. nodescraper/plugins/inband/cmdline/analyzer_args.py +80 -0
  77. nodescraper/plugins/inband/cmdline/cmdline_analyzer.py +113 -0
  78. nodescraper/plugins/inband/cmdline/cmdline_collector.py +77 -0
  79. nodescraper/plugins/inband/cmdline/cmdline_plugin.py +43 -0
  80. nodescraper/plugins/inband/cmdline/cmdlinedata.py +30 -0
  81. nodescraper/plugins/inband/device_enumeration/__init__.py +29 -0
  82. nodescraper/plugins/inband/device_enumeration/analyzer_args.py +73 -0
  83. nodescraper/plugins/inband/device_enumeration/device_enumeration_analyzer.py +81 -0
  84. nodescraper/plugins/inband/device_enumeration/device_enumeration_collector.py +176 -0
  85. nodescraper/plugins/inband/device_enumeration/device_enumeration_plugin.py +45 -0
  86. nodescraper/plugins/inband/device_enumeration/deviceenumdata.py +36 -0
  87. nodescraper/plugins/inband/dimm/__init__.py +25 -0
  88. nodescraper/plugins/inband/dimm/collector_args.py +31 -0
  89. nodescraper/plugins/inband/dimm/dimm_collector.py +151 -0
  90. nodescraper/plugins/inband/dimm/dimm_plugin.py +40 -0
  91. nodescraper/plugins/inband/dimm/dimmdata.py +30 -0
  92. nodescraper/plugins/inband/dkms/__init__.py +25 -0
  93. nodescraper/plugins/inband/dkms/analyzer_args.py +85 -0
  94. nodescraper/plugins/inband/dkms/dkms_analyzer.py +106 -0
  95. nodescraper/plugins/inband/dkms/dkms_collector.py +76 -0
  96. nodescraper/plugins/inband/dkms/dkms_plugin.py +43 -0
  97. nodescraper/plugins/inband/dkms/dkmsdata.py +33 -0
  98. nodescraper/plugins/inband/dmesg/__init__.py +28 -0
  99. nodescraper/plugins/inband/dmesg/analyzer_args.py +33 -0
  100. nodescraper/plugins/inband/dmesg/collector_args.py +39 -0
  101. nodescraper/plugins/inband/dmesg/dmesg_analyzer.py +503 -0
  102. nodescraper/plugins/inband/dmesg/dmesg_collector.py +164 -0
  103. nodescraper/plugins/inband/dmesg/dmesg_plugin.py +44 -0
  104. nodescraper/plugins/inband/dmesg/dmesgdata.py +116 -0
  105. nodescraper/plugins/inband/fabrics/__init__.py +28 -0
  106. nodescraper/plugins/inband/fabrics/fabrics_collector.py +726 -0
  107. nodescraper/plugins/inband/fabrics/fabrics_plugin.py +37 -0
  108. nodescraper/plugins/inband/fabrics/fabricsdata.py +140 -0
  109. nodescraper/plugins/inband/journal/__init__.py +28 -0
  110. nodescraper/plugins/inband/journal/collector_args.py +33 -0
  111. nodescraper/plugins/inband/journal/journal_collector.py +107 -0
  112. nodescraper/plugins/inband/journal/journal_plugin.py +40 -0
  113. nodescraper/plugins/inband/journal/journaldata.py +44 -0
  114. nodescraper/plugins/inband/kernel/__init__.py +25 -0
  115. nodescraper/plugins/inband/kernel/analyzer_args.py +64 -0
  116. nodescraper/plugins/inband/kernel/kernel_analyzer.py +91 -0
  117. nodescraper/plugins/inband/kernel/kernel_collector.py +129 -0
  118. nodescraper/plugins/inband/kernel/kernel_plugin.py +43 -0
  119. nodescraper/plugins/inband/kernel/kerneldata.py +32 -0
  120. nodescraper/plugins/inband/kernel_module/__init__.py +25 -0
  121. nodescraper/plugins/inband/kernel_module/analyzer_args.py +59 -0
  122. nodescraper/plugins/inband/kernel_module/kernel_module_analyzer.py +211 -0
  123. nodescraper/plugins/inband/kernel_module/kernel_module_collector.py +264 -0
  124. nodescraper/plugins/inband/kernel_module/kernel_module_data.py +60 -0
  125. nodescraper/plugins/inband/kernel_module/kernel_module_plugin.py +43 -0
  126. nodescraper/plugins/inband/memory/__init__.py +25 -0
  127. nodescraper/plugins/inband/memory/analyzer_args.py +45 -0
  128. nodescraper/plugins/inband/memory/memory_analyzer.py +98 -0
  129. nodescraper/plugins/inband/memory/memory_collector.py +330 -0
  130. nodescraper/plugins/inband/memory/memory_plugin.py +43 -0
  131. nodescraper/plugins/inband/memory/memorydata.py +90 -0
  132. nodescraper/plugins/inband/network/__init__.py +28 -0
  133. nodescraper/plugins/inband/network/network_collector.py +1828 -0
  134. nodescraper/plugins/inband/network/network_plugin.py +37 -0
  135. nodescraper/plugins/inband/network/networkdata.py +319 -0
  136. nodescraper/plugins/inband/nvme/__init__.py +28 -0
  137. nodescraper/plugins/inband/nvme/nvme_collector.py +167 -0
  138. nodescraper/plugins/inband/nvme/nvme_plugin.py +37 -0
  139. nodescraper/plugins/inband/nvme/nvmedata.py +45 -0
  140. nodescraper/plugins/inband/os/__init__.py +25 -0
  141. nodescraper/plugins/inband/os/analyzer_args.py +64 -0
  142. nodescraper/plugins/inband/os/os_analyzer.py +73 -0
  143. nodescraper/plugins/inband/os/os_collector.py +131 -0
  144. nodescraper/plugins/inband/os/os_plugin.py +43 -0
  145. nodescraper/plugins/inband/os/osdata.py +31 -0
  146. nodescraper/plugins/inband/package/__init__.py +25 -0
  147. nodescraper/plugins/inband/package/analyzer_args.py +48 -0
  148. nodescraper/plugins/inband/package/package_analyzer.py +253 -0
  149. nodescraper/plugins/inband/package/package_collector.py +273 -0
  150. nodescraper/plugins/inband/package/package_plugin.py +43 -0
  151. nodescraper/plugins/inband/package/packagedata.py +41 -0
  152. nodescraper/plugins/inband/pcie/__init__.py +29 -0
  153. nodescraper/plugins/inband/pcie/analyzer_args.py +63 -0
  154. nodescraper/plugins/inband/pcie/pcie_analyzer.py +1081 -0
  155. nodescraper/plugins/inband/pcie/pcie_collector.py +690 -0
  156. nodescraper/plugins/inband/pcie/pcie_data.py +2017 -0
  157. nodescraper/plugins/inband/pcie/pcie_plugin.py +43 -0
  158. nodescraper/plugins/inband/process/__init__.py +25 -0
  159. nodescraper/plugins/inband/process/analyzer_args.py +45 -0
  160. nodescraper/plugins/inband/process/collector_args.py +31 -0
  161. nodescraper/plugins/inband/process/process_analyzer.py +91 -0
  162. nodescraper/plugins/inband/process/process_collector.py +115 -0
  163. nodescraper/plugins/inband/process/process_plugin.py +46 -0
  164. nodescraper/plugins/inband/process/processdata.py +34 -0
  165. nodescraper/plugins/inband/rocm/__init__.py +25 -0
  166. nodescraper/plugins/inband/rocm/analyzer_args.py +66 -0
  167. nodescraper/plugins/inband/rocm/rocm_analyzer.py +100 -0
  168. nodescraper/plugins/inband/rocm/rocm_collector.py +205 -0
  169. nodescraper/plugins/inband/rocm/rocm_plugin.py +43 -0
  170. nodescraper/plugins/inband/rocm/rocmdata.py +62 -0
  171. nodescraper/plugins/inband/storage/__init__.py +25 -0
  172. nodescraper/plugins/inband/storage/analyzer_args.py +38 -0
  173. nodescraper/plugins/inband/storage/collector_args.py +31 -0
  174. nodescraper/plugins/inband/storage/storage_analyzer.py +152 -0
  175. nodescraper/plugins/inband/storage/storage_collector.py +110 -0
  176. nodescraper/plugins/inband/storage/storage_plugin.py +44 -0
  177. nodescraper/plugins/inband/storage/storagedata.py +70 -0
  178. nodescraper/plugins/inband/sysctl/__init__.py +29 -0
  179. nodescraper/plugins/inband/sysctl/analyzer_args.py +67 -0
  180. nodescraper/plugins/inband/sysctl/sysctl_analyzer.py +81 -0
  181. nodescraper/plugins/inband/sysctl/sysctl_collector.py +101 -0
  182. nodescraper/plugins/inband/sysctl/sysctl_plugin.py +43 -0
  183. nodescraper/plugins/inband/sysctl/sysctldata.py +42 -0
  184. nodescraper/plugins/inband/syslog/__init__.py +28 -0
  185. nodescraper/plugins/inband/syslog/syslog_collector.py +121 -0
  186. nodescraper/plugins/inband/syslog/syslog_plugin.py +37 -0
  187. nodescraper/plugins/inband/syslog/syslogdata.py +46 -0
  188. nodescraper/plugins/inband/uptime/__init__.py +25 -0
  189. nodescraper/plugins/inband/uptime/uptime_collector.py +88 -0
  190. nodescraper/plugins/inband/uptime/uptime_plugin.py +37 -0
  191. nodescraper/plugins/inband/uptime/uptimedata.py +31 -0
  192. nodescraper/resultcollators/__init__.py +25 -0
  193. nodescraper/resultcollators/tablesummary.py +159 -0
  194. nodescraper/taskresulthooks/__init__.py +28 -0
  195. nodescraper/taskresulthooks/filesystemloghook.py +88 -0
  196. nodescraper/typeutils.py +171 -0
  197. nodescraper/utils.py +412 -0
@@ -0,0 +1,64 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from typing import Union
27
+
28
+ from pydantic import Field, field_validator
29
+
30
+ from nodescraper.models import AnalyzerArgs
31
+ from nodescraper.plugins.inband.os.osdata import OsDataModel
32
+
33
+
34
+ class OsAnalyzerArgs(AnalyzerArgs):
35
+ exp_os: Union[str, list] = Field(default_factory=list)
36
+ exact_match: bool = True
37
+
38
+ @field_validator("exp_os", mode="before")
39
+ @classmethod
40
+ def validate_exp_os(cls, exp_os: Union[str, list]) -> list:
41
+ """support str or list input for exp_os
42
+
43
+ Args:
44
+ exp_os (Union[str, list]): exp_os input
45
+
46
+ Returns:
47
+ list: exp_os list
48
+ """
49
+ if isinstance(exp_os, str):
50
+ exp_os = [exp_os]
51
+
52
+ return exp_os
53
+
54
+ @classmethod
55
+ def build_from_model(cls, datamodel: OsDataModel) -> "OsAnalyzerArgs":
56
+ """build analyzer args from data model
57
+
58
+ Args:
59
+ datamodel (OsDataModel): data model for plugin
60
+
61
+ Returns:
62
+ OsAnalyzerArgs: instance of analyzer args class
63
+ """
64
+ return cls(exp_os=datamodel.os_name, exact_match=True)
@@ -0,0 +1,73 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from typing import Optional
27
+
28
+ from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus
29
+ from nodescraper.interfaces import DataAnalyzer
30
+ from nodescraper.models import TaskResult
31
+
32
+ from .analyzer_args import OsAnalyzerArgs
33
+ from .osdata import OsDataModel
34
+
35
+
36
+ class OsAnalyzer(DataAnalyzer[OsDataModel, OsAnalyzerArgs]):
37
+ """Check os matches expected versions"""
38
+
39
+ DATA_MODEL = OsDataModel
40
+
41
+ def analyze_data(self, data: OsDataModel, args: Optional[OsAnalyzerArgs] = None) -> TaskResult:
42
+ """Analyze the OS data against expected OS names.
43
+
44
+ Args:
45
+ data (OsDataModel): Operating System data to analyze.
46
+ args (Optional[OsAnalyzerArgs], optional): OS analysis arguments. Defaults to None.
47
+
48
+ Returns:
49
+ TaskResult: Result of the analysis containing status and message.
50
+ """
51
+ if not args or not args.exp_os:
52
+ self.result.message = "Expected OS name not provided"
53
+ self.result.status = ExecutionStatus.NOT_RAN
54
+ return self.result
55
+
56
+ for os_name in args.exp_os:
57
+ if (os_name == data.os_name and args.exact_match) or (
58
+ os_name in data.os_name and not args.exact_match
59
+ ):
60
+ self.result.message = "OS name matches expected"
61
+ self.result.status = ExecutionStatus.OK
62
+ return self.result
63
+
64
+ self.result.message = f"OS name mismatch! Expected: {args.exp_os}, actual: {data.os_name}"
65
+ self.result.status = ExecutionStatus.ERROR
66
+ self._log_event(
67
+ category=EventCategory.OS,
68
+ description=f"{self.result.message}",
69
+ data={"expected": args.exp_os, "actual": data.os_name},
70
+ priority=EventPriority.CRITICAL,
71
+ console_log=True,
72
+ )
73
+ return self.result
@@ -0,0 +1,131 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ import re
27
+ from typing import Optional
28
+
29
+ from nodescraper.base import InBandDataCollector
30
+ from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
31
+ from nodescraper.models import TaskResult
32
+
33
+ from .osdata import OsDataModel
34
+
35
+
36
+ class OsCollector(InBandDataCollector[OsDataModel, None]):
37
+ """Collect OS details"""
38
+
39
+ DATA_MODEL = OsDataModel
40
+ CMD_VERSION_WINDOWS = "wmic os get Version /value"
41
+ CMD_VERSION = "cat /etc/*release | grep VERSION_ID"
42
+ CMD_WINDOWS = "wmic os get Caption /Value"
43
+ PRETTY_STR = "PRETTY_NAME" # noqa: N806
44
+ CMD = f"sh -c '( lsb_release -ds || (cat /etc/*release | grep {PRETTY_STR}) || uname -om ) 2>/dev/null | head -n1'"
45
+
46
+ def collect_version(self) -> str:
47
+ """Collect OS version.
48
+
49
+ Returns:
50
+ str: OS version string, empty string if not found.
51
+ """
52
+ if self.system_info.os_family == OSFamily.WINDOWS:
53
+ res = self._run_sut_cmd(self.CMD_VERSION_WINDOWS)
54
+ if res.exit_code == 0:
55
+ os_version = re.search(r"Version=([\w\s\.]+)", res.stdout).group(1)
56
+ else:
57
+ self._log_event(
58
+ category=EventCategory.OS,
59
+ description="OS version not found",
60
+ priority=EventPriority.ERROR,
61
+ )
62
+ os_version = ""
63
+ else:
64
+ res = self._run_sut_cmd(self.CMD_VERSION)
65
+ if res.exit_code == 0:
66
+ os_version = res.stdout
67
+ os_version = os_version.removeprefix("VERSION_ID=")
68
+ os_version = os_version.strip('" ')
69
+ else:
70
+ self._log_event(
71
+ category=EventCategory.OS,
72
+ description="OS version not found",
73
+ priority=EventPriority.ERROR,
74
+ )
75
+ os_version = ""
76
+ return os_version
77
+
78
+ def collect_data(self, args=None) -> tuple[TaskResult, Optional[OsDataModel]]:
79
+ """Collect OS name and version.
80
+
81
+ Returns:
82
+ tuple[TaskResult, Optional[OsDataModel]]: tuple containing the task result and OS data model or None if not found.
83
+ """
84
+ os_name = None
85
+ if self.system_info.os_family == OSFamily.WINDOWS:
86
+ res = self._run_sut_cmd(self.CMD_WINDOWS)
87
+ if res.exit_code == 0:
88
+ os_name = re.search(r"Caption=([\w\s]+)", res.stdout).group(1)
89
+ else:
90
+ res = self._run_sut_cmd(self.CMD)
91
+ # search for PRETTY_NAME in res
92
+ if res.exit_code == 0:
93
+ if res.stdout.find(self.PRETTY_STR) != -1:
94
+ os_name = res.stdout
95
+ os_name = os_name.removeprefix(f"{self.PRETTY_STR}=")
96
+ # remove the ending/starting quotes and spaces
97
+ os_name = os_name.strip('" ')
98
+ else:
99
+ os_name = res.stdout
100
+ else:
101
+ self._log_event(
102
+ category=EventCategory.OS,
103
+ description="OS name not found",
104
+ priority=EventPriority.ERROR,
105
+ )
106
+
107
+ if os_name:
108
+ os_version = self.collect_version()
109
+ os_data = OsDataModel(
110
+ os_name=os_name,
111
+ os_version=os_version,
112
+ )
113
+ self._log_event(
114
+ category="OS_NAME_READ",
115
+ description="OS name data collected",
116
+ data=os_data.model_dump(),
117
+ priority=EventPriority.INFO,
118
+ )
119
+ self.result.message = f"OS: {os_name}"
120
+ self.result.status = ExecutionStatus.OK
121
+ else:
122
+ os_data = None
123
+ self._log_event(
124
+ category=EventCategory.OS,
125
+ description="OS name not found",
126
+ priority=EventPriority.CRITICAL,
127
+ )
128
+ self.result.message = "OS name not found"
129
+ self.result.status = ExecutionStatus.EXECUTION_FAILURE
130
+
131
+ return self.result, os_data
@@ -0,0 +1,43 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from nodescraper.base import InBandDataPlugin
27
+
28
+ from .analyzer_args import OsAnalyzerArgs
29
+ from .os_analyzer import OsAnalyzer
30
+ from .os_collector import OsCollector
31
+ from .osdata import OsDataModel
32
+
33
+
34
+ class OsPlugin(InBandDataPlugin[OsDataModel, None, OsAnalyzerArgs]):
35
+ """Plugin for collection and analysis of os version data"""
36
+
37
+ DATA_MODEL = OsDataModel
38
+
39
+ COLLECTOR = OsCollector
40
+
41
+ ANALYZER = OsAnalyzer
42
+
43
+ ANALYZER_ARGS = OsAnalyzerArgs
@@ -0,0 +1,31 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from nodescraper.models import DataModel
27
+
28
+
29
+ class OsDataModel(DataModel):
30
+ os_name: str
31
+ os_version: str = ""
@@ -0,0 +1,25 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
@@ -0,0 +1,48 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from typing import Dict, Optional
27
+
28
+ from pydantic import Field
29
+
30
+ from nodescraper.models import AnalyzerArgs
31
+ from nodescraper.plugins.inband.package.packagedata import PackageDataModel
32
+
33
+
34
+ class PackageAnalyzerArgs(AnalyzerArgs):
35
+ exp_package_ver: Dict[str, Optional[str]] = Field(default_factory=dict)
36
+ regex_match: bool = False
37
+ # rocm_regex is optional and should be specified in plugin_config.json if needed
38
+ rocm_regex: Optional[str] = None
39
+ enable_rocm_regex: bool = False
40
+
41
+ @classmethod
42
+ def build_from_model(cls, datamodel: PackageDataModel) -> "PackageAnalyzerArgs":
43
+ # Use custom rocm_regex from collection_args if enable_rocm_regex is true
44
+ rocm_regex = None
45
+ if datamodel.enable_rocm_regex and datamodel.rocm_regex:
46
+ rocm_regex = datamodel.rocm_regex
47
+
48
+ return cls(exp_package_ver=datamodel.version_info, rocm_regex=rocm_regex)
@@ -0,0 +1,253 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ import re
27
+ from typing import Optional, Pattern
28
+
29
+ from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus
30
+ from nodescraper.interfaces import DataAnalyzer
31
+ from nodescraper.models import TaskResult
32
+
33
+ from .analyzer_args import PackageAnalyzerArgs
34
+ from .packagedata import PackageDataModel
35
+
36
+
37
+ class PackageAnalyzer(DataAnalyzer[PackageDataModel, PackageAnalyzerArgs]):
38
+ """Check the package version data against the expected package version data"""
39
+
40
+ DATA_MODEL = PackageDataModel
41
+
42
+ def regex_version_data(
43
+ self,
44
+ package_data: dict[str, str],
45
+ key_search: re.Pattern[str],
46
+ value_search: Optional[Pattern[str]],
47
+ ) -> tuple[bool, list[tuple[str, str, str]]]:
48
+ """Searches the package values for the key and value search patterns
49
+
50
+ Args:
51
+ package_data (dict[str, str]): a dictionary of package names and versions
52
+ key_search (re.Pattern[str]): a compiled regex pattern to search for the package name
53
+ value_search (Optional[Pattern[str]]): a compiled regex pattern to search for the package version, if None then any version is accepted
54
+
55
+ Returns:
56
+ tuple: (value_found, version_mismatches) where value_found is a bool and
57
+ version_mismatches is a list of (package_name, expected_pattern, found_version) tuples
58
+ """
59
+
60
+ value_found = False
61
+ version_mismatches = []
62
+ for name, version in package_data.items():
63
+ self.logger.debug("Package data: %s, %s", name, version)
64
+ key_search_res = key_search.search(name)
65
+ if key_search_res:
66
+ value_found = True
67
+ if value_search is None:
68
+ continue
69
+ value_search_res = value_search.search(version)
70
+ if not value_search_res:
71
+ version_mismatches.append((name, value_search.pattern, version))
72
+ self._log_event(
73
+ EventCategory.APPLICATION,
74
+ f"Package {key_search.pattern} Version Mismatch, Expected {value_search.pattern} but found {version}",
75
+ EventPriority.ERROR,
76
+ {
77
+ "expected_package_search": key_search.pattern,
78
+ "found_package": name,
79
+ "expected_version_search": value_search.pattern,
80
+ "found_version": version,
81
+ },
82
+ )
83
+ return value_found, version_mismatches
84
+
85
+ def package_regex_search(
86
+ self, package_data: dict[str, str], exp_package_data: dict[str, Optional[str]]
87
+ ):
88
+ """Searches the package data for the expected package and version using regex
89
+
90
+ Args:
91
+ package_data (dict[str, str]): a dictionary of package names and versions
92
+ exp_package_data (dict[str, Optional[str]]): a dictionary of expected package names and versions
93
+
94
+ Returns:
95
+ tuple: (not_found_keys, regex_errors, version_mismatches) containing lists of errors
96
+ """
97
+ not_found_keys = []
98
+ regex_errors = []
99
+ version_mismatches = []
100
+
101
+ for exp_key, exp_value in exp_package_data.items():
102
+ try:
103
+ if exp_value is not None:
104
+ value_search = re.compile(exp_value)
105
+ else:
106
+ value_search = None
107
+ key_search = re.compile(exp_key)
108
+ except re.error as e:
109
+ regex_errors.append((exp_key, exp_value, str(e)))
110
+ self._log_event(
111
+ EventCategory.RUNTIME,
112
+ f"Regex Compile Error either {exp_key} {exp_value}",
113
+ EventPriority.ERROR,
114
+ {
115
+ "expected_package_search": exp_key,
116
+ "expected_version_search": exp_value,
117
+ },
118
+ )
119
+ continue
120
+
121
+ key_found, mismatches = self.regex_version_data(package_data, key_search, value_search)
122
+
123
+ # Collect version mismatches
124
+ version_mismatches.extend(mismatches)
125
+
126
+ if not key_found:
127
+ not_found_keys.append((exp_key, exp_value))
128
+ self._log_event(
129
+ EventCategory.APPLICATION,
130
+ f"Package {exp_key} not found in the package list",
131
+ EventPriority.ERROR,
132
+ {
133
+ "expected_package": exp_key,
134
+ "found_package": None,
135
+ "expected_version": exp_value,
136
+ "found_version": None,
137
+ },
138
+ )
139
+
140
+ return not_found_keys, regex_errors, version_mismatches
141
+
142
+ def package_exact_match(
143
+ self, package_data: dict[str, str], exp_package_data: dict[str, Optional[str]]
144
+ ):
145
+ """Checks the package data for the expected package and version using exact match
146
+
147
+ Args:
148
+ package_data (dict[str, str]): a dictionary of package names and versions
149
+ exp_package_data (dict[str, Optional[str]]): a dictionary of expected package names and versions
150
+ """
151
+ not_found_match = []
152
+ not_found_version = []
153
+ for exp_key, exp_value in exp_package_data.items():
154
+ self.logger.info("Expected value: %s, %s", exp_key, exp_value)
155
+ version = package_data.get(exp_key)
156
+ self.logger.info("Found version: %s", version)
157
+ if version is None:
158
+ # package not found
159
+ not_found_version.append((exp_key, exp_value))
160
+ self._log_event(
161
+ EventCategory.APPLICATION,
162
+ f"Package {exp_key} not found in the package list",
163
+ EventPriority.ERROR,
164
+ {
165
+ "expected_package": exp_key,
166
+ "found_package": None,
167
+ "expected_version": exp_value,
168
+ "found_version": None,
169
+ },
170
+ )
171
+ elif exp_value is None:
172
+ # allow any version when expected version is None
173
+ continue
174
+ elif version != exp_value:
175
+ not_found_match.append((exp_key, version))
176
+ self._log_event(
177
+ EventCategory.APPLICATION,
178
+ f"Package {exp_key} Version Mismatch, Expected {exp_value} but found {version}",
179
+ EventPriority.ERROR,
180
+ {
181
+ "expected_package": exp_key,
182
+ "found_package": exp_key,
183
+ "expected_version": exp_value,
184
+ "found_version": version,
185
+ },
186
+ )
187
+ return not_found_match, not_found_version
188
+
189
+ def analyze_data(
190
+ self, data: PackageDataModel, args: Optional[PackageAnalyzerArgs] = None
191
+ ) -> TaskResult:
192
+ """Analyze the package data against the expected package version data
193
+
194
+ Args:
195
+ data (PackageDataModel): package data to analyze
196
+ args (Optional[PackageAnalyzerArgs], optional): package analysis arguments. Defaults to None.
197
+
198
+ Returns:
199
+ TaskResult: the result of the analysis containing status and message
200
+ """
201
+ if not args or not args.exp_package_ver:
202
+ self.result.message = "Expected Package Version Data not provided"
203
+ self.result.status = ExecutionStatus.NOT_RAN
204
+ return self.result
205
+
206
+ if args.regex_match:
207
+ not_found_keys, regex_errors, version_mismatches = self.package_regex_search(
208
+ data.version_info, args.exp_package_ver
209
+ )
210
+
211
+ # Adding details for err message
212
+ error_parts = []
213
+ if not_found_keys:
214
+ packages_detail = ", ".join(
215
+ [
216
+ f"'{pkg}' (expected version: {ver if ver else 'any'})"
217
+ for pkg, ver in not_found_keys
218
+ ]
219
+ )
220
+ error_parts.append(f"Packages not found: {packages_detail}")
221
+
222
+ if regex_errors:
223
+ regex_detail = ", ".join(
224
+ [f"'{pkg}' pattern (version: {ver})" for pkg, ver, _ in regex_errors]
225
+ )
226
+ error_parts.append(f"Regex compile errors: {regex_detail}")
227
+
228
+ if version_mismatches:
229
+ version_detail = ", ".join(
230
+ [
231
+ f"'{pkg}' (expected: {exp}, found: {found})"
232
+ for pkg, exp, found in version_mismatches
233
+ ]
234
+ )
235
+ error_parts.append(f"Version mismatches: {version_detail}")
236
+
237
+ total_errors = len(not_found_keys) + len(regex_errors) + len(version_mismatches)
238
+ if total_errors > 0:
239
+ self.result.message = f"{'; '.join(error_parts)}"
240
+ self.result.status = ExecutionStatus.ERROR
241
+ else:
242
+ self.result.message = "All packages found and versions matched"
243
+ self.result.status = ExecutionStatus.OK
244
+ else:
245
+ self.logger.info("Expected packages: %s", list(args.exp_package_ver.keys()))
246
+ not_found_match, not_found_version = self.package_exact_match(
247
+ data.version_info, args.exp_package_ver
248
+ )
249
+ if not_found_match or not_found_version:
250
+ self.result.message = f"Package version missmatched. Missmatched versions: {not_found_match}, not found versions: {not_found_version}"
251
+ self.result.status = ExecutionStatus.ERROR
252
+
253
+ return self.result