change uuid in views and forms for system_uuid
This commit is contained in:
parent
0f916e5964
commit
34def901cb
|
@ -271,7 +271,7 @@ class UploadSnapshotForm(SnapshotMixin, FlaskForm):
|
||||||
self.version = snapshot_json.get('version')
|
self.version = snapshot_json.get('version')
|
||||||
system_uuid = self.get_uuid(debug)
|
system_uuid = self.get_uuid(debug)
|
||||||
if system_uuid:
|
if system_uuid:
|
||||||
snapshot_json['device']['uuid'] = system_uuid
|
snapshot_json['device']['system_uuid'] = system_uuid
|
||||||
|
|
||||||
try:
|
try:
|
||||||
snapshot_json = schema.load(snapshot_json)
|
snapshot_json = schema.load(snapshot_json)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ParseSnapshot:
|
||||||
self.device['type'] = self.get_type()
|
self.device['type'] = self.get_type()
|
||||||
self.device['sku'] = self.get_sku()
|
self.device['sku'] = self.get_sku()
|
||||||
self.device['version'] = self.get_version()
|
self.device['version'] = self.get_version()
|
||||||
self.device['uuid'] = self.get_uuid()
|
self.device['system_uuid'] = self.get_uuid()
|
||||||
|
|
||||||
def set_components(self):
|
def set_components(self):
|
||||||
self.get_cpu()
|
self.get_cpu()
|
||||||
|
@ -379,7 +379,7 @@ class ParseSnapshotLsHw:
|
||||||
raise ValidationError(txt)
|
raise ValidationError(txt)
|
||||||
|
|
||||||
self.device = pc
|
self.device = pc
|
||||||
self.device['uuid'] = self.get_uuid()
|
self.device['system_uuid'] = self.get_uuid()
|
||||||
|
|
||||||
def set_components(self):
|
def set_components(self):
|
||||||
memory = None
|
memory = None
|
||||||
|
|
|
@ -169,7 +169,7 @@ class SnapshotView(SnapshotMixin):
|
||||||
self.sid = None
|
self.sid = None
|
||||||
system_uuid = self.get_uuid(snapshot_json.pop('debug', None))
|
system_uuid = self.get_uuid(snapshot_json.pop('debug', None))
|
||||||
if system_uuid:
|
if system_uuid:
|
||||||
snapshot_json['device']['uuid'] = system_uuid
|
snapshot_json['device']['system_uuid'] = system_uuid
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.snapshot_json = resource_def.schema.load(snapshot_json)
|
self.snapshot_json = resource_def.schema.load(snapshot_json)
|
||||||
|
|
|
@ -177,12 +177,15 @@ class Sync:
|
||||||
inspect(tag).transient for tag in device.tags
|
inspect(tag).transient for tag in device.tags
|
||||||
), 'Tags cannot be synced from DB'
|
), 'Tags cannot be synced from DB'
|
||||||
db_device = None
|
db_device = None
|
||||||
if isinstance(db_device, Computer):
|
if isinstance(device, Computer):
|
||||||
if db_device.uuid:
|
# first search by uuid
|
||||||
db_device = Computer.query.filter_by(
|
if device.system_uuid:
|
||||||
uuid=device.uuid, owner_id=g.user.id, active=True
|
with suppress(ResourceNotFound):
|
||||||
).one()
|
db_device = Computer.query.filter_by(
|
||||||
elif device.hid:
|
system_uuid=device.system_uuid, owner_id=g.user.id, active=True
|
||||||
|
).one()
|
||||||
|
# if no there are any Computer by uuid search by hid
|
||||||
|
if not db_device and device.hid:
|
||||||
with suppress(ResourceNotFound):
|
with suppress(ResourceNotFound):
|
||||||
db_device = Device.query.filter_by(
|
db_device = Device.query.filter_by(
|
||||||
hid=device.hid, owner_id=g.user.id, active=True
|
hid=device.hid, owner_id=g.user.id, active=True
|
||||||
|
|
Reference in a new issue