Call out transient sysmeta in swift-object-info
This is similar to the separate output sections for sysmeta and user meta. Change-Id: Icc1fd86b2f7dcc085fee8ee94ec331290b530521
This commit is contained in:
parent
d6c3f6d554
commit
07a157f98e
@ -22,7 +22,8 @@ from swift.common.utils import hash_path, storage_directory, \
|
||||
Timestamp
|
||||
from swift.common.ring import Ring
|
||||
from swift.common.request_helpers import is_sys_meta, is_user_meta, \
|
||||
strip_sys_meta_prefix, strip_user_meta_prefix
|
||||
strip_sys_meta_prefix, strip_user_meta_prefix, \
|
||||
is_object_transient_sysmeta
|
||||
from swift.account.backend import AccountBroker, DATADIR as ABDATADIR
|
||||
from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR
|
||||
from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \
|
||||
@ -256,6 +257,7 @@ def print_obj_metadata(metadata):
|
||||
"""
|
||||
user_metadata = {}
|
||||
sys_metadata = {}
|
||||
transient_sys_metadata = {}
|
||||
other_metadata = {}
|
||||
|
||||
if not metadata:
|
||||
@ -292,6 +294,8 @@ def print_obj_metadata(metadata):
|
||||
user_metadata[key] = value
|
||||
elif is_sys_meta('Object', key):
|
||||
sys_metadata[key] = value
|
||||
elif is_object_transient_sysmeta(key):
|
||||
transient_sys_metadata[key] = value
|
||||
else:
|
||||
other_metadata[key] = value
|
||||
|
||||
@ -304,6 +308,7 @@ def print_obj_metadata(metadata):
|
||||
print(' No metadata found')
|
||||
|
||||
print_metadata('System Metadata:', sys_metadata)
|
||||
print_metadata('Transient System Metadata:', transient_sys_metadata)
|
||||
print_metadata('User Metadata:', user_metadata)
|
||||
print_metadata('Other Metadata:', other_metadata)
|
||||
|
||||
|
@ -630,9 +630,11 @@ class TestPrintObjFullMeta(TestCliInfoBase):
|
||||
print_obj_metadata, [])
|
||||
|
||||
def get_metadata(items):
|
||||
md = dict(name='/AUTH_admin/c/dummy')
|
||||
md['Content-Type'] = 'application/octet-stream'
|
||||
md['X-Timestamp'] = 106.3
|
||||
md = {
|
||||
'name': '/AUTH_admin/c/dummy',
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'X-Timestamp': 106.3,
|
||||
}
|
||||
md.update(items)
|
||||
return md
|
||||
|
||||
@ -649,6 +651,8 @@ Content-Type: application/octet-stream
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
No metadata found
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
@ -674,6 +678,8 @@ Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
X-Object-Sysmeta-Mtime: 107.3
|
||||
X-Object-Sysmeta-Name: Obj name
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
No metadata found
|
||||
Other Metadata:
|
||||
@ -699,6 +705,8 @@ Content-Type: application/octet-stream
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
X-Object-Sysmeta-Mtime: 107.3
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
@ -720,6 +728,8 @@ Content-Type: application/octet-stream
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
No metadata found
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
No metadata found
|
||||
Other Metadata:
|
||||
@ -743,6 +753,8 @@ Content-Type: application/octet-stream
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
No metadata found
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
@ -765,6 +777,8 @@ Content-Type: Not found in metadata
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
No metadata found
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
@ -787,6 +801,8 @@ Content-Type: application/octet-stream
|
||||
Timestamp: Not found in metadata
|
||||
System Metadata:
|
||||
No metadata found
|
||||
Transient System Metadata:
|
||||
No metadata found
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
@ -794,6 +810,34 @@ Other Metadata:
|
||||
|
||||
self.assertEqual(out.getvalue().strip(), exp_out)
|
||||
|
||||
metadata = get_metadata({
|
||||
'X-Object-Meta-Mtime': '107.3',
|
||||
'X-Object-Sysmeta-Mtime': '106.3',
|
||||
'X-Object-Transient-Sysmeta-Mtime': '105.3',
|
||||
'X-Object-Mtime': '104.3',
|
||||
})
|
||||
out = StringIO()
|
||||
with mock.patch('sys.stdout', out):
|
||||
print_obj_metadata(metadata)
|
||||
exp_out = '''Path: /AUTH_admin/c/dummy
|
||||
Account: AUTH_admin
|
||||
Container: c
|
||||
Object: dummy
|
||||
Object hash: 128fdf98bddd1b1e8695f4340e67a67a
|
||||
Content-Type: application/octet-stream
|
||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||
System Metadata:
|
||||
X-Object-Sysmeta-Mtime: 106.3
|
||||
Transient System Metadata:
|
||||
X-Object-Transient-Sysmeta-Mtime: 105.3
|
||||
User Metadata:
|
||||
X-Object-Meta-Mtime: 107.3
|
||||
Other Metadata:
|
||||
X-Object-Mtime: 104.3''' % (
|
||||
utils.Timestamp(106.3).internal)
|
||||
|
||||
self.assertEqual(out.getvalue().strip(), exp_out)
|
||||
|
||||
|
||||
class TestPrintObjWeirdPath(TestPrintObjFullMeta):
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user