From 0831f612892e681e1b74b3cf3ebfd8434ec44d26 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Tue, 28 Jan 2020 15:23:22 +0530 Subject: [PATCH] cephfs-shell: Add getxattr command Fixes: https://tracker.ceph.com/issues/42530 Signed-off-by: Varsha Rao --- src/tools/cephfs/cephfs-shell | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index a7349b809a9..8e5dc381a0f 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -1433,6 +1433,24 @@ class CephFSShell(Cmd): perror(e) self.exit_code = e.get_error_code() + getxattr_parser = argparse.ArgumentParser( + description='Get extended attribute set for a file') + getxattr_parser.add_argument('path', type=str, action=path_to_bytes, + help='Name of the file') + getxattr_parser.add_argument('name', type=str, help='Extended attribute name') + + @with_argparser(getxattr_parser) + def do_getxattr(self, args): + """ + Get extended attribute for a file + """ + try: + poutput('{}'.format(cephfs.getxattr(args.path, + to_bytes(args.name)).decode('utf-8'))) + except libcephfs.Error as e: + perror(e) + self.exit_code = e.get_error_code() + ####################################################### # # Following are methods that get cephfs-shell started. -- 2.39.5