Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nautilus: mgr/telemetry: fix device id splitting when anonymizing serial #37318

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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