diff --git a/packethardware/component/management_controller.py b/packethardware/component/management_controller.py index 99fcc73..fc95582 100644 --- a/packethardware/component/management_controller.py +++ b/packethardware/component/management_controller.py @@ -28,6 +28,10 @@ def __init__(self): self.name = self.model + " Base Management Controller" self.vendor = utils.normalize_vendor(utils.get_mc_info("vendor")) + + if "unknown" in self.vendor.lower(): + self.vendor = utils.get_hardwarevendor_from_hostnamectl(self) + self.serial = utils.get_mc_info("guid") self.data = {"aux": utils.get_mc_info("aux")} diff --git a/packethardware/utils.py b/packethardware/utils.py index 501b0d9..3ea5409 100644 --- a/packethardware/utils.py +++ b/packethardware/utils.py @@ -604,3 +604,17 @@ def get_bios_features(): obj = json.loads(bios_features) return json.dumps(obj) + + +def get_hardwarevendor_from_hostnamectl(self): + hostnamectl_output = cmd_output("hostnamectl", "--json", "pretty") + if hostnamectl_output: + try: + data = json.loads(hostnamectl_output) + return data.get("HardwareVendor", None) + except json.JSONDecodeError: + print("Failed to parse JSON output") + return None + else: + print("Failed to get hostnamectl output") + return None