Properly format meta and sysmeta in db info cli tools

Currently we make no effort in formatting the meta and sysmeta
inside a db when we use the info (swift-{container,account}-info
tools. This patch properly formats them so they are easier to parse by human eyes.

Change-Id: I5c3d260d677c61213c42662c6641207d9b7f026a
This commit is contained in:
indianwhocodes 2023-05-01 16:41:49 -07:00 committed by ASHWIN A NAIR
parent a82d9c58b6
commit e82536c64d
2 changed files with 12 additions and 5 deletions

View File

@ -298,12 +298,16 @@ def print_db_info_metadata(db_type, info, metadata, drop_prefixes=False,
title = key.replace('_', '-').title()
print(' %s: %s' % (title, value))
if sys_metadata:
print(' System Metadata: %s' % sys_metadata)
print(' System Metadata:')
for key, value in sys_metadata.items():
print(' %s: %s' % (key, value))
else:
print('No system metadata found in db file')
if user_metadata:
print(' User Metadata: %s' % user_metadata)
print(' User Metadata:')
for key, value in user_metadata.items():
print(' %s: %s' % (key, value))
else:
print('No user metadata found in db file')

View File

@ -139,7 +139,8 @@ Metadata:
UUID: abadf100d0ddba11
X-Other-Something: boo
No system metadata found in db file
User Metadata: {'x-account-meta-mydata': 'swift'}'''
User Metadata:
x-account-meta-mydata: swift'''
self.assertEqual(out.getvalue().strip().split('\n'),
exp_out.split('\n'))
@ -190,7 +191,8 @@ Metadata:
UUID: abadf100d0ddba11
X-Container-Bar: goo
X-Container-Foo: bar
System Metadata: {'mydata': 'swift'}
System Metadata:
mydata: swift
No user metadata found in db file
Sharding Metadata:
Type: root
@ -232,7 +234,8 @@ Metadata:
UUID: abadf100d0ddba11
X-Other-Something: boo
No system metadata found in db file
User Metadata: {'x-account-meta-mydata': 'swift'}'''
User Metadata:
x-account-meta-mydata: swift'''
self.assertEqual(sorted(out.getvalue().strip().split('\n')),
sorted(exp_out.split('\n')))