From e28d06253c6a7a0c774089c1d296cae444ca1195 Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Thu, 28 Nov 2024 16:48:12 +0100 Subject: [PATCH] hwbench: generic vendor: make monitoring file optional Since we moved to the generic vendor, we no longer use the mockedvendor by default (it's now only for tests). So when running hwbench on a desktop/laptop for local testing, it requires setting the monitoring file, which wasn't the case before. This change makes the monitoring file optional in this case, with a fallback when it is not provided to the MockedBMC. --- hwbench/environment/vendors/generic.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hwbench/environment/vendors/generic.py b/hwbench/environment/vendors/generic.py index 70862d4..9185331 100644 --- a/hwbench/environment/vendors/generic.py +++ b/hwbench/environment/vendors/generic.py @@ -1,4 +1,5 @@ -from .vendor import Vendor, BMC +from .vendor import Vendor +from .mock import MockedBMC class GenericVendor(Vendor): @@ -9,11 +10,16 @@ def __init__( monitoring_config_filename, ): super().__init__(out_dir, dmi, monitoring_config_filename) - self.bmc = BMC(self.out_dir, self) def detect(self) -> bool: return True + def prepare(self): + if self.get_monitoring_config_filename(): + super().prepare() + else: + self.bmc = MockedBMC(self.out_dir, self) + def save_bios_config(self): print("Warning: using Generic BIOS vendor") # TODO: in the future, dump available BIOS config via redfish @@ -28,3 +34,12 @@ def save_bmc_config(self): def name(self) -> str: return "GenericVendor" + + def find_monitoring_sections( + self, section_type: str, sections_list=[], max_sections=0 + ): + if self.get_monitoring_config_filename(): + return super().find_monitoring_sections( + section_type, sections_list, max_sections + ) + return []