New function is_executable added to fencing library.
Function checks if path is reachable and executable.
Used for example in fence_amt to check path to amttool.

---
 fence/agents/lib/fencing.py.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index ab14cb7..f4150ff 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, getopt, time, os, uuid, pycurl
+import sys, getopt, time, os, uuid, pycurl, stat
 import pexpect, re, atexit, syslog
 import __main__
 
@@ -1065,3 +1065,10 @@ def fence_login(options, re_login_string = "(login\s*: 
)|(Login Name:  )|(userna
        except pexpect.TIMEOUT:
                fail(EC_LOGIN_DENIED)
        return conn
+
+def is_executable(path):
+       if os.path.exists(path):
+               stats = os.stat(path)
+               if stat.S_ISREG(stats.st_mode) and os.access(path, os.X_OK):
+                       return True
+       return False
-- 
1.8.3.1


Reply via email to