path: root/glustolibs-gluster/glustolibs
diff options
authorsayaleeraut <>2020-08-11 22:46:11 +0530
committerSayalee Raut <>2020-08-12 05:20:03 +0000
commit1d0ff4497fa3df2f4acebbc0eef044fb122b64d9 (patch)
treeb3448f10e5a37816dabb256d587c8b12278c12b8 /glustolibs-gluster/glustolibs
parentd4ee7ad936e45019275e536f0041addee54812c4 (diff)
[LibFix] Add encoding type to get_fattr()
Currently the get_fattr() function returns the xattr value in the hex encoding format. Adding the option to add/specify other encoding types, i.e. text and base64, where hex will be the default encoding format. Reason - When the xattrs are custom set through mountpoint, it becomes easier to test if the value is correct by using the "text" encoding. Example - >>> ret = get_fattr(host, fqpath, fattr) >>> print ret 0x414243 >>> ret = get_fattr(host, fqpath, fattr, encode="text") >>> print ret "ABC" The value "ABC" is easily readable as opposed to 0x414243 when performing a test. Change-Id: Ie2377b924816ebab0a2af116d82600e01f03d61f Signed-off-by: sayaleeraut <>
Diffstat (limited to 'glustolibs-gluster/glustolibs')
1 files changed, 7 insertions, 5 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/ b/glustolibs-gluster/glustolibs/gluster/
index 32068d9f4..86383e800 100755
--- a/glustolibs-gluster/glustolibs/gluster/
+++ b/glustolibs-gluster/glustolibs/gluster/
@@ -97,22 +97,24 @@ def get_mountpoint(host, fqpath):
return None
-def get_fattr(host, fqpath, fattr):
+def get_fattr(host, fqpath, fattr, encode="hex"):
"""getfattr for filepath on remote system
host (str): The hostname/ip of the remote system.
fqpath (str): The fully-qualified path to the file.
fattr (str): name of the fattr to retrieve
+ Kwargs:
+ encode(str): The supported types of encoding are
+ [hex|text|base64]
+ Defaults to hex type of encoding
getfattr result on success. None on fail.
- command = ("getfattr --absolute-names -e hex "
+ command = ("getfattr --absolute-names -e '%s' "
"-n '%s' %s" %
- (fattr, fqpath))
+ (encode, fattr, fqpath))
rcode, rout, rerr =, command)
if not rcode:
return rout.strip().split('=')[1]