Skip to content

Commit

Permalink
Merge pull request #37318 from yaarith/nautilus-fix-dev-id-split
Browse files Browse the repository at this point in the history
nautilus: mgr/telemetry: fix device id splitting when anonymizing serial

Reviewed-by: Kiefer Chang <kiefer.chang@suse.com>
  • Loading branch information
yuriw committed Sep 24, 2020
2 parents 24677eb + 0dccfc4 commit 42af857
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pybind/mgr/telemetry/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,21 +397,29 @@ def gather_device_report(self):
if not anon_host:
anon_host = str(uuid.uuid1())
self.set_store('host-id/%s' % host, anon_host)
serial = None
for dev, rep in m.items():
rep['host_id'] = anon_host
if serial is None and 'serial_number' in rep:
serial = rep['serial_number']

# anonymize device id
anon_devid = self.get_store('devid-id/%s' % devid)
if not anon_devid:
anon_devid = devid[:devid.rfind('_')] + '_' + str(uuid.uuid1())
# ideally devid is 'vendor_model_serial',
# but can also be 'model_serial', 'serial'
if '_' in devid:
anon_devid = devid[:devid.rfind('_')] + '_' + str(uuid.uuid1())
else:
anon_devid = str(uuid.uuid1())
self.set_store('devid-id/%s' % devid, anon_devid)
self.log.info('devid %s / %s, host %s / %s' % (devid, anon_devid,
host, anon_host))

# anonymize the smartctl report itself
serial = devid.rsplit('_', 1)[1]
m_str = json.dumps(m)
m = json.loads(m_str.replace(serial, 'deleted'))
if serial:
m_str = json.dumps(m)
m = json.loads(m_str.replace(serial, 'deleted'))

if anon_host not in res:
res[anon_host] = {}
Expand Down

0 comments on commit 42af857

Please sign in to comment.