Skip to content

Commit d5c2ac7

Browse files
committed
added collector args to dimm, dmesg and storage to support skip_sudo
1 parent 545db47 commit d5c2ac7

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

nodescraper/cli/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def generate_reference_config(
331331
for obj in results:
332332
if obj.result_data.collection_result.status != ExecutionStatus.OK:
333333
logger.warning(
334-
"Plugin: %s result status is %, skipping",
334+
"Plugin: %s result status is %s, skipping",
335335
obj.source,
336336
obj.result_data.collection_result.status,
337337
)

nodescraper/pluginexecutor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,23 @@ def apply_global_args_to_plugin(
243243
else:
244244
run_args[key] = global_args[key]
245245

246-
if "collection_args" in global_args and hasattr(plugin_class, "COLLECTOR_ARGS"):
246+
if (
247+
"collection_args" in global_args
248+
and getattr(plugin_class, "COLLECTOR_ARGS", None) is not None
249+
and "COLLECTOR_ARGS" in plugin_class.__dict__
250+
):
247251
plugin_fields = set(plugin_class.COLLECTOR_ARGS.__fields__.keys())
248252
filtered = {
249253
k: v for k, v in global_args["collection_args"].items() if k in plugin_fields
250254
}
251255
if filtered:
252256
run_args["collection_args"] = filtered
253257

254-
if "analysis_args" in global_args and hasattr(plugin_class, "ANALYZER_ARGS"):
258+
if (
259+
"analysis_args" in global_args
260+
and getattr(plugin_class, "ANALYZER_ARGS", None) is not None
261+
and "ANALYZER_ARGS" in plugin_class.__dict__
262+
):
255263
plugin_fields = set(plugin_class.ANALYZER_ARGS.__fields__.keys())
256264
filtered = {k: v for k, v in global_args["analysis_args"].items() if k in plugin_fields}
257265
if filtered:

nodescraper/plugins/inband/dimm/dimm_collector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def collect_data(
5050
self.result.message = "Skipping sudo plugin"
5151
self.result.status = ExecutionStatus.NOT_RAN
5252
return self.result, None
53+
5354
dimm_str = None
5455
if self.system_info.os_family == OSFamily.WINDOWS:
5556
res = self._run_sut_cmd("wmic memorychip get Capacity")

nodescraper/plugins/inband/dmesg/dmesg_collector.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26+
from typing import Optional
27+
2628
from nodescraper.base import InBandDataCollector
2729
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
2830
from nodescraper.models import TaskResult
2931

32+
from .collector_args import DmesgCollectorArgs
3033
from .dmesgdata import DmesgData
3134

3235

33-
class DmesgCollector(InBandDataCollector[DmesgData, None]):
36+
class DmesgCollector(InBandDataCollector[DmesgData, DmesgCollectorArgs]):
3437
"""Read dmesg log"""
3538

3639
SUPPORTED_OS_FAMILY = {OSFamily.LINUX}
@@ -60,17 +63,21 @@ def _get_dmesg_content(self) -> str:
6063

6164
def collect_data(
6265
self,
63-
args=None,
66+
args: Optional[DmesgCollectorArgs] = None,
6467
) -> tuple[TaskResult, DmesgData | None]:
6568
"""Collect dmesg data from the system
6669
6770
Returns:
6871
tuple[TaskResult, DmesgData | None]: tuple containing the result of the task and the dmesg data if available
6972
"""
73+
if args is None:
74+
args = DmesgCollectorArgs()
75+
7076
if args.skip_sudo:
7177
self.result.message = "Skipping sudo plugin"
7278
self.result.status = ExecutionStatus.NOT_RAN
7379
return self.result, None
80+
7481
dmesg_content = self._get_dmesg_content()
7582

7683
if dmesg_content:

nodescraper/plugins/inband/storage/storage_collector.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
#
2525
###############################################################################
2626
import re
27+
from typing import Optional
2728

2829
from nodescraper.base import InBandDataCollector
2930
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
3031
from nodescraper.models import TaskResult
3132

33+
from .collector_args import StorageCollectorArgs
3234
from .storagedata import DeviceStorageData, StorageDataModel
3335

3436

@@ -37,8 +39,13 @@ class StorageCollector(InBandDataCollector[StorageDataModel, None]):
3739

3840
DATA_MODEL = StorageDataModel
3941

40-
def collect_data(self, args: None = None) -> tuple[TaskResult, StorageDataModel | None]:
42+
def collect_data(
43+
self, args: Optional[StorageCollectorArgs] = None
44+
) -> tuple[TaskResult, StorageDataModel | None]:
4145
"""read storage usage data"""
46+
if args is None:
47+
args = StorageCollectorArgs()
48+
4249
if args.skip_sudo:
4350
self.result.message = "Skipping sudo plugin"
4451
self.result.status = ExecutionStatus.NOT_RAN

0 commit comments

Comments
 (0)