Merge pull request #33029 from yaarith/wip-telemetry-show-device

mgr/telemetry: anonymizing smartctl report itself

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Kefu Chai 2020-02-05 20:11:39 +08:00 committed by GitHub
commit 882d1fb28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,6 +169,11 @@ class Module(MgrModule):
"desc": "Show last report or report to be sent",
"perm": "r"
},
{
"cmd": "telemetry show-device",
"desc": "Show last device report or device report to be sent",
"perm": "r"
},
{
"cmd": "telemetry on name=license,type=CephString,req=false",
"desc": "Enable telemetry reports from this cluster",
@ -390,9 +395,9 @@ class Module(MgrModule):
host, anon_host))
# anonymize the smartctl report itself
for k in ['serial_number']:
if k in m:
m.pop(k)
serial = devid.rsplit('_', 1)[1]
m_str = json.dumps(m)
m = json.loads(m_str.replace(serial, 'deleted'))
if anon_host not in res:
res[anon_host] = {}
@ -748,7 +753,12 @@ class Module(MgrModule):
report = self.compile_report(
channels=command.get('channels', None)
)
return 0, json.dumps(report, indent=4, sort_keys=True), ''
report = json.dumps(report, indent=4, sort_keys=True)
if self.channel_device:
report += '\n \nDevice report is generated separately. To see it run \'ceph telemetry show-device\'.'
return 0, report, ''
elif command['prefix'] == 'telemetry show-device':
return 0, json.dumps(self.gather_device_report(), indent=4, sort_keys=True), ''
else:
return (-errno.EINVAL, '',
"Command not found '{0}'".format(command['prefix']))