Commit bb55355a authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Slight modifications in file-show command

* Search by object UUID
* Do not display hashmap by default
parent 1c6539da
......@@ -38,11 +38,11 @@ from optparse import make_option
from import SynnefoCommand
from import utils
from pithos.api.util import get_backend, update_public_meta
from pithos.api.util import get_backend, update_public_meta, is_uuid
class Command(SynnefoCommand):
args = "<account> <container> <object>"
args = "<account> <container> <object> or <object uuid>"
help = """Show file information"""
option_list = SynnefoCommand.option_list + (
......@@ -52,18 +52,30 @@ class Command(SynnefoCommand):
make_option("--domain", dest="domain",
help="Show file attributes from the specific domain."),
make_option("--hashmap", dest="hashmap",
help="Display also the object hashmap")
def handle(self, *args, **options):
if len(args) != 3:
raise CommandError("Invalid number of arguments")
success_status = False
b = get_backend()
account, container, name = args
if len(args) == 3:
account, container, name = args
elif len(args) == 1:
if not is_uuid(args[0]):
raise CommandError('Invalid UUID')
account, container, name = b.get_uuid(
None, args[0], check_permissions=False)
except NameError:
raise CommandError('Unknown UUID')
raise CommandError("Invalid number of arguments")
kv = b.get_object_meta(account, account, container, name,
options['domain'], options['obj_version'])
......@@ -80,9 +92,10 @@ class Command(SynnefoCommand):
if public is not None:
update_public_meta(public, kv)
kv['hashmap'] = b.get_object_hashmap(account, account, container,
if options['hashmap']:
_, kv['hashmap'] = b.get_object_hashmap(account, account,
container, name,
utils.pprint_table(self.stdout, [kv.values()], kv.keys(),
options["output_format"], vertical=True)
......@@ -1367,7 +1367,7 @@ class ModularBackend(BaseBackend):
def get_uuid(self, user, uuid):
def get_uuid(self, user, uuid, check_permissions=True):
"""Return the (account, container, name) for the UUID given."""
info = self.node.latest_uuid(uuid, CLUSTER_NORMAL)
......@@ -1375,7 +1375,8 @@ class ModularBackend(BaseBackend):
raise NameError
path, serial = info
account, container, name = path.split('/', 2)
self._can_read(user, account, container, name)
if check_permissions:
self._can_read(user, account, container, name)
return (account, container, name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment