sid in parser and inventory
This commit is contained in:
parent
9b1e8617fa
commit
be53827c02
|
@ -56,9 +56,9 @@ class InventoryView(LoginMix, SnapshotMix):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
txt = "{}, {}".format(err.__class__, err)
|
txt = "{}, {}".format(err.__class__, err)
|
||||||
uuid = snapshot_json.get('uuid')
|
uuid = snapshot_json.get('uuid')
|
||||||
wbid = snapshot_json.get('wbid')
|
sid = snapshot_json.get('sid')
|
||||||
error = SnapshotErrors(
|
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)
|
error.save(commit=True)
|
||||||
self.response = jsonify('')
|
self.response = jsonify('')
|
||||||
|
|
|
@ -208,12 +208,12 @@ class UploadSnapshotForm(FlaskForm, SnapshotMix):
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
txt = "{}".format(err)
|
txt = "{}".format(err)
|
||||||
uuid = snapshot_json.get('uuid')
|
uuid = snapshot_json.get('uuid')
|
||||||
wbid = snapshot_json.get('wbid')
|
sid = snapshot_json.get('sid')
|
||||||
error = SnapshotErrors(
|
error = SnapshotErrors(
|
||||||
description=txt,
|
description=txt,
|
||||||
snapshot_uuid=uuid,
|
snapshot_uuid=uuid,
|
||||||
severity=Severity.Error,
|
severity=Severity.Error,
|
||||||
wbid=wbid,
|
sid=sid,
|
||||||
)
|
)
|
||||||
error.save(commit=True)
|
error.save(commit=True)
|
||||||
self.result[filename] = 'Error'
|
self.result[filename] = 'Error'
|
||||||
|
|
|
@ -14,7 +14,7 @@ class SnapshotErrors(Thing):
|
||||||
|
|
||||||
id = Column(BigInteger, Sequence('snapshot_errors_seq'), primary_key=True)
|
id = Column(BigInteger, Sequence('snapshot_errors_seq'), primary_key=True)
|
||||||
description = Column(CIText(), default='', nullable=False)
|
description = Column(CIText(), default='', nullable=False)
|
||||||
wbid = Column(CIText(), nullable=True)
|
sid = Column(CIText(), nullable=True)
|
||||||
severity = Column(SmallInteger, default=Severity.Info, nullable=False)
|
severity = Column(SmallInteger, default=Severity.Info, nullable=False)
|
||||||
snapshot_uuid = Column(UUID(as_uuid=True), nullable=False)
|
snapshot_uuid = Column(UUID(as_uuid=True), nullable=False)
|
||||||
owner_id = db.Column(
|
owner_id = db.Column(
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ParseSnapshot:
|
||||||
"version": "14.0.0",
|
"version": "14.0.0",
|
||||||
"endTime": snapshot["timestamp"],
|
"endTime": snapshot["timestamp"],
|
||||||
"elapsed": 1,
|
"elapsed": 1,
|
||||||
"wbid": snapshot["wbid"],
|
"sid": snapshot["sid"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_snapshot(self):
|
def get_snapshot(self):
|
||||||
|
@ -317,7 +317,7 @@ class ParseSnapshotLsHw:
|
||||||
def __init__(self, snapshot, default="n/a"):
|
def __init__(self, snapshot, default="n/a"):
|
||||||
self.default = default
|
self.default = default
|
||||||
self.uuid = snapshot.get("uuid")
|
self.uuid = snapshot.get("uuid")
|
||||||
self.wbid = snapshot.get("wbid")
|
self.sid = snapshot.get("sid")
|
||||||
self.dmidecode_raw = snapshot["data"]["dmidecode"]
|
self.dmidecode_raw = snapshot["data"]["dmidecode"]
|
||||||
self.smart = snapshot["data"]["smart"]
|
self.smart = snapshot["data"]["smart"]
|
||||||
self.hwinfo_raw = snapshot["data"]["hwinfo"]
|
self.hwinfo_raw = snapshot["data"]["hwinfo"]
|
||||||
|
@ -342,7 +342,7 @@ class ParseSnapshotLsHw:
|
||||||
"version": "14.0.0",
|
"version": "14.0.0",
|
||||||
"endTime": snapshot["timestamp"],
|
"endTime": snapshot["timestamp"],
|
||||||
"elapsed": 1,
|
"elapsed": 1,
|
||||||
"wbid": snapshot["wbid"],
|
"sid": snapshot["sid"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_snapshot(self):
|
def get_snapshot(self):
|
||||||
|
@ -398,8 +398,10 @@ class ParseSnapshotLsHw:
|
||||||
def get_ram_size(self, ram):
|
def get_ram_size(self, ram):
|
||||||
size = ram.get("Size")
|
size = ram.get("Size")
|
||||||
if not len(size.split(" ")) == 2:
|
if not len(size.split(" ")) == 2:
|
||||||
txt = "Error: Snapshot: {uuid}, tag: {wbid} have this ram Size: {size}".format(
|
txt = (
|
||||||
uuid=self.uuid, size=size, wbid=self.wbid
|
"Error: Snapshot: {uuid}, tag: {sid} have this ram Size: {size}".format(
|
||||||
|
uuid=self.uuid, size=size, sid=self.sid
|
||||||
|
)
|
||||||
)
|
)
|
||||||
self.errors(txt)
|
self.errors(txt)
|
||||||
return 128
|
return 128
|
||||||
|
@ -409,8 +411,8 @@ class ParseSnapshotLsHw:
|
||||||
def get_ram_speed(self, ram):
|
def get_ram_speed(self, ram):
|
||||||
speed = ram.get("Speed", "100")
|
speed = ram.get("Speed", "100")
|
||||||
if not len(speed.split(" ")) == 2:
|
if not len(speed.split(" ")) == 2:
|
||||||
txt = "Error: Snapshot: {uuid}, tag: {wbid} have this ram Speed: {speed}".format(
|
txt = "Error: Snapshot: {uuid}, tag: {sid} have this ram Speed: {speed}".format(
|
||||||
uuid=self.uuid, speed=speed, wbid=self.wbid
|
uuid=self.uuid, speed=speed, sid=self.sid
|
||||||
)
|
)
|
||||||
self.errors(txt)
|
self.errors(txt)
|
||||||
return 100
|
return 100
|
||||||
|
@ -444,8 +446,8 @@ class ParseSnapshotLsHw:
|
||||||
uuid.UUID(dmi_uuid)
|
uuid.UUID(dmi_uuid)
|
||||||
except (ValueError, AttributeError) as err:
|
except (ValueError, AttributeError) as err:
|
||||||
self.errors("{}".format(err))
|
self.errors("{}".format(err))
|
||||||
txt = "Error: Snapshot: {uuid} tag: {wbid} have this uuid: {device}".format(
|
txt = "Error: Snapshot: {uuid} tag: {sid} have this uuid: {device}".format(
|
||||||
uuid=self.uuid, device=dmi_uuid, wbid=self.wbid
|
uuid=self.uuid, device=dmi_uuid, sid=self.sid
|
||||||
)
|
)
|
||||||
self.errors(txt)
|
self.errors(txt)
|
||||||
dmi_uuid = None
|
dmi_uuid = None
|
||||||
|
@ -491,7 +493,7 @@ class ParseSnapshotLsHw:
|
||||||
DataStorageInterface(interface.upper())
|
DataStorageInterface(interface.upper())
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
txt = "tag: {}, interface {} is not in DataStorageInterface Enum".format(
|
txt = "tag: {}, interface {} is not in DataStorageInterface Enum".format(
|
||||||
interface, self.wbid
|
interface, self.sid
|
||||||
)
|
)
|
||||||
self.errors("{}".format(err))
|
self.errors("{}".format(err))
|
||||||
self.errors(txt)
|
self.errors(txt)
|
||||||
|
@ -533,6 +535,6 @@ class ParseSnapshotLsHw:
|
||||||
logger.error(txt)
|
logger.error(txt)
|
||||||
self._errors.append(txt)
|
self._errors.append(txt)
|
||||||
error = SnapshotErrors(
|
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()
|
error.save()
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Snapshot_lite(Thing):
|
||||||
version = String(required=True)
|
version = String(required=True)
|
||||||
schema_api = String(required=True)
|
schema_api = String(required=True)
|
||||||
software = String(required=True)
|
software = String(required=True)
|
||||||
wbid = String(required=True)
|
sid = String(required=True)
|
||||||
type = String(required=True)
|
type = String(required=True)
|
||||||
timestamp = String(required=True)
|
timestamp = String(required=True)
|
||||||
data = Nested(Snapshot_lite_data)
|
data = Nested(Snapshot_lite_data)
|
||||||
|
|
Reference in New Issue