summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
diff options
context:
space:
mode:
authorTim <timothyasir@gluster.com>2011-08-10 13:16:43 +0530
committerTim <timothyasir@gluster.com>2011-08-10 13:29:54 +0530
commit1811ec9c6177feebff19e5e02a1b26a942d3dcf8 (patch)
tree36115248e07bfa1fa8f1ab409801c392c34d89b1 /src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
parent578247d221b3aea335c4b883a6655cca5ec831b2 (diff)
Bug 3374 - [CIFS] updating volume with a non-existent user succeeds.
Added checks to find non-existing user/s Moved CIFS_VOLUME_FILE, CIFS_USER_FILE, DEFAULT_UID to Globals.py Added getCifsUserUid function into Utils.py Fixed typo in grun.py
Diffstat (limited to 'src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py')
-rw-r--r--src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
index 82f8b7b6..be5df757 100644
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
@@ -1084,3 +1084,18 @@ def getGlusterVersion():
if not rv["Stdout"]:
return None
return rv["Stdout"].strip().split()[1]
+
+def getCifsUserUid(userName):
+ try:
+ fp = open(Globals.CIFS_USER_FILE)
+ content = fp.read()
+ fp.close()
+ except IOError, e:
+ Utils.log("failed to read file %s: %s" % (Globals.CIFS_USER_FILE, str(e)))
+ return False
+
+ for line in content.strip().split():
+ tokens = line.split(":")
+ if tokens[1] == userName:
+ return int(tokens[0])
+ return None