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:
@@ -22,7 +22,8 @@ from swift.common.utils import hash_path, storage_directory, \
|
|||||||
Timestamp
|
Timestamp
|
||||||
from swift.common.ring import Ring
|
from swift.common.ring import Ring
|
||||||
from swift.common.request_helpers import is_sys_meta, is_user_meta, \
|
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.account.backend import AccountBroker, DATADIR as ABDATADIR
|
||||||
from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR
|
from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR
|
||||||
from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \
|
from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \
|
||||||
@@ -256,6 +257,7 @@ def print_obj_metadata(metadata):
|
|||||||
"""
|
"""
|
||||||
user_metadata = {}
|
user_metadata = {}
|
||||||
sys_metadata = {}
|
sys_metadata = {}
|
||||||
|
transient_sys_metadata = {}
|
||||||
other_metadata = {}
|
other_metadata = {}
|
||||||
|
|
||||||
if not metadata:
|
if not metadata:
|
||||||
@@ -292,6 +294,8 @@ def print_obj_metadata(metadata):
|
|||||||
user_metadata[key] = value
|
user_metadata[key] = value
|
||||||
elif is_sys_meta('Object', key):
|
elif is_sys_meta('Object', key):
|
||||||
sys_metadata[key] = value
|
sys_metadata[key] = value
|
||||||
|
elif is_object_transient_sysmeta(key):
|
||||||
|
transient_sys_metadata[key] = value
|
||||||
else:
|
else:
|
||||||
other_metadata[key] = value
|
other_metadata[key] = value
|
||||||
|
|
||||||
@@ -304,6 +308,7 @@ def print_obj_metadata(metadata):
|
|||||||
print(' No metadata found')
|
print(' No metadata found')
|
||||||
|
|
||||||
print_metadata('System Metadata:', sys_metadata)
|
print_metadata('System Metadata:', sys_metadata)
|
||||||
|
print_metadata('Transient System Metadata:', transient_sys_metadata)
|
||||||
print_metadata('User Metadata:', user_metadata)
|
print_metadata('User Metadata:', user_metadata)
|
||||||
print_metadata('Other Metadata:', other_metadata)
|
print_metadata('Other Metadata:', other_metadata)
|
||||||
|
|
||||||
|
@@ -630,9 +630,11 @@ class TestPrintObjFullMeta(TestCliInfoBase):
|
|||||||
print_obj_metadata, [])
|
print_obj_metadata, [])
|
||||||
|
|
||||||
def get_metadata(items):
|
def get_metadata(items):
|
||||||
md = dict(name='/AUTH_admin/c/dummy')
|
md = {
|
||||||
md['Content-Type'] = 'application/octet-stream'
|
'name': '/AUTH_admin/c/dummy',
|
||||||
md['X-Timestamp'] = 106.3
|
'Content-Type': 'application/octet-stream',
|
||||||
|
'X-Timestamp': 106.3,
|
||||||
|
}
|
||||||
md.update(items)
|
md.update(items)
|
||||||
return md
|
return md
|
||||||
|
|
||||||
@@ -649,6 +651,8 @@ Content-Type: application/octet-stream
|
|||||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||||
System Metadata:
|
System Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
X-Object-Meta-Mtime: 107.3
|
X-Object-Meta-Mtime: 107.3
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -674,6 +678,8 @@ Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
|||||||
System Metadata:
|
System Metadata:
|
||||||
X-Object-Sysmeta-Mtime: 107.3
|
X-Object-Sysmeta-Mtime: 107.3
|
||||||
X-Object-Sysmeta-Name: Obj name
|
X-Object-Sysmeta-Name: Obj name
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -699,6 +705,8 @@ Content-Type: application/octet-stream
|
|||||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||||
System Metadata:
|
System Metadata:
|
||||||
X-Object-Sysmeta-Mtime: 107.3
|
X-Object-Sysmeta-Mtime: 107.3
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
X-Object-Meta-Mtime: 107.3
|
X-Object-Meta-Mtime: 107.3
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -720,6 +728,8 @@ Content-Type: application/octet-stream
|
|||||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||||
System Metadata:
|
System Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -743,6 +753,8 @@ Content-Type: application/octet-stream
|
|||||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||||
System Metadata:
|
System Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
X-Object-Meta-Mtime: 107.3
|
X-Object-Meta-Mtime: 107.3
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -765,6 +777,8 @@ Content-Type: Not found in metadata
|
|||||||
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
Timestamp: 1970-01-01T00:01:46.300000 (%s)
|
||||||
System Metadata:
|
System Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
X-Object-Meta-Mtime: 107.3
|
X-Object-Meta-Mtime: 107.3
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -787,6 +801,8 @@ Content-Type: application/octet-stream
|
|||||||
Timestamp: Not found in metadata
|
Timestamp: Not found in metadata
|
||||||
System Metadata:
|
System Metadata:
|
||||||
No metadata found
|
No metadata found
|
||||||
|
Transient System Metadata:
|
||||||
|
No metadata found
|
||||||
User Metadata:
|
User Metadata:
|
||||||
X-Object-Meta-Mtime: 107.3
|
X-Object-Meta-Mtime: 107.3
|
||||||
Other Metadata:
|
Other Metadata:
|
||||||
@@ -794,6 +810,34 @@ Other Metadata:
|
|||||||
|
|
||||||
self.assertEqual(out.getvalue().strip(), exp_out)
|
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):
|
class TestPrintObjWeirdPath(TestPrintObjFullMeta):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Reference in New Issue
Block a user