Merge "Call out transient sysmeta in swift-object-info"
This commit is contained in:
commit
bdac96e10d
@ -22,7 +22,8 @@ from swift.common.utils import hash_path, storage_directory, \
|
||||
Timestamp, is_valid_ipv6
|
||||
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, \
|
||||
@ -274,6 +275,7 @@ def print_obj_metadata(metadata):
|
||||
"""
|
||||
user_metadata = {}
|
||||
sys_metadata = {}
|
||||
transient_sys_metadata = {}
|
||||
other_metadata = {}
|
||||
|
||||
if not metadata:
|
||||
@ -310,6 +312,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
|
||||
|
||||
@ -322,6 +326,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)
|
||||
|
||||
|
@ -719,9 +719,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
|
||||
|
||||
@ -738,6 +740,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:
|
||||
@ -763,6 +767,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:
|
||||
@ -788,6 +794,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:
|
||||
@ -809,6 +817,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:
|
||||
@ -832,6 +842,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:
|
||||
@ -854,6 +866,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:
|
||||
@ -876,6 +890,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:
|
||||
@ -883,6 +899,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