fix version in snaposhotslog

This commit is contained in:
Cayo Puigdefabregas 2022-05-18 18:00:54 +02:00
parent 1698f35e3d
commit 3d73e1a368
2 changed files with 18 additions and 7 deletions

View File

@ -422,7 +422,7 @@ class Computer(Device):
self._ram = None
@classmethod
def run(cls, lshw, hwinfo_raw, uuid=None, sid=None):
def run(cls, lshw, hwinfo_raw, uuid=None, sid=None, version=None):
"""
Gets hardware information from the computer and its components,
like serial numbers or model names, and benchmarks them.
@ -447,18 +447,24 @@ class Computer(Device):
txt = "Error: Snapshot: {uuid}, sid: {sid}, type_error: {type}, error: {error}".format(
uuid=uuid, sid=sid, type=err.__class__, error=err
)
cls.errors(txt, uuid=uuid, sid=sid)
cls.errors(txt, uuid=uuid, sid=sid, version=version)
return computer, components
@classmethod
def errors(cls, txt=None, uuid=None, sid=None, severity=Severity.Error):
def errors(
cls, txt=None, uuid=None, sid=None, version=None, severity=Severity.Error
):
if not txt:
return
logger.error(txt)
error = SnapshotsLog(
description=txt, snapshot_uuid=uuid, severity=severity, sid=sid
description=txt,
snapshot_uuid=uuid,
severity=severity,
sid=sid,
version=version,
)
error.save()

View File

@ -320,6 +320,7 @@ class ParseSnapshotLsHw:
self.default = default
self.uuid = snapshot.get("uuid")
self.sid = snapshot.get("sid")
self.version = snapshot.get("version")
self.dmidecode_raw = snapshot["data"]["dmidecode"]
self.smart = snapshot["data"]["smart"]
self.hwinfo_raw = snapshot["data"]["hwinfo"]
@ -362,7 +363,7 @@ class ParseSnapshotLsHw:
def set_basic_datas(self):
try:
pc, self.components_obj = Computer.run(
self.lshw, self.hwinfo_raw, self.uuid, self.sid
self.lshw, self.hwinfo_raw, self.uuid, self.sid, self.version
)
pc = pc.dump()
minimum_hid = None in [pc['manufacturer'], pc['model'], pc['serialNumber']]
@ -546,13 +547,17 @@ class ParseSnapshotLsHw:
return action
def errors(self, txt=None, severity=Severity.Info):
def errors(self, txt=None, severity=Severity.Error):
if not txt:
return self._errors
logger.error(txt)
self._errors.append(txt)
error = SnapshotsLog(
description=txt, snapshot_uuid=self.uuid, severity=severity, sid=self.sid
description=txt,
snapshot_uuid=self.uuid,
severity=severity,
sid=self.sid,
version=self.version,
)
error.save()