summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2015-05-04 15:23:06 +0530
committerPrashanth Pai <ppai@redhat.com>2015-06-11 13:10:56 +0530
commit1943dcd4c9ad652013592653b087350560b7a778 (patch)
tree3ee752b45860d1517b1fa45340cd0746bfbae0ac
parent385dd1635dc243feafb6b234a4feb80417ee9f4f (diff)
Explicitly set .so file if find_library() fails
Change-Id: I8678148961ee192d96e887b6ca7f4b8e4ba89507 Signed-off-by: Prashanth Pai <ppai@redhat.com>
-rwxr-xr-xgluster/api.py19
-rwxr-xr-xgluster/gfapi.py5
2 files changed, 21 insertions, 3 deletions
diff --git a/gluster/api.py b/gluster/api.py
index 3309471..1b5d320 100755
--- a/gluster/api.py
+++ b/gluster/api.py
@@ -13,9 +13,26 @@ import ctypes
from ctypes.util import find_library
+# LD_LIBRARY_PATH is not looked up by ctypes.util.find_library()
+so_file_name = find_library("gfapi")
+
+if so_file_name is None:
+ for name in ["libgfapi.so.0", "libgfapi.so"]:
+ try:
+ ctypes.CDLL(name, ctypes.RTLD_GLOBAL, use_errno=True)
+ except OSError:
+ pass
+ else:
+ so_file_name = name
+ break
+ if so_file_name is None:
+ # The .so file cannot be found (or loaded)
+ # May be you need to run ldconfig command
+ raise Exception("libgfapi.so not found")
+
# Looks like ctypes is having trouble with dependencies, so just force them to
# load with RTLD_GLOBAL until I figure that out.
-client = ctypes.CDLL(find_library("gfapi"), ctypes.RTLD_GLOBAL, use_errno=True)
+client = ctypes.CDLL(so_file_name, ctypes.RTLD_GLOBAL, use_errno=True)
# The above statement "may" fail with OSError on some systems if libgfapi.so
# is located in /usr/local/lib/. This happens when glusterfs is installed from
# source. Refer to: http://bugs.python.org/issue18502
diff --git a/gluster/gfapi.py b/gluster/gfapi.py
index 4aaca38..3554657 100755
--- a/gluster/gfapi.py
+++ b/gluster/gfapi.py
@@ -335,7 +335,7 @@ class Volume(object):
if not isinstance(ent, api.Dirent):
break
name = ent.d_name[:ent.d_reclen]
- if not name in [".", ".."]:
+ if name not in [".", ".."]:
dir_list.append(name)
return dir_list
@@ -397,7 +397,8 @@ class Volume(object):
def open(self, path, flags, mode=0777):
if (os.O_CREAT & flags) == os.O_CREAT:
- #Without direct call to _api the functest fails on creat and open.
+ # FIXME:
+ # Without direct call to _api the functest fails on creat and open.
fd = api.client.glfs_creat(self.fs, path, flags, mode)
else: