From: Varsha Rao Date: Tue, 28 Jan 2020 09:53:22 +0000 (+0530) Subject: cephfs-shell: Add getxattr command X-Git-Tag: v15.1.1~575^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0831f612892e681e1b74b3cf3ebfd8434ec44d26;p=ceph.git cephfs-shell: Add getxattr command Fixes: https://tracker.ceph.com/issues/42530 Signed-off-by: Varsha Rao --- diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index a7349b809a97..8e5dc381a0f7 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.