]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: Add getxattr command
authorVarsha Rao <varao@redhat.com>
Tue, 28 Jan 2020 09:53:22 +0000 (15:23 +0530)
committerVarsha Rao <varao@redhat.com>
Wed, 29 Jan 2020 19:46:27 +0000 (01:16 +0530)
Fixes: https://tracker.ceph.com/issues/42530
Signed-off-by: Varsha Rao <varao@redhat.com>
src/tools/cephfs/cephfs-shell

index a7349b809a97eb4b38bfe41223d56b3fda1517db..8e5dc381a0f7f3ebcd4178dce3069cd81bfb59bb 100755 (executable)
@@ -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.