Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=e4dfd7...
Commit: e4dfd762a9c92231c002e4739752bc8baf738c2b
Parent: 5e1e49d35903417fd974acfb670bc27075c28697
Author: Ondrej Mular <omular(a)redhat.com>
AuthorDate: Mon Dec 30 11:24:46 2013 -0500
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Jan 6 16:37:30 2014 +0100
fencing: add function is_executale
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 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index c8b9bda..ad5dd10 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__
@@ -1079,3 +1079,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