sid in parser and inventory

This commit is contained in:
Cayo Puigdefabregas 2022-04-25 11:45:25 +02:00
parent 9b1e8617fa
commit be53827c02
5 changed files with 19 additions and 17 deletions

View file

@ -56,9 +56,9 @@ class InventoryView(LoginMix, SnapshotMix):
except Exception as err:
txt = "{}, {}".format(err.__class__, err)
uuid = snapshot_json.get('uuid')
wbid = snapshot_json.get('wbid')
sid = snapshot_json.get('sid')
error = SnapshotErrors(
description=txt, snapshot_uuid=uuid, severity=Severity.Error, wbid=wbid
description=txt, snapshot_uuid=uuid, severity=Severity.Error, sid=sid
)
error.save(commit=True)
self.response = jsonify('')

View file

@ -208,12 +208,12 @@ class UploadSnapshotForm(FlaskForm, SnapshotMix):
except ValidationError as err:
txt = "{}".format(err)
uuid = snapshot_json.get('uuid')
wbid = snapshot_json.get('wbid')
sid = snapshot_json.get('sid')
error = SnapshotErrors(
description=txt,
snapshot_uuid=uuid,
severity=Severity.Error,
wbid=wbid,
sid=sid,
)
error.save(commit=True)
self.result[filename] = 'Error'

View file

@ -14,7 +14,7 @@ class SnapshotErrors(Thing):
id = Column(BigInteger, Sequence('snapshot_errors_seq'), primary_key=True)
description = Column(CIText(), default='', nullable=False)
wbid = Column(CIText(), nullable=True)
sid = Column(CIText(), nullable=True)
severity = Column(SmallInteger, default=Severity.Info, nullable=False)
snapshot_uuid = Column(UUID(as_uuid=True), nullable=False)
owner_id = db.Column(

View file

@ -37,7 +37,7 @@ class ParseSnapshot:
"version": "14.0.0",
"endTime": snapshot["timestamp"],
"elapsed": 1,
"wbid": snapshot["wbid"],
"sid": snapshot["sid"],
}
def get_snapshot(self):
@ -317,7 +317,7 @@ class ParseSnapshotLsHw:
def __init__(self, snapshot, default="n/a"):
self.default = default
self.uuid = snapshot.get("uuid")
self.wbid = snapshot.get("wbid")
self.sid = snapshot.get("sid")
self.dmidecode_raw = snapshot["data"]["dmidecode"]
self.smart = snapshot["data"]["smart"]
self.hwinfo_raw = snapshot["data"]["hwinfo"]
@ -342,7 +342,7 @@ class ParseSnapshotLsHw:
"version": "14.0.0",
"endTime": snapshot["timestamp"],
"elapsed": 1,
"wbid": snapshot["wbid"],
"sid": snapshot["sid"],
}
def get_snapshot(self):
@ -398,8 +398,10 @@ class ParseSnapshotLsHw:
def get_ram_size(self, ram):
size = ram.get("Size")
if not len(size.split(" ")) == 2:
txt = "Error: Snapshot: {uuid}, tag: {wbid} have this ram Size: {size}".format(
uuid=self.uuid, size=size, wbid=self.wbid
txt = (
"Error: Snapshot: {uuid}, tag: {sid} have this ram Size: {size}".format(
uuid=self.uuid, size=size, sid=self.sid
)
)
self.errors(txt)
return 128
@ -409,8 +411,8 @@ class ParseSnapshotLsHw:
def get_ram_speed(self, ram):
speed = ram.get("Speed", "100")
if not len(speed.split(" ")) == 2:
txt = "Error: Snapshot: {uuid}, tag: {wbid} have this ram Speed: {speed}".format(
uuid=self.uuid, speed=speed, wbid=self.wbid
txt = "Error: Snapshot: {uuid}, tag: {sid} have this ram Speed: {speed}".format(
uuid=self.uuid, speed=speed, sid=self.sid
)
self.errors(txt)
return 100
@ -444,8 +446,8 @@ class ParseSnapshotLsHw:
uuid.UUID(dmi_uuid)
except (ValueError, AttributeError) as err:
self.errors("{}".format(err))
txt = "Error: Snapshot: {uuid} tag: {wbid} have this uuid: {device}".format(
uuid=self.uuid, device=dmi_uuid, wbid=self.wbid
txt = "Error: Snapshot: {uuid} tag: {sid} have this uuid: {device}".format(
uuid=self.uuid, device=dmi_uuid, sid=self.sid
)
self.errors(txt)
dmi_uuid = None
@ -491,7 +493,7 @@ class ParseSnapshotLsHw:
DataStorageInterface(interface.upper())
except ValueError as err:
txt = "tag: {}, interface {} is not in DataStorageInterface Enum".format(
interface, self.wbid
interface, self.sid
)
self.errors("{}".format(err))
self.errors(txt)
@ -533,6 +535,6 @@ class ParseSnapshotLsHw:
logger.error(txt)
self._errors.append(txt)
error = SnapshotErrors(
description=txt, snapshot_uuid=self.uuid, severity=severity, wbid=self.wbid
description=txt, snapshot_uuid=self.uuid, severity=severity, sid=self.sid
)
error.save()

View file

@ -19,7 +19,7 @@ class Snapshot_lite(Thing):
version = String(required=True)
schema_api = String(required=True)
software = String(required=True)
wbid = String(required=True)
sid = String(required=True)
type = String(required=True)
timestamp = String(required=True)
data = Nested(Snapshot_lite_data)